Java聊天室 IO流 Socket流 GUI界面 客户端ShangXiaCompoent界面详解
效果图
- 界面显示内容
代码
package SanWa.UI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ShangXiaCompoent extends Box {
public static JTextArea infortextArea1;
public ShangXiaCompoent() {
super(BoxLayout.Y_AXIS);
//垂直布局
//组装视图
this.setBackground(new Color(208,208,208));
Box u1Box = Box.createHorizontalBox();
u1Box.setPreferredSize(new Dimension(500, 550));
infortextArea1 = new JTextArea();
infortextArea1.setEditable(false);
infortextArea1.setBounds(0, 0, 500, 200);
infortextArea1.setBackground(new Color(208,208,208));
JScrollPane scrollPane21 = new JScrollPane();
scrollPane21.setBounds(0, 0, 850, 300);
scrollPane21.setViewportView(infortextArea1);
u1Box.add(scrollPane21);
JPanel btnPanel = new JPanel();
Color color = new Color(208,208,208);
btnPanel.setBackground(new Color(50,50,50));
btnPanel.setMaximumSize(new Dimension(1500, 80));
btnPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
JLabel d11Label = new JLabel("弎屲聊天室 ");
d11Label.setBackground(new Color(50,50,50));
d11Label.setForeground(Color.white);
d11Label.setFont(new java.awt.Font("楷体", 1, 35));
JButton getButton = new JButton("神秘按钮");
getButton.setFont(new java.awt.Font("楷体", 1, 20));
getButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "(⑅˃◡˂⑅)弎屲-常祥(づ◡ど)");
}
});
btnPanel.add(d11Label);
btnPanel.add(getButton);
this.add(btnPanel);
Box u5Box = Box.createHorizontalBox();
JScrollPane scrollPane_5 = new JScrollPane();
Box btn1Panel = Box.createHorizontalBox();
btn1Panel.setPreferredSize(new Dimension(600, 60));
JTextArea infortext = new JTextArea();
infortext.setEditable(false);
infortext.setText(" 【欢 迎 来 到 弎 屲 聊 天 室】");
infortext.setFont(new java.awt.Font("楷体", 1, 40));
infortext.setBackground(color);
JLabel d1Label = new JLabel(" 【欢 迎 来 到 弎 屲 聊 天 室】");
d1Label.setFont(new java.awt.Font("楷体", 1, 20));
scrollPane_5.setViewportView(infortext);
u5Box.add(scrollPane_5);
u5Box.setBackground(color);
scrollPane_5.setBackground(color);
this.add(u5Box);
this.add(u1Box);
}
}