界面练习——聊天窗口

版权声明:使用注明出处 https://blog.csdn.net/chunfenxiaotaohua/article/details/82763241
package test;
import java.awt.*;
import javax.swing.*;
public class J091802 extends JFrame{
	JTextArea ta;
	JPanel pan;
	JComboBox cb;
	JButton bu;
	JTextField tf;
	JScrollPane sp;//滚动按钮
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		J091802 j091802=new J091802();
	}
	public J091802()
	{
		ta=new JTextArea();
		pan=new JPanel();
		String[] rw= {"张三","李四","王五","李二麻子"};
		cb=new JComboBox(rw);
		tf=new JTextField(20);
		bu=new JButton("发送");
		sp=new JScrollPane(ta);
		pan.add(cb);pan.add(tf);pan.add(bu);
		this.add(sp);this.add(pan,BorderLayout.SOUTH);
		this.setTitle("聊天窗口练习");
		this.setIconImage((new ImageIcon("image/qq.jpg")).getImage());//获取图片位置
		this.setSize(550, 300);
		this.setLocation(100, 100);
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setResizable(true);
	}
}

猜你喜欢

转载自blog.csdn.net/chunfenxiaotaohua/article/details/82763241