🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ package kehuduan.view; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; public class Chat extends JFrame implements ActionListener{ JTextArea jta;//文本域 JTextField jtf;//文本框 JButton jb;//按钮 JPanel jp;//面板 String ownerId; String friendId; public static void main(String[] args) { Chat t=new Chat("1","2"); } public Chat(String owner ,String friend){ this.ownerId=owner; this.friendId=friend; jta=new JTextArea();//文本域 jtf=new JTextField(15);//文本框 jb=new JButton("发送");//按钮 jb.addActionListener(this); jp=new JPanel();//面板 jp.add(jtf); jp.add(jb); this.add(jta,"Center");//上-文本域 this.add(jp,"South");//下-面板 this.setTitle(ownerId+"正在和"+friend+"聊天"); this.setIconImage((new ImageIcon("image/qq.gif").getImage())); this.setSize(300, 200); this.setLocation(318,186); this.setResizable(false); this.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } } ~~~ ![](https://box.kancloud.cn/a5248eeaeb8ff510168c03ea37045726_298x198.png)