//聊天窗口 import java.awt.*; import javax.swing.*; public class Jiemian9 extends JFrame{ JTextArea wby; //文本域 JPanel mb; //面板 JComboBox xlk; //下拉框 JButton an; //按钮 JTextField wbk; //文本框 JScrollPane gd; //滚动 public static void main(String[] args){ //运行本类的构造方法 Jiemian9 jiemian = new Jiemian9(); } public Jiemian9(){ //添加 wby = new JTextArea(); mb = new JPanel(); String[] lt = {"悟空","八戒","沙僧","唐僧"}; xlk = new JComboBox(lt); an = new JButton("发送"); wbk = new JTextField(10); gd = new JScrollPane(wby); //添加到面板 mb.add(xlk); mb.add(wbk); mb.add(an); this.add(gd); this.add(mb,BorderLayout.SOUTH); //设置窗口标题 this.setTitle("聊天窗口"); //设置窗口的宽高 this.setSize(500,350); //添加标题栏图片 this.setIconImage((new ImageIcon("image/1.jpg")).getImage()); //设置窗口出现对于屏幕的位置 this.setLocation(100,100); //禁止拉大拉小 this.setResizable(false); //关闭窗口后释放资源 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //输出窗口 this.setVisible(true); } }
时间: 2024-10-29 19:11:39