| @@ -0,0 +1,329 @@ | ||
| package simplepaint; | ||
|
|
||
| import java.awt.BorderLayout; | ||
| import java.awt.Color; | ||
| import java.awt.Dimension; | ||
| import java.awt.Toolkit; | ||
| import java.io.IOException; | ||
| import java.io.UnsupportedEncodingException; | ||
| import java.util.logging.Level; | ||
| import java.util.logging.Logger; | ||
| import javax.swing.JPanel; | ||
|
|
||
| public class ButtonFrame extends javax.swing.JFrame { | ||
|
|
||
| public ButtonFrame() { | ||
| initComponents(); | ||
| Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); | ||
| double width = screenSize.getWidth(); | ||
| double height = screenSize.getHeight(); | ||
|
|
||
| setSize((int)width, (int)height); | ||
|
|
||
| setVisible(true); | ||
|
|
||
| validate(); | ||
| } | ||
|
|
||
| /** | ||
| * This method is called from within the constructor to initialize the form. | ||
| * WARNING: Do NOT modify this code. The content of this method is always | ||
| * regenerated by the Form Editor. | ||
| */ | ||
| @SuppressWarnings("unchecked") | ||
| // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
| private void initComponents() { | ||
|
|
||
| jToolBar1 = new javax.swing.JToolBar(); | ||
| freehandButton = new javax.swing.JButton(); | ||
| lineButton = new javax.swing.JButton(); | ||
| squareButton = new javax.swing.JButton(); | ||
| rectangleButton = new javax.swing.JButton(); | ||
| circleButton = new javax.swing.JButton(); | ||
| ellipseButton = new javax.swing.JButton(); | ||
| polyButton = new javax.swing.JButton(); | ||
| jSeparator1 = new javax.swing.JToolBar.Separator(); | ||
| undoButton = new javax.swing.JButton(); | ||
| redoButton = new javax.swing.JButton(); | ||
| selectButton = new javax.swing.JButton(); | ||
| jSeparator2 = new javax.swing.JToolBar.Separator(); | ||
| jComboBox1 = new javax.swing.JComboBox(); | ||
| jMenuBar1 = new javax.swing.JMenuBar(); | ||
| jMenu1 = new javax.swing.JMenu(); | ||
| jMenuItem1 = new javax.swing.JMenuItem(); | ||
| jMenuItem2 = new javax.swing.JMenuItem(); | ||
| jMenu2 = new javax.swing.JMenu(); | ||
| jMenuItem3 = new javax.swing.JMenuItem(); | ||
| jMenuItem4 = new javax.swing.JMenuItem(); | ||
| jMenuItem5 = new javax.swing.JMenuItem(); | ||
|
|
||
| setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | ||
|
|
||
| freehandButton.setText("Freehand"); | ||
| freehandButton.setFocusable(false); | ||
| freehandButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| freehandButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(freehandButton); | ||
| this.freehandButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 'f'; | ||
| } | ||
| }); | ||
|
|
||
| lineButton.setText("Line"); | ||
| lineButton.setFocusable(false); | ||
| lineButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| lineButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(lineButton); | ||
| this.lineButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 'l'; | ||
| } | ||
| }); | ||
|
|
||
| squareButton.setText("Square"); | ||
| squareButton.setFocusable(false); | ||
| squareButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| squareButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(squareButton); | ||
| this.squareButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 's'; | ||
| } | ||
| }); | ||
|
|
||
| rectangleButton.setText("Rectangle"); | ||
| rectangleButton.setFocusable(false); | ||
| rectangleButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| rectangleButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(rectangleButton); | ||
| this.rectangleButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 'r'; | ||
| } | ||
| }); | ||
|
|
||
| circleButton.setText("Circle"); | ||
| circleButton.setFocusable(false); | ||
| circleButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| circleButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(circleButton); | ||
| this.circleButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 'c'; | ||
| } | ||
| }); | ||
|
|
||
| ellipseButton.setText("Ellipse"); | ||
| ellipseButton.setFocusable(false); | ||
| ellipseButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| ellipseButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(ellipseButton); | ||
| this.ellipseButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 'o'; | ||
| } | ||
| }); | ||
|
|
||
| polyButton.setText("Polygon"); | ||
| polyButton.setFocusable(false); | ||
| polyButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| polyButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(polyButton); | ||
| jToolBar1.add(jSeparator1); | ||
| this.polyButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 'p'; | ||
| } | ||
| }); | ||
|
|
||
| undoButton.setText("Undo"); | ||
| undoButton.setFocusable(false); | ||
| undoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| undoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(undoButton); | ||
| this.undoButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| try { | ||
| p.undo(); | ||
| } catch (CloneNotSupportedException ex) { | ||
| Logger.getLogger(ButtonFrame.class.getName()).log(Level.SEVERE, null, ex); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| redoButton.setText("Redo"); | ||
| redoButton.setFocusable(false); | ||
| redoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| redoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(redoButton); | ||
| this.redoButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| try { | ||
| p.redo(); | ||
| } catch (CloneNotSupportedException ex) { | ||
| Logger.getLogger(ButtonFrame.class.getName()).log(Level.SEVERE, null, ex); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| selectButton.setText("Select"); | ||
| selectButton.setFocusable(false); | ||
| selectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| selectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(selectButton); | ||
| jToolBar1.add(jSeparator2); | ||
| this.selectButton.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.mode = 'q'; | ||
| } | ||
| }); | ||
|
|
||
| jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Black", "Red", "Yellow", "Blue", "Green", "Magenta" })); | ||
| jToolBar1.add(jComboBox1); | ||
| this.jComboBox1.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| if (jComboBox1.getSelectedItem().equals("Black")) | ||
| p.setColor(Color.black); | ||
| else if (jComboBox1.getSelectedItem().equals("Red")) | ||
| p.setColor(Color.red); | ||
| else if (jComboBox1.getSelectedItem().equals("Yellow")) | ||
| p.setColor(Color.yellow); | ||
| else if (jComboBox1.getSelectedItem().equals("Blue")) | ||
| p.setColor(Color.blue); | ||
| else if (jComboBox1.getSelectedItem().equals("Green")) | ||
| p.setColor(Color.green); | ||
| else if (jComboBox1.getSelectedItem().equals("Magenta")) | ||
| p.setColor(Color.magenta); | ||
| } | ||
| }); | ||
| jComboBox1.addKeyListener(p); | ||
|
|
||
| buttonPanel.add(this.circleButton); | ||
| buttonPanel.add(this.ellipseButton); | ||
| buttonPanel.add(this.freehandButton); | ||
| buttonPanel.add(this.lineButton); | ||
| buttonPanel.add(this.polyButton); | ||
| buttonPanel.add(this.rectangleButton); | ||
| buttonPanel.add(this.squareButton); | ||
| buttonPanel.add(this.selectButton); | ||
| buttonPanel.add(this.undoButton); | ||
| buttonPanel.add(this.redoButton); | ||
| buttonPanel.add(this.jComboBox1); | ||
|
|
||
| jToolBar1.setFloatable(false); | ||
| jToolBar1.setRollover(true); | ||
|
|
||
| jMenu1.setText("File"); | ||
|
|
||
| jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, 0)); | ||
| jMenuItem1.setText("Save"); | ||
| jMenuItem1.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| try { | ||
| p.save(); | ||
| } catch (IOException ex) { | ||
| Logger.getLogger(ButtonFrame.class.getName()).log(Level.SEVERE, null, ex); | ||
| } | ||
| } | ||
| }); | ||
| jMenu1.add(jMenuItem1); | ||
|
|
||
| jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, 0)); | ||
| jMenuItem2.setText("Load"); | ||
| jMenuItem2.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| try { | ||
| p.load(); | ||
| } catch (UnsupportedEncodingException ex) { | ||
| Logger.getLogger(ButtonFrame.class.getName()).log(Level.SEVERE, null, ex); | ||
| } catch (IOException ex) { | ||
| Logger.getLogger(ButtonFrame.class.getName()).log(Level.SEVERE, null, ex); | ||
| } catch (CloneNotSupportedException ex) { | ||
| Logger.getLogger(ButtonFrame.class.getName()).log(Level.SEVERE, null, ex); | ||
| } | ||
| } | ||
| }); | ||
| jMenu1.add(jMenuItem2); | ||
|
|
||
| jMenuBar1.add(jMenu1); | ||
|
|
||
| jMenu2.setText("Edit"); | ||
|
|
||
| jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); | ||
| jMenuItem3.setText("Cut"); | ||
| jMenuItem3.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.cut(); | ||
| } | ||
| }); | ||
| jMenu2.add(jMenuItem3); | ||
|
|
||
| jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); | ||
| jMenuItem4.setText("Copy"); | ||
| jMenuItem4.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| p.copy(); | ||
| } | ||
| }); | ||
| jMenu2.add(jMenuItem4); | ||
|
|
||
| jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); | ||
| jMenuItem5.setText("Paste"); | ||
| jMenuItem5.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| try { | ||
| p.paste(); | ||
| } catch (CloneNotSupportedException ex) { | ||
| Logger.getLogger(ButtonFrame.class.getName()).log(Level.SEVERE, null, ex); | ||
| } | ||
| } | ||
| }); | ||
| jMenu2.add(jMenuItem5); | ||
|
|
||
| jMenuBar1.add(jMenu2); | ||
|
|
||
| setJMenuBar(jMenuBar1); | ||
|
|
||
| setLayout(new BorderLayout()); | ||
|
|
||
| add(buttonPanel, BorderLayout.SOUTH); | ||
|
|
||
| this.addMouseListener(p); | ||
| this.addMouseMotionListener(p); | ||
| this.addKeyListener(p); | ||
| this.add(p, BorderLayout.CENTER); | ||
|
|
||
| pack(); | ||
| }// </editor-fold>//GEN-END:initComponents | ||
|
|
||
| private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed | ||
| // TODO add your handling code here: | ||
| }//GEN-LAST:event_jMenuItem3ActionPerformed | ||
|
|
||
| private javax.swing.JComboBox jComboBox1; | ||
| private javax.swing.JMenu jMenu1; | ||
| private javax.swing.JMenu jMenu2; | ||
| private javax.swing.JMenuBar jMenuBar1; | ||
| private javax.swing.JMenuItem jMenuItem1; | ||
| private javax.swing.JMenuItem jMenuItem2; | ||
| private javax.swing.JMenuItem jMenuItem3; | ||
| private javax.swing.JMenuItem jMenuItem4; | ||
| private javax.swing.JMenuItem jMenuItem5; | ||
| private javax.swing.JToolBar.Separator jSeparator1; | ||
| private javax.swing.JToolBar.Separator jSeparator2; | ||
| private javax.swing.JToolBar jToolBar1; | ||
| private JPanel buttonPanel = new JPanel(); | ||
| private javax.swing.JButton lineButton; | ||
| private javax.swing.JButton polyButton; | ||
| private javax.swing.JButton rectangleButton; | ||
| private javax.swing.JButton redoButton; | ||
| private javax.swing.JButton selectButton; | ||
| private javax.swing.JButton squareButton; | ||
| private javax.swing.JButton undoButton; | ||
| private javax.swing.JButton circleButton; | ||
| private javax.swing.JButton ellipseButton; | ||
| private javax.swing.JButton freehandButton; | ||
| private ApplicationFrame p = new ApplicationFrame(); | ||
|
|
||
| } |
| @@ -32,7 +32,7 @@ public void paint(Graphics g, boolean selected) { | ||
|
|
||
| @Override | ||
| public boolean intersects(int x, int y) { | ||
| return shape.intersects(x, y, 10, 10); | ||
| } | ||
|
|
||
| @Override | ||
| @@ -0,0 +1,233 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
|
|
||
| <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> | ||
| <NonVisualComponents> | ||
| <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> | ||
| <SubComponents> | ||
| <Menu class="javax.swing.JMenu" name="jMenu1"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="File"/> | ||
| </Properties> | ||
| <SubComponents> | ||
| <MenuItem class="javax.swing.JMenuItem" name="jMenuItem1"> | ||
| <Properties> | ||
| <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> | ||
| <KeyStroke key="W"/> | ||
| </Property> | ||
| <Property name="text" type="java.lang.String" value="Save"/> | ||
| </Properties> | ||
| </MenuItem> | ||
| <MenuItem class="javax.swing.JMenuItem" name="jMenuItem2"> | ||
| <Properties> | ||
| <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> | ||
| <KeyStroke key="E"/> | ||
| </Property> | ||
| <Property name="text" type="java.lang.String" value="Load"/> | ||
| </Properties> | ||
| </MenuItem> | ||
| </SubComponents> | ||
| </Menu> | ||
| <Menu class="javax.swing.JMenu" name="jMenu2"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Edit"/> | ||
| </Properties> | ||
| <SubComponents> | ||
| <MenuItem class="javax.swing.JMenuItem" name="jMenuItem3"> | ||
| <Properties> | ||
| <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> | ||
| <KeyStroke key="Ctrl+X"/> | ||
| </Property> | ||
| <Property name="text" type="java.lang.String" value="Cut"/> | ||
| </Properties> | ||
| <Events> | ||
| <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/> | ||
| </Events> | ||
| </MenuItem> | ||
| <MenuItem class="javax.swing.JMenuItem" name="jMenuItem4"> | ||
| <Properties> | ||
| <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> | ||
| <KeyStroke key="Ctrl+C"/> | ||
| </Property> | ||
| <Property name="text" type="java.lang.String" value="Copy"/> | ||
| </Properties> | ||
| </MenuItem> | ||
| <MenuItem class="javax.swing.JMenuItem" name="jMenuItem5"> | ||
| <Properties> | ||
| <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> | ||
| <KeyStroke key="Ctrl+V"/> | ||
| </Property> | ||
| <Property name="text" type="java.lang.String" value="Paste"/> | ||
| </Properties> | ||
| </MenuItem> | ||
| </SubComponents> | ||
| </Menu> | ||
| </SubComponents> | ||
| </Menu> | ||
| </NonVisualComponents> | ||
| <Properties> | ||
| <Property name="defaultCloseOperation" type="int" value="3"/> | ||
| </Properties> | ||
| <SyntheticProperties> | ||
| <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> | ||
| <SyntheticProperty name="formSizePolicy" type="int" value="1"/> | ||
| <SyntheticProperty name="generateCenter" type="boolean" value="false"/> | ||
| </SyntheticProperties> | ||
| <AuxValues> | ||
| <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> | ||
| <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> | ||
| <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
| <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
| <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> | ||
| <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
| <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
| <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
| <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
| </AuxValues> | ||
|
|
||
| <Layout> | ||
| <DimensionLayout dim="0"> | ||
| <Group type="103" groupAlignment="0" attributes="0"> | ||
| <Component id="ryanDoTheThing" alignment="0" max="32767" attributes="0"/> | ||
| </Group> | ||
| </DimensionLayout> | ||
| <DimensionLayout dim="1"> | ||
| <Group type="103" groupAlignment="0" attributes="0"> | ||
| <Component id="ryanDoTheThing" alignment="1" max="32767" attributes="0"/> | ||
| </Group> | ||
| </DimensionLayout> | ||
| </Layout> | ||
| <SubComponents> | ||
| <Container class="javax.swing.JPanel" name="ryanDoTheThing"> | ||
|
|
||
| <Layout> | ||
| <DimensionLayout dim="0"> | ||
| <Group type="103" groupAlignment="0" attributes="0"> | ||
| <Group type="102" alignment="0" attributes="0"> | ||
| <EmptySpace max="-2" attributes="0"/> | ||
| <Component id="jToolBar1" pref="650" max="32767" attributes="0"/> | ||
| <EmptySpace max="-2" attributes="0"/> | ||
| </Group> | ||
| </Group> | ||
| </DimensionLayout> | ||
| <DimensionLayout dim="1"> | ||
| <Group type="103" groupAlignment="0" attributes="0"> | ||
| <Group type="102" alignment="1" attributes="0"> | ||
| <EmptySpace min="0" pref="405" max="32767" attributes="0"/> | ||
| <Component id="jToolBar1" min="-2" max="-2" attributes="0"/> | ||
| </Group> | ||
| </Group> | ||
| </DimensionLayout> | ||
| </Layout> | ||
| <SubComponents> | ||
| <Container class="javax.swing.JToolBar" name="jToolBar1"> | ||
| <Properties> | ||
| <Property name="floatable" type="boolean" value="false"/> | ||
| <Property name="rollover" type="boolean" value="true"/> | ||
| </Properties> | ||
|
|
||
| <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> | ||
| <SubComponents> | ||
| <Component class="javax.swing.JButton" name="freehandButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Freehand"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="lineButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Line"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="squareButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Square"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="rectangleButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Rectangle"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="circleButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Circle"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="ellipseButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Ellipse"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="polyButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Polygon"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JToolBar$Separator" name="jSeparator1"> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="undoButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Undo"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="redoButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Redo"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JButton" name="selectButton"> | ||
| <Properties> | ||
| <Property name="text" type="java.lang.String" value="Select"/> | ||
| <Property name="focusable" type="boolean" value="false"/> | ||
| <Property name="horizontalTextPosition" type="int" value="0"/> | ||
| <Property name="verticalTextPosition" type="int" value="3"/> | ||
| </Properties> | ||
| </Component> | ||
| <Component class="javax.swing.JToolBar$Separator" name="jSeparator2"> | ||
| </Component> | ||
| <Component class="javax.swing.JComboBox" name="jComboBox1"> | ||
| <Properties> | ||
| <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> | ||
| <StringArray count="6"> | ||
| <StringItem index="0" value="Black"/> | ||
| <StringItem index="1" value="Red"/> | ||
| <StringItem index="2" value="Yellow"/> | ||
| <StringItem index="3" value="Blue"/> | ||
| <StringItem index="4" value="Green"/> | ||
| <StringItem index="5" value="Magenta"/> | ||
| </StringArray> | ||
| </Property> | ||
| </Properties> | ||
| </Component> | ||
| </SubComponents> | ||
| </Container> | ||
| </SubComponents> | ||
| </Container> | ||
| </SubComponents> | ||
| </Form> |
| @@ -0,0 +1,235 @@ | ||
| package simplepaint; | ||
|
|
||
| import java.awt.Dimension; | ||
| import java.awt.Toolkit; | ||
| import javax.swing.JPanel; | ||
|
|
||
| public class SketchUI extends javax.swing.JFrame { | ||
|
|
||
| public SketchUI() { | ||
| initComponents(); | ||
| Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); | ||
| double width = screenSize.getWidth(); | ||
| double height = screenSize.getHeight(); | ||
|
|
||
| setSize((int)width, (int)height); | ||
| } | ||
|
|
||
| public JPanel getPanel() { | ||
| return ryanDoTheThing; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * This method is called from within the constructor to initialize the form. | ||
| * WARNING: Do NOT modify this code. The content of this method is always | ||
| * regenerated by the Form Editor. | ||
| */ | ||
| @SuppressWarnings("unchecked") | ||
| // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
| private void initComponents() { | ||
|
|
||
| ryanDoTheThing = new javax.swing.JPanel(); | ||
| jToolBar1 = new javax.swing.JToolBar(); | ||
| freehandButton = new javax.swing.JButton(); | ||
| lineButton = new javax.swing.JButton(); | ||
| squareButton = new javax.swing.JButton(); | ||
| rectangleButton = new javax.swing.JButton(); | ||
| circleButton = new javax.swing.JButton(); | ||
| ellipseButton = new javax.swing.JButton(); | ||
| polyButton = new javax.swing.JButton(); | ||
| jSeparator1 = new javax.swing.JToolBar.Separator(); | ||
| undoButton = new javax.swing.JButton(); | ||
| redoButton = new javax.swing.JButton(); | ||
| selectButton = new javax.swing.JButton(); | ||
| jSeparator2 = new javax.swing.JToolBar.Separator(); | ||
| jComboBox1 = new javax.swing.JComboBox(); | ||
| jMenuBar1 = new javax.swing.JMenuBar(); | ||
| jMenu1 = new javax.swing.JMenu(); | ||
| jMenuItem1 = new javax.swing.JMenuItem(); | ||
| jMenuItem2 = new javax.swing.JMenuItem(); | ||
| jMenu2 = new javax.swing.JMenu(); | ||
| jMenuItem3 = new javax.swing.JMenuItem(); | ||
| jMenuItem4 = new javax.swing.JMenuItem(); | ||
| jMenuItem5 = new javax.swing.JMenuItem(); | ||
|
|
||
| setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | ||
|
|
||
| jToolBar1.setFloatable(false); | ||
| jToolBar1.setRollover(true); | ||
|
|
||
| freehandButton.setText("Freehand"); | ||
| freehandButton.setFocusable(false); | ||
| freehandButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| freehandButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(freehandButton); | ||
|
|
||
| lineButton.setText("Line"); | ||
| lineButton.setFocusable(false); | ||
| lineButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| lineButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(lineButton); | ||
|
|
||
| squareButton.setText("Square"); | ||
| squareButton.setFocusable(false); | ||
| squareButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| squareButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(squareButton); | ||
|
|
||
| rectangleButton.setText("Rectangle"); | ||
| rectangleButton.setFocusable(false); | ||
| rectangleButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| rectangleButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(rectangleButton); | ||
|
|
||
| circleButton.setText("Circle"); | ||
| circleButton.setFocusable(false); | ||
| circleButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| circleButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(circleButton); | ||
|
|
||
| ellipseButton.setText("Ellipse"); | ||
| ellipseButton.setFocusable(false); | ||
| ellipseButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| ellipseButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(ellipseButton); | ||
|
|
||
| polyButton.setText("Polygon"); | ||
| polyButton.setFocusable(false); | ||
| polyButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| polyButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(polyButton); | ||
| jToolBar1.add(jSeparator1); | ||
|
|
||
| undoButton.setText("Undo"); | ||
| undoButton.setFocusable(false); | ||
| undoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| undoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(undoButton); | ||
|
|
||
| redoButton.setText("Redo"); | ||
| redoButton.setFocusable(false); | ||
| redoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| redoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(redoButton); | ||
|
|
||
| selectButton.setText("Select"); | ||
| selectButton.setFocusable(false); | ||
| selectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | ||
| selectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); | ||
| jToolBar1.add(selectButton); | ||
| jToolBar1.add(jSeparator2); | ||
|
|
||
| jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Black", "Red", "Yellow", "Blue", "Green", "Magenta" })); | ||
| jToolBar1.add(jComboBox1); | ||
|
|
||
| javax.swing.GroupLayout ryanDoTheThingLayout = new javax.swing.GroupLayout(ryanDoTheThing); | ||
| ryanDoTheThing.setLayout(ryanDoTheThingLayout); | ||
| ryanDoTheThingLayout.setHorizontalGroup( | ||
| ryanDoTheThingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
| .addGroup(ryanDoTheThingLayout.createSequentialGroup() | ||
| .addContainerGap() | ||
| .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 650, Short.MAX_VALUE) | ||
| .addContainerGap()) | ||
| ); | ||
| ryanDoTheThingLayout.setVerticalGroup( | ||
| ryanDoTheThingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
| .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ryanDoTheThingLayout.createSequentialGroup() | ||
| .addGap(0, 405, Short.MAX_VALUE) | ||
| .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) | ||
| ); | ||
|
|
||
| jMenu1.setText("File"); | ||
|
|
||
| jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, 0)); | ||
| jMenuItem1.setText("Save"); | ||
| jMenu1.add(jMenuItem1); | ||
|
|
||
| jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, 0)); | ||
| jMenuItem2.setText("Load"); | ||
| jMenu1.add(jMenuItem2); | ||
|
|
||
| jMenuBar1.add(jMenu1); | ||
|
|
||
| jMenu2.setText("Edit"); | ||
|
|
||
| jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); | ||
| jMenuItem3.setText("Cut"); | ||
| jMenuItem3.addActionListener(new java.awt.event.ActionListener() { | ||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
| jMenuItem3ActionPerformed(evt); | ||
| } | ||
| }); | ||
| jMenu2.add(jMenuItem3); | ||
|
|
||
| jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); | ||
| jMenuItem4.setText("Copy"); | ||
| jMenu2.add(jMenuItem4); | ||
|
|
||
| jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); | ||
| jMenuItem5.setText("Paste"); | ||
| jMenu2.add(jMenuItem5); | ||
|
|
||
| jMenuBar1.add(jMenu2); | ||
|
|
||
| setJMenuBar(jMenuBar1); | ||
|
|
||
| javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | ||
| getContentPane().setLayout(layout); | ||
| layout.setHorizontalGroup( | ||
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
| .addComponent(ryanDoTheThing, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | ||
| ); | ||
| layout.setVerticalGroup( | ||
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
| .addComponent(ryanDoTheThing, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | ||
| ); | ||
|
|
||
| pack(); | ||
| }// </editor-fold>//GEN-END:initComponents | ||
|
|
||
| private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed | ||
| // TODO add your handling code here: | ||
| }//GEN-LAST:event_jMenuItem3ActionPerformed | ||
|
|
||
| /** | ||
| * @param args the command line arguments | ||
| */ | ||
| /* | ||
| public static void main(String args[]) { | ||
| java.awt.EventQueue.invokeLater(new Runnable() { | ||
| @Override | ||
| public void run() { | ||
| new SketchUI().setVisible(true); | ||
| } | ||
| }); | ||
| } | ||
| */ | ||
| // Variables declaration - do not modify//GEN-BEGIN:variables | ||
| private javax.swing.JButton circleButton; | ||
| private javax.swing.JButton ellipseButton; | ||
| private javax.swing.JButton freehandButton; | ||
| private javax.swing.JComboBox jComboBox1; | ||
| private javax.swing.JMenu jMenu1; | ||
| private javax.swing.JMenu jMenu2; | ||
| private javax.swing.JMenuBar jMenuBar1; | ||
| private javax.swing.JMenuItem jMenuItem1; | ||
| private javax.swing.JMenuItem jMenuItem2; | ||
| private javax.swing.JMenuItem jMenuItem3; | ||
| private javax.swing.JMenuItem jMenuItem4; | ||
| private javax.swing.JMenuItem jMenuItem5; | ||
| private javax.swing.JToolBar.Separator jSeparator1; | ||
| private javax.swing.JToolBar.Separator jSeparator2; | ||
| private javax.swing.JToolBar jToolBar1; | ||
| private javax.swing.JButton lineButton; | ||
| private javax.swing.JButton polyButton; | ||
| private javax.swing.JButton rectangleButton; | ||
| private javax.swing.JButton redoButton; | ||
| private javax.swing.JPanel ryanDoTheThing; | ||
| private javax.swing.JButton selectButton; | ||
| private javax.swing.JButton squareButton; | ||
| private javax.swing.JButton undoButton; | ||
| // End of variables declaration//GEN-END:variables | ||
|
|
||
| } |