package Test;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.GroupLayout.Alignment;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class Main extends JFrame
{
public static DrawPlace place = new DrawPlace();
public static boolean IsConnect = false; //是否连接
public static boolean TypeFlag; //服务器还是客户端
public static boolean Dash = false; //虚线
public static boolean Full = false; //填充
public static String AllData = ""; //所有信息
public static String Data; //消息
public static String ServerIP; //服务器IP
public static float PenType = 1.0f; //画笔粗细
public static int DrawType = 0; //画图类型
public static Color color = null; //颜色
public static InetAddress myip = null; //本机IP
private JTextField MyIP;
public static JTextField GoalIP;
public static JTextField State; //连接状态
public static JTextArea Message; //消息接收框
public static JTextField MyMessage; //消息发送框
public Main() throws UnknownHostException
{
color = new Color(0,0,0);
place.setFocusable(true);
place.requestFocus();
place.getViewport().setBackground(Color.WHITE);
JComboBox comboBox = new JComboBox();
comboBox.addItem("自由");
comboBox.addItem("直线");
comboBox.addItem("长方形");
comboBox.addItem("圆形");
JSpinner spinner = new JSpinner();
spinner.setModel(new SpinnerNumberModel(new Float(1), new Float(1), new Float(99), new Float(1)));
JCheckBox dash = new JCheckBox("虚线");
JButton Black = new JButton("");
Black.setBackground(Color.BLACK);
JButton Red = new JButton("");
Red.setBackground(Color.RED);
JButton Blue = new JButton("");
Blue.setBackground(Color.BLUE);
JButton Green = new JButton("");
Green.setBackground(Color.GREEN);
JButton Yellow = new JButton("");
Yellow.setBackground(Color.YELLOW);
JButton White = new JButton("");
White.setBackground(Color.WHITE);
MyIP = new JTextField();
MyIP.setColumns(10);
MyIP.setEditable(false);
myip = InetAddress.getLocalHost();
MyIP.setText(myip.getHostName() + ":" + myip.getHostAddress());
GoalIP = new JTextField();
GoalIP.setColumns(10);
GoalIP.setText("");
State = new JTextField();
State.setText("未连接");
State.setColumns(5);
State.setEditable(false);
JButton Send = new JButton("发送");
JButton JoinIn = new JButton("加入连接");
JButton BuildConnect = new JButton("建立连接");
MyMessage = new JTextField();
MyMessage.setColumns(10);
JScrollPane scrollPane = new JScrollPane();
final JButton NowColor = new JButton("");
NowColor.setBackground(Color.BLACK);
JLabel label = new JLabel("当前颜色");
JCheckBox FullType = new JCheckBox("填充图形");
JLabel lblip = new JLabel("本机IP");
JLabel lblip_1 = new JLabel("输入服务器IP");
//=========================================================
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addComponent(spinner, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)
.addComponent(dash)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(Blue, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(White, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(Black, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
.addComponent(Red, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(Green, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
.addComponent(Yellow, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(NowColor, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(label))
.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)
.addComponent(FullType, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(28)
.addComponent(place, GroupLayout.PREFERRED_SIZE, 282, GroupLayout.PREFERRED_SIZE)
.addGap(39)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(9)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addComponent(lblip)
.addComponent(lblip_1, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
.addComponent(MyIP, GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
.addComponent(GoalIP)))
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(BuildConnect)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(JoinIn)
.addGap(12))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(State, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE)
.addGap(44)))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(MyMessage, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
.addGap(6)
.addComponent(Send))
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE))
.addGap(17))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblip)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(MyIP, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lblip_1)
.addGap(1)
.addComponent(GoalIP, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(BuildConnect, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
.addComponent(JoinIn, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(State, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(MyMessage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(Send, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
.addGap(20))
.addGroup(groupLayout.createSequentialGroup()
.addGap(20)
.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Group
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Project4.rar (24个子文件)
Project4
.project 384B
bin
Test
Main$1.class 812B
Main$8.class 2KB
DrawPlace.class 4KB
Main$3.class 861B
Main$7$1.class 1015B
Client.class 3KB
Main$6.class 774B
LogicThread.class 3KB
Main$6$1.class 989B
Server.class 1010B
Main$4.class 797B
Main$5.class 797B
Main$2.class 931B
Main.class 8KB
Main$7.class 774B
.settings
org.eclipse.core.resources.prefs 74B
org.eclipse.jdt.core.prefs 598B
src
Test
Server.java 623B
DrawPlace.java 4KB
LogicThread.java 2KB
Main.java 13KB
Client.java 3KB
.classpath 301B
共 24 条
- 1
资源评论
- 炽天使_2018-01-09下载失败。。。
- LIANNN2017-11-14挺不错的 看看!
- qq_269221572015-07-02挺好的,虽然是csd的
- qq4913139992015-05-09这个可以运行,是很好的学习材料
- 初_凉2015-06-10还不错,就是画板可绘图面积小了点
柱柱快跑
- 粉丝: 4
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功