------<a href="http://www.itheima.com" target="blank">Java培训、Android培训、iOS培训、.Net培训</a>、期待与您交流! -------
刚接触到java界面编程时还是有点小兴奋,看着自己敲的代码一运行就出来一个小窗口,而且小窗口的大小和名称都能
自己设置.虽然java主要是后台强大,但界面编程还是熟悉下吧,下面就是我自己当初写的一段界面程序。
- import java.awt.*;
- import javax.swing.*;
- public class Text2 extends JFrame
- {
- JTextArea jta;
- JScrollPane jsp;
- JPanel jp1;
- JComboBox jcb;
- JTextField jtf;
- JButton jb;
- public static void main(String[] args)
- {
- Text2 e=new Text2();
- }
- public Text2()
- {
- jta=new JTextArea();
- jsp=new JScrollPane(jta);
- jp1=new JPanel();
- String liao[]={"奥巴马","拉登"};
- jcb=new JComboBox(liao);
- jtf=new JTextField(10);
- jb=new JButton("发送");
- jp1.add(jcb);
- jp1.add(jtf);
- jp1.add(jb);
- this.add(jsp);
- this.add(jp1,BorderLayout.SOUTH);
- this.setSize(300,300);
- this.setIconImage((new ImageIcon("tse/420c75f082025aaf67b8de7dfbedab64024f1a99.jpg")).getImage());
- this.setDefaultCloseOperation(EXIT_ON_CLOSE);
- this.setLocation(100,100);
- this.setTitle("武爷");
- this.setVisible(true);
- }