package net.test;
import java.awt.Color;
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Graphics;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.Polygon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.GroupLayout.Alignment;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.UndoableEditEvent;
import javax.swing.event.UndoableEditListener;
import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
import javax.swing.undo.UndoManager;
import javax.swing.undo.UndoableEdit;
import javax.swing.undo.UndoableEditSupport;
//
//import Undo.UndoableDrawEdit;
//import Undo.UndoableDrawingPanel;
//import Undo.UndoManagerHelper.RedoAction;
//import Undo.UndoManagerHelper.UndoAction;
//import Undo.UndoManagerHelper.UndoRedoAction;
//import Undo.UndoableDrawingPanel;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.awt.image.BufferedImage;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
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 JLabel mark; //设置提示文本
public static boolean Full = false; //填充
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 MenuBar mb=new MenuBar();
public static JTextArea scrollPane = new JTextArea(); //显示状态
public static JButton clear=new JButton("清空");
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)));
mark = new JLabel();
mark.setText("线条粗细调整");
Menu m1=new Menu("文件"); //菜单栏
MenuItem m1_4=new MenuItem("新建");
MenuItem m1_1=new MenuItem("打开");
MenuItem m1_2=new MenuItem("保存");
MenuItem m1_3=new MenuItem("退出");
Menu m2=new Menu("编辑");
MenuItem m2_1=new MenuItem("撤销");
MenuItem m2_2=new MenuItem("前进");
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("");
scrollPane.setText("未连接");
scrollPane.setColumns(10);
scrollPane.setEditable(false);
scrollPane.setBackground(Color.BLACK);
scrollPane.setForeground(Color.GREEN);
JButton JoinIn = new JButton("加入连接");
JButton BuildConnect = new JButton("建立连接");
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,GroupLayout.PREFERRED_SIZE,30,GroupLayout.PREFERRED_SIZE)
.addComponent(mark, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
.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(clear) //添加清空按钮
.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, 300, 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()
.addGap(44)))
.addGroup(groupLayout.createSequentialGroup()
.addGap(6))
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE)
) .addGap(17))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblip)
.addPreferredGap(C
网络画板java源代码
需积分: 10 31 浏览量
2016-06-14
14:02:12
上传
评论 1
收藏 69KB RAR 举报
pineappleAndorange
- 粉丝: 1
- 资源: 5
最新资源
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈