package com.itheima;
import javax.swing.*;
public class JFrame06 {
public static void main(String[] args) {
JFrame jf=new JFrame();
jf.setTitle("聊天室");
jf.setSize(400,300);
jf.setDefaultCloseOperation(3);
jf.setLocationRelativeTo(null);
jf.setAlwaysOnTop(true);
jf.setLayout(null); //取消窗体的默认布局
//显示聊天信息的文本域
JTextArea messageArea =new JTextArea();
messageArea.setBounds(10,10,360,200);
jf.add(messageArea);
//输入聊天信息的文本框
JTextField messageField = new JTextField();
messageField.setBounds(10,230,180,20);
jf.add(messageField);
//发送按钮
JButton PutButton = new JButton("发送");
PutButton.setBounds(200,230,70,20);
jf.add(PutButton);
//清空聊天
//发送按钮
JButton CleanButton = new JButton("清空聊天");
CleanButton.setBounds(280,230,100,20);
jf.add(CleanButton);
//添加按钮到窗体中
jf.setVisible(true);
}
}
标签:聊天室,JAVA,setBounds,PutButton,add,new,jf,JButton
From: https://www.cnblogs.com/cy-xt/p/16840074.html