⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chatwindow.java

📁 简单的聊天程序
💻 JAVA
字号:

import java.awt.*;

import javax.swing.*;

public class ChatWindow extends JFrame{
	private JTextArea showField,sendField;
	private JLabel fontLab,fontSizeLab,showColor;
	private JButton fontBut,qqFace,fontColor;
	private JComboBox fontSytle,fontSize;
	public ChatWindow(){
		buildGUI();
		hookEvent();
		init();
	}
	private void buildGUI(){

		
		showField = new JTextArea(10,30);
		sendField = new JTextArea(4,30);
		showField.setBackground(Color.pink);
		JPanel toolBar = new JPanel();
		GridBagLayout gb = new GridBagLayout();
		JPanel chatP = new JPanel();
		chatP.setLayout(gb);
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.BOTH;
		addGCmp(chatP,showField,gb,gbc,0,0,1,1,1,1);
		addGCmp(chatP,sendField,gb,gbc,0,2,1,1,1,1);
		//工具条不会变化
		
		gbc.fill = GridBagConstraints.NONE;
		addGCmp(chatP,toolBar,gb,gbc,0,1,1,1,0,0);
		JTabbedPane tp = new JTabbedPane();
		tp.addTab("聊天",chatP);
		this.getContentPane().add(tp);
		this.setSize(400,400);
		this.setVisible(true);

	}
	private void addGCmp(
			Container father,Component c,
			GridBagLayout gb,GridBagConstraints gbc,
			int gridx,int gridy,
			int gridWeight,int gridHeight,
			int weightx,int weighty)
	{
		gbc.gridx = gridx;
		gbc.gridy = gridy;
		gbc.gridwidth = gridWeight;
		gbc.gridheight = gridHeight;
		gbc.weightx = weightx;
		gbc.weighty = weighty;
		gb.setConstraints(c,gbc);
		father.add(c);
	}
	private void hookEvent(){

	}
	private void init(){

	}
	public static void main(String[] args)
	{
		new ChatWindow();
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -