1个回答
展开全部
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
public class UI extends JFrame implements ActionListener{
private static final long serialVersionUID = 2L;
JTextField jtfDna1=new JTextField(20);
JTextField jtfDna2=new JTextField(20);
JButton jbtSovle;
JButton jbtReset;
JLabel jlbRsDna1;
JLabel jlb_1to2;
JLabel jlbRsDna2;
JLabel jlbEqu;
JLabel jlbExp;
JLabel jlbRs;
DisplayPanel jplCenter;
public UI(){
JPanel jpl1=new JPanel();
jpl1.add(new JLabel("基因序列A:"));
jtfDna1.setText("AGTGATG");
jpl1.add(jtfDna1);
JPanel jpl2=new JPanel();
jpl2.add(new JLabel("基因序列B:"));
jtfDna2.setText("ATTAG");
jpl2.add(jtfDna2);
JPanel jpl3=new JPanel();
jbtSovle=new JButton("计算相似度");
jbtSovle.addActionListener(this);
jbtReset=new JButton("重置");
jbtReset.addActionListener(this);
jbtSovle.setPreferredSize(new Dimension(200,30));
jbtReset.setPreferredSize(new Dimension(100,30));
jpl3.add(jbtSovle);
jpl3.add(jbtReset);
JPanel jplNorth=new JPanel(new GridLayout(3,1));
jplNorth.add(jpl1);
jplNorth.add(jpl2);
jplNorth.add(jpl3);
jplCenter=new DisplayPanel();
jplCenter.setPreferredSize(new Dimension(800, 800));
JScrollPane jslp = new JScrollPane(jplCenter);
jslp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jslp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
setLayout(new BorderLayout());
add(jplNorth,BorderLayout.NORTH);
add(jslp,BorderLayout.CENTER);
this.setTitle("窗口标题");
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(650, 700);
this.setVisible(true);
}
public static void main(String[] args) {
new UI();
}
}
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
public class UI extends JFrame implements ActionListener{
private static final long serialVersionUID = 2L;
JTextField jtfDna1=new JTextField(20);
JTextField jtfDna2=new JTextField(20);
JButton jbtSovle;
JButton jbtReset;
JLabel jlbRsDna1;
JLabel jlb_1to2;
JLabel jlbRsDna2;
JLabel jlbEqu;
JLabel jlbExp;
JLabel jlbRs;
DisplayPanel jplCenter;
public UI(){
JPanel jpl1=new JPanel();
jpl1.add(new JLabel("基因序列A:"));
jtfDna1.setText("AGTGATG");
jpl1.add(jtfDna1);
JPanel jpl2=new JPanel();
jpl2.add(new JLabel("基因序列B:"));
jtfDna2.setText("ATTAG");
jpl2.add(jtfDna2);
JPanel jpl3=new JPanel();
jbtSovle=new JButton("计算相似度");
jbtSovle.addActionListener(this);
jbtReset=new JButton("重置");
jbtReset.addActionListener(this);
jbtSovle.setPreferredSize(new Dimension(200,30));
jbtReset.setPreferredSize(new Dimension(100,30));
jpl3.add(jbtSovle);
jpl3.add(jbtReset);
JPanel jplNorth=new JPanel(new GridLayout(3,1));
jplNorth.add(jpl1);
jplNorth.add(jpl2);
jplNorth.add(jpl3);
jplCenter=new DisplayPanel();
jplCenter.setPreferredSize(new Dimension(800, 800));
JScrollPane jslp = new JScrollPane(jplCenter);
jslp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jslp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
setLayout(new BorderLayout());
add(jplNorth,BorderLayout.NORTH);
add(jslp,BorderLayout.CENTER);
this.setTitle("窗口标题");
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(650, 700);
this.setVisible(true);
}
public static void main(String[] args) {
new UI();
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询