package com.hb.cad;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
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 java.awt.event.MouseMotionAdapter;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.WindowConstants;
import javax.swing.filechooser.FileFilter;
import com.hb.cad.baseShapeInterface.BaseShapeInterface;
import com.hb.cad.canvas.CanvasJPanel;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class CADJFrame extends javax.swing.JFrame implements MouseListener{
private JMenuBar jMenuBar;
private JMenuItem newMenuItem;
private JLabel ellipseLabel;
private JLabel greenLabel;
private JLabel redLabel;
private JLabel yellowLabel;
private JLabel turnLabel;
private JLabel selectLabel;
private JLabel undoLabel;
private JLabel doLabel;
private JLabel pentacleLabel;
private JPopupMenu jPopupMenu1;
private JButton moreColorButton;
private JLabel orangeLabel;
private JLabel lightgrayLabel;
private JLabel magentaLabel;
private JLabel darkgrayLabel;
private JLabel grayLabel;
private JLabel cyanLabel;
private JLabel purpleLabel;
private JLabel blueLabel;
private JLabel blackLabel;
private JLabel colorLabel;
private JLabel pentagonLabel;
private JLabel triangleLabel;
private JLabel roundLabel;
private JLabel rectLabel;
private JLabel lineLabel;
private JPanel toolsPanel;
private CanvasJPanel drawPanel;
private JLabel positionLabel;
private JMenuItem editcolorMenuItem;
private JMenuItem openMenuItem;
private JMenuItem deleteMenuItem;
private JMenuItem undoMenuItem;
private JMenu pictureMenu;
private JMenuItem exitMenuItem;
private JMenuItem saveMenuItem;
private JMenu fileMenu;
private boolean isSame = false; // 校验上次点击和当前鼠标进入是否同一个JLabel
private boolean isClick = false; // 校验是否点击了JLabel
private int flag = -1; // 标记点击的对象是否相同,0代表两次点击对象相同,1代表两次点击对象不同
private String conName = null; // 记录上一次点击对象的名字
/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
CADJFrame inst = new CADJFrame();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
public CADJFrame() {
super("画图");
initGUI();
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
{
{
positionLabel = new JLabel();
getContentPane().add(positionLabel, BorderLayout.SOUTH);
positionLabel.setText(" ");
positionLabel.setPreferredSize(new java.awt.Dimension(392, 26));
}
{
drawPanel = new CanvasJPanel();
getContentPane().add(drawPanel, BorderLayout.CENTER);
drawPanel.setBackground(Color.white);
drawPanel.setLayout(null);
drawPanel.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent evt) {
drawPanelMouseMoved(evt);
}
public void mouseMoved(MouseEvent evt) {
drawPanelMouseMoved(evt);
}
});
drawPanel.setManage(CanvasJPanel.DRAW_LINE);
}
{
toolsPanel = new JPanel();
getContentPane().add(toolsPanel, BorderLayout.WEST);
toolsPanel.setPreferredSize(new java.awt.Dimension(126, 518));
toolsPanel.setLayout(null);
{
javax.swing.ImageIcon image = new javax.swing.ImageIcon("icon\\line.jpg");
image = new javax.swing.ImageIcon(getScaledImage(image.getImage(), 25, 25));
lineLabel = new JLabel(image);
toolsPanel.add(lineLabel);
lineLabel.setBounds(17, 14, 29, 29);
lineLabel.setBackground(new Color(171,215,250));
lineLabel.setOpaque(true);
lineLabel.setName("line");
conName = lineLabel.getName().toString(); // 初始化为直线
lineLabel.addMouseListener(this);
{
jPopupMenu1 = new JPopupMenu();
jPopupMenu1.add("直线");
lineLabel.setComponentPopupMenu(jPopupMenu1);
}
}
{
javax.swing.ImageIcon image = new javax.swing.ImageIcon("icon\\rect.jpg");
image = new javax.swing.ImageIcon(getScaledImage(image.getImage(), 25, 25));
rectLabel = new JLabel(image);
toolsPanel.add(rectLabel);
rectLabel.setBounds(46, 14, 29, 29);
rectLabel.setOpaque(true);
rectLabel.setName("rect");
rectLabel.addMouseListener(this);
{
jPopupMenu1 = new JPopupMenu();
jPopupMenu1.add("矩形");
rectLabel.setComponentPopupMenu(jPopupMenu1);
}
}
{
javax.swing.ImageIcon image = new javax.swing.ImageIcon("icon\\round.jpg");
image = new javax.swing.ImageIcon(getScaledImage(image.getImage(), 25, 25));
roundLabel = new JLabel(image);
toolsPanel.add(roundLabel);
roundLabel.setBounds(75, 14, 29, 29);
roundLabel.setOpaque(true);
roundLabel.setName("round");
roundLabel.addMouseListener(this);
{
jPopupMenu1 = new JPopupMenu();
jPopupMenu1.add("圆");
roundLabel.setComponentPopupMenu(jPopupMenu1);
}
}
{
javax.swing.ImageIcon image = new javax.swing.ImageIcon("icon\\ellipse.jpg");
image = new javax.swing.ImageIcon(getScaledImage(image.getImage(), 25, 25));
ellipseLabel = new JLabel(image);
toolsPanel.add(ellipseLabel);
ellipseLabel.setBounds(17, 43, 29, 29);
ellipseLabel.setOpaque(true);
ellipseLabel.setName("ellipse");
ellipseLabel.addMouseListener(this);
{
jPopupMenu1 = new JPopupMenu();
jPopupMenu1.add("椭圆");
ellipseLabel.setComponentPopupMenu(jPopupMenu1);
}
}
{
javax.swing.ImageIcon image = new javax.swing.ImageIcon("icon\\triangle.jpg");
image = new javax.swing.ImageIcon(getScaledImage(image.getImage(), 25, 25));
triangleLabel = new JLabel(image);
toolsPanel.add(triangleLabel);
triangleLabel.setBounds(46, 43, 29, 29);
triangleLabel.setOpaque(true);
triangleLabel.setName("triangle");
triangleLabel.addMouseListener(this);
{
jPopupMenu1 = new JPopupMenu();
jPopupMenu1.add("正三角形");
triangleLabel.setComponentPopupMenu(jPopupMenu1);
}
}
{
javax.swing.ImageIcon image = new javax.swing.ImageIcon("icon\\pentagon.jpg");
image = new javax.swing.ImageIcon(getScaledImage(image.getImage(), 25, 25));
pentagonLabel = new JLabel(image);
toolsPanel.add(pentagonLabel);
pentagonLabel.setBounds(75, 43, 29, 29);
pentagonLabel.setOpaque(true);
pentagonLabel.setName("pentagon");
pentagonLabel.addMouseListener(this);
{
jPopupMenu1 = new JPopupMenu();
jPopupMenu1.add("正五边形");
pentagonLabel.setComponentPopupMenu(jPopupMenu1);
}
}
{
javax.swing.ImageIcon image = new javax.swing.ImageIcon("icon\\pentacle.jpg");
image = n
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
CAD.rar (33个子文件)
CAD
.project 379B
com
hb
cad
CADJFrame.java 28KB
ColorJDialog.java 3KB
canvas
CanvasJPanel.java 16KB
vssver2.scc 131B
shapes
NewPentagon2D.java 14KB
NewPentacle2D.java 14KB
NewLine2D.java 6KB
NewRound2D.java 9KB
NewRectangle2D.java 12KB
NewTriangle2D.java 16KB
NewEllipse2D.java 10KB
vssver2.scc 370B
baseShapeInterface
BaseShapeInterface.java 4KB
vssver2.scc 149B
ReadAndWrite.java 1KB
vssver2.scc 224B
cloudgarden
layout
AnchorLayout.java 7KB
AnchorConstraint.java 2KB
vssver2.scc 174B
icon
triangle.jpg 2KB
ellipse.jpg 2KB
line.jpg 2KB
do.jpg 805B
rect.jpg 2KB
undo.jpg 791B
select.jpg 780B
turn.jpg 4KB
round.jpg 2KB
pentacle.jpg 2KB
pentagon.jpg 2KB
vssver2.scc 375B
.classpath 226B
共 33 条
- 1
资源评论
NE_cogo
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- PLC 程序 2号卸垛AD778899.gxw
- C#ASP.NET大学在线考试系统源码数据库 SQL2008源码类型 WebForm
- PLC 程序 2号送盖机123DF456.gxw
- ta-lib-0.5.1-cp311-cp311-win-amd64.whl
- 二车间 PLC 程序2号码垛机.gxw
- Qt QChart+Eigen库 绘制线性回归图表,源代码和库都在压缩包里
- 二车间 PLC 2号包装机.gxw
- onnxruntime-win-x64-gpu-1.19.2.zip
- 一车间4号包装机 GX Works3 PLC项目
- java校园管理平台源码数据库 MySQL源码类型 WebForm
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功