import javax.swing.*;
import javax.swing.filechooser.*;
import javax.swing.JComponent.*;
import java.io.File;
import java.awt.*;
import java.awt.Frame.*;
import java.awt.Font.*;
import java.awt.Graphics.*;
import java.awt.Graphics2D.*;
import java.awt.Color.*;
import java.awt.BasicStroke.*;
import java.awt.event.*;
import java.util.*;
import java.lang.Math.*;
import java.awt.AWTException;
import java.awt.image.*;
import java.lang.Exception.*;
import java.io.*;
import javax.imageio.*;
import javax.imageio.stream.*;
public class GraphicsPanel
{
public int Bgt[][]=new int[1000000][8];
public Color colorChoice[]=new Color[1000000];
public int Graphicsnum=0;
public JFrame aFrame;
public int toolState=4;
public int polyPoint[][]=new int[500][2];
public int Pointnum=0;
public int Textnum=0;
public int lineStyle=1;
public int paintStyle=1;
public int brushStyle=1;
public int newState=0;
public String fileName="未命名";
public String filePaths="";
public Color preColor=Color.black;
public Color backColor=Color.white;
public DrawRectPanel aPanel;
public JPanel colorPanel;
public JPanel statePanel;
public DummyPanel dummyPanel;
public JPanel leftPanel;
public JColorChooser aColorChooser;
public JTextField helpText;
public JTextField pointText;
public JTextField rightText;
public ToolPanel toolPanel;
public JPanel toolPanel1;
public JMenuBar aMenuBar;
public JMenu fileMenu,editMenu,helpMenu,viewMenu,colorMenu,ImageMenu;
public JMenuItem openMenuItem,saveMenuItem,saveAsMenuItem,newMenuItem;
public JMenuItem colorMenuItem;
public JMenuItem iColorMenuItem;
//copyMenuItem,cutMenuItem;
public JButton colorButton;
public RectButton rectButton;
public CycleButton cycleButton;
public LineButton lineButton;
public ArcButton arcButton;
public PolyButton polyButton;
public FillButton fillButton;
public EraserButton eraserButton;
public PenButton penButton;
public BrushButton brushButton;
public LargeButton largeButton;
public getButton getButton;
public JTextArea aTextField;
public JFileChooser aFileChooser,bFileChooser;
public ActionListener rectListener,cycleListener,lineListener,arcListener,polyListener,fillListener,eraserListener,penListener,brushListener,colorListener,largeListener,getListener,saveListener;
public Color oldColor;
public GraphicsPanel()
{
aFrame=new JFrame();
aTextField=new JTextArea();
aFrame.setTitle(fileName+"-画图");
aColorChooser=new JColorChooser();
aFileChooser=new JFileChooser();
bFileChooser=new JFileChooser();
//UIManager.put("bFileChooser.newFolderIcon","mspaint.gif");
colorPanel=new JPanel();
aPanel=new DrawRectPanel();
toolPanel=new ToolPanel();
leftPanel=new JPanel();
aMenuBar=new JMenuBar();
toolPanel1=new JPanel();
statePanel=new JPanel();
dummyPanel=new DummyPanel();
fileMenu=new JMenu("文件(F)");
fileMenu.setFont(new Font("menuFont",Font.PLAIN,12));
editMenu=new JMenu("编辑(E)");
editMenu.setFont(new Font("menuFont",Font.PLAIN,12));
viewMenu=new JMenu("查看(V)");
viewMenu.setFont(new Font("menuFont",Font.PLAIN,12));
ImageMenu=new JMenu("图像(I)");
ImageMenu.setFont(new Font("menuFont",Font.PLAIN,12));
colorMenu=new JMenu("颜色(C)");
colorMenu.setFont(new Font("menuFont",Font.PLAIN,12));
helpMenu=new JMenu("帮助(H)");
helpMenu.setFont(new Font("menuFont",Font.PLAIN,12));
newMenuItem=new JMenuItem("新建(N)");
newMenuItem.setFont(new Font("menuFont",Font.PLAIN,12));
openMenuItem=new JMenuItem("打开(O)");
openMenuItem.setFont(new Font("menuFont",Font.PLAIN,12));
saveMenuItem=new JMenuItem("保存(S)");
saveMenuItem.setFont(new Font("menuFont",Font.PLAIN,12));
saveAsMenuItem=new JMenuItem("另存为(A)");
saveAsMenuItem.setFont(new Font("menuFont",Font.PLAIN,12));
colorMenuItem=new JMenuItem("编辑颜色(E)...");
colorMenuItem.setFont(new Font("menuFont",Font.PLAIN,12));
iColorMenuItem=new JMenuItem("反色(I)");
iColorMenuItem.setFont(new Font("menuFont",Font.PLAIN,12));
//cutMenuItem=new JMenuItem("剪切");
//copyMenuItem=new JMenuItem("复制");
helpText=new JTextField();
helpText.setPreferredSize(new Dimension(250,20));
helpText.setEditable(false);
helpText.setBorder(BorderFactory.createLoweredBevelBorder());
pointText=new JTextField();
pointText.setEditable(false);
pointText.setBorder(BorderFactory.createLoweredBevelBorder());
rightText=new JTextField();
rightText.setPreferredSize(new Dimension(60,20));
rightText.setEditable(false);
rightText.setBorder(BorderFactory.createLoweredBevelBorder());
rectButton=new RectButton();
rectButton.setIcon(new ImageIcon("rect.gif"));
cycleButton=new CycleButton();
cycleButton.setIcon(new ImageIcon("cycle.gif"));
lineButton=new LineButton();
lineButton.setIcon(new ImageIcon("line.gif"));
arcButton=new ArcButton();
arcButton.setIcon(new ImageIcon("arc.gif"));
polyButton=new PolyButton();
polyButton.setIcon(new ImageIcon("poly.gif"));
fillButton=new FillButton();
fillButton.setIcon(new ImageIcon("fill.gif"));
eraserButton=new EraserButton();
eraserButton.setIcon(new ImageIcon("eraser.gif"));
penButton=new PenButton();
penButton.setIcon(new ImageIcon("pencil.gif"));
brushButton=new BrushButton();
brushButton.setIcon(new ImageIcon("brush.gif"));
colorButton=new JButton();
colorButton.setBackground(preColor);
colorButton.setPreferredSize(new Dimension(20,20));
largeButton=new LargeButton();
largeButton.setIcon(new ImageIcon("glass.gif"));
getButton=new getButton();
getButton.setIcon(new ImageIcon("get.gif"));
lineListener=new LineListener();
arcListener=new ArcListener();
polyListener=new PolyListener();
cycleListener=new CycleListener();
rectListener=new RectListener();
fillListener=new FillListener();
penListener=new PenListener();
eraserListener=new EraserListener();
brushListener=new BrushListener();
colorListener=new ColorListener();
largeListener=new LargeListener();
getListener=new GetListener();
saveListener=new SaveListener();
lineButton.addActionListener(lineListener);
arcButton.addActionListener(arcListener);
fillButton.addActionListener(fillListener);
polyButton.addActionListener(polyListener);
cycleButton.addActionListener(cycleListener);
rectButton.addActionListener(rectListener);
penButton.addActionListener(penListener);
brushButton.addActionListener(brushListener);
eraserButton.addActionListener(eraserListener);
colorButton.addActionListener(colorListener);
largeButton.addActionListener(largeListener);
getButton.addActionListener(getListener);
fileMenu.setMnemonic('F');
editMenu.setMnemonic('E');
openMenuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_O,InputEvent.CTRL_MASK,false));
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_S,InputEvent.CTRL_MASK,false));
newMenuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_N,InputEvent.CTRL_MASK,false));
iColorMenuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_I,InputEvent.CTRL_MASK,false));
openMenuItem.addActionListener(new OpenListener());
newMenuItem.addActionListener(new NewListener());
saveMenuItem.addActionListener(saveListener);
saveAsMenuItem.addActionListener(new SaveAsListener());
iColorMenuItem.
评论1