Esempio n. 1
1
 /**
  * Set the current background color to the given color.
  *
  * <p>The color object is cloned; you can change the original afterwards. If the color object is
  * null, the current background color is turned off (same as nobackground).
  *
  * @param c the color object.
  * @return the current background color.
  */
 public Color background(Color c) {
   return canvas.setBackground(c == null ? null : c.clone());
 }
Esempio n. 2
0
  public void draw(Canvas _canvas, Rect _top_left) {
    Rect myrect;
    Rect subrect;
    // START KGU 2015-10-13: All highlighting rules now encapsulated by this new method
    // Color drawColor = getColor();
    Color drawColor = getFillColor();
    // END KGU 2015-10-13
    FontMetrics fm = _canvas.getFontMetrics(Element.font);
    Canvas canvas = _canvas;
    // START KGU 2015-10-13: Became obsolete by new method getFillColor() applied above now
    //		if (selected==true)
    //		{
    //			drawColor=Element.E_DRAWCOLOR;
    //		}
    // END KGU 2015-10-13

    rect = _top_left.copy();

    myrect = _top_left.copy();
    myrect.bottom = myrect.top;

    if (children.size() > 0) {
      // draw children
      for (int i = 0; i < children.size(); i++) {
        subrect = ((Element) children.get(i)).prepareDraw(_canvas);
        myrect.bottom += subrect.bottom;
        if (i == children.size() - 1) {
          myrect.bottom = _top_left.bottom;
        }
        ((Element) children.get(i)).draw(_canvas, myrect);

        // myrect.bottom-=1;
        myrect.top += subrect.bottom;
      }
    } else {
      // draw nothing
      rect = _top_left.copy();

      canvas.setBackground(drawColor);
      canvas.setColor(drawColor);

      myrect = _top_left.copy();

      canvas.fillRect(myrect);

      canvas.setColor(Color.BLACK);
      canvas.writeOut(
          _top_left.left
              + ((_top_left.right - _top_left.left) / 2)
              - (_canvas.stringWidth("\u2205") / 2),
          _top_left.top + ((_top_left.bottom - _top_left.top) / 2) + (fm.getHeight() / 2),
          "\u2205");

      canvas.drawRect(_top_left);
    }
  }
Esempio n. 3
0
 public void resetContext(boolean resetBackground) {
   super.resetContext();
   if (resetBackground) canvas.setBackground(new Color(1, 1, 1));
 }
Esempio n. 4
0
 public void nobackground() {
   canvas.setBackground(null);
 }
Esempio n. 5
0
 /**
  * Set the current background color to the given R/G/B/A value.
  *
  * @param x the red component.
  * @param y the green component.
  * @param z the blue component.
  * @param a the alpha component.
  * @return the current background color.
  */
 public Color background(double x, double y, double z, double a) {
   return canvas.setBackground(
       new Color(normalize(x), normalize(y), normalize(z), normalize(a), colormode()));
 }
Esempio n. 6
0
 /**
  * Set the current background color to given grayscale and alpha value.
  *
  * @param x the grayscale value.
  * @param y the alpha value.
  * @return the current background color.
  */
 public Color background(double x, double y) {
   double nx = normalize(x);
   return canvas.setBackground(new Color(nx, nx, nx, normalize(y)));
 }
Esempio n. 7
0
  public void draw(Canvas _canvas, Rect _top_left) {
    if (isCollapsed()) {
      Instruction.draw(_canvas, _top_left, getCollapsedText(), this);
      return;
    }

    Rect myrect = new Rect();
    // START KGU 2015-10-13: All highlighting rules now encapsulated by this new method
    // Color drawColor = getColor();
    Color drawColor = getFillColor();
    // END KGU 2015-10-13
    FontMetrics fm = _canvas.getFontMetrics(font);
    //		int p;
    //		int w;

    // START KGU 2015-10-13: Became obsolete by new method getFillColor() applied above now
    //		if (selected==true)
    //		{
    //			drawColor=Element.E_DRAWCOLOR;
    //		}
    // END KGU 2015-10-13

    Canvas canvas = _canvas;
    canvas.setBackground(drawColor);
    canvas.setColor(drawColor);

    // draw background
    myrect = _top_left.copy();
    canvas.fillRect(myrect);

    // draw shape
    rect = _top_left.copy();
    canvas.setColor(Color.BLACK);
    canvas.drawRect(_top_left);

    myrect = _top_left.copy();
    myrect.bottom =
        _top_left.top + fm.getHeight() * getText().count() + 2 * Math.round(Element.E_PADDING / 2);
    canvas.drawRect(myrect);

    myrect.bottom = _top_left.bottom;
    myrect.top = myrect.bottom - E_PADDING;
    canvas.drawRect(myrect);

    myrect = _top_left.copy();
    myrect.right = myrect.left + E_PADDING;
    canvas.drawRect(myrect);

    // fill shape
    canvas.setColor(drawColor);
    myrect.left = myrect.left + 1;
    myrect.top = myrect.top + 1;
    myrect.bottom = myrect.bottom;
    myrect.right = myrect.right - 1;
    canvas.fillRect(myrect);

    myrect = _top_left.copy();
    myrect.bottom =
        _top_left.top + fm.getHeight() * getText().count() + 2 * Math.round(E_PADDING / 2);
    myrect.left = myrect.left + 1;
    myrect.top = myrect.top + 1;
    myrect.bottom = myrect.bottom;
    myrect.right = myrect.right - 1;
    canvas.fillRect(myrect);

    myrect.bottom = _top_left.bottom;
    myrect.top = myrect.bottom - Element.E_PADDING;
    myrect.left = myrect.left + 1;
    myrect.top = myrect.top + 1;
    myrect.bottom = myrect.bottom;
    myrect.right = myrect.right;
    canvas.fillRect(myrect);

    // draw comment
    if (Element.E_SHOWCOMMENTS == true && !comment.getText().trim().equals("")) {
      // START KGU 2015-10-11: Use an inherited helper method now
      //			canvas.setBackground(E_COMMENTCOLOR);
      //			canvas.setColor(E_COMMENTCOLOR);
      //
      //			Rect someRect = _top_left.copy();
      //
      //			someRect.left+=2;
      //			someRect.top+=2;
      //			someRect.right=someRect.left+4;
      //			someRect.bottom-=1;
      //
      //			canvas.fillRect(someRect);
      this.drawCommentMark(canvas, _top_left);
      // END KGU 2015-10-11
    }
    // START KGU 2015-10-11
    // draw breakpoint bar if necessary
    this.drawBreakpointMark(canvas, _top_left);
    // END KGU 2015-10-11

    // draw text
    for (int i = 0; i < getText().count(); i++) {
      String text = this.getText().get(i);
      text = BString.replace(text, "<--", "<-");

      canvas.setColor(Color.BLACK);
      writeOutVariables(
          canvas,
          _top_left.left + Math.round(E_PADDING / 2),
          _top_left.top + Math.round(E_PADDING / 2) + (i + 1) * fm.getHeight(),
          text,
          this);
    }

    // draw children
    myrect = _top_left.copy();
    myrect.left = myrect.left + Element.E_PADDING - 1;
    myrect.top =
        _top_left.top + fm.getHeight() * getText().count() + 2 * Math.round(E_PADDING / 2) - 1;
    myrect.bottom = myrect.bottom - E_PADDING + 1;
    q.draw(_canvas, myrect);
  }
Esempio n. 8
0
  public void init() {

    initCanvas();
    WindowEventListener listener = new WindowEventListener();
    this.addWindowFocusListener(listener);
    this.addWindowListener(listener);
    this.addWindowStateListener(listener);

    JPanel wrapper = new JPanel();
    wrapper.setLayout(new BoxLayout(wrapper, BoxLayout.Y_AXIS));
    wrapper.add(Box.createVerticalGlue());
    JPanel top = new JPanel();
    top.setPreferredSize(new Dimension(800, 40));
    top.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS));
    ImageIcon pointerIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/pointer.png"))
                .getImage()
                .getScaledInstance(40, 40, Image.SCALE_SMOOTH));
    JButton pointerButton = new JButton(pointerIcon);
    pointerButton.setMaximumSize(new Dimension(40, 30));
    pointerButton.setBorder(null);
    pointerButton.setOpaque(false);
    // pointerButton.setContentAreaFilled(false);
    pointerButton.setBorderPainted(false);
    pointerButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            canvas.removeAllHighlights();
            canvas.removeDrags();
            canvas.repaint();
          }
        });

    JLabel stroke = new JLabel("Stroke: ");
    JButton strokeButton = new JButton("");
    strokeButton.setPreferredSize(new Dimension(30, 25));
    strokeButton.setMinimumSize(new Dimension(30, 25));
    strokeButton.setMaximumSize(new Dimension(30, 25));
    JLabel fill = new JLabel("Fill: ");
    JButton fillButton = new JButton("");
    fillButton.setPreferredSize(new Dimension(30, 25));
    fillButton.setMinimumSize(new Dimension(30, 25));
    fillButton.setMaximumSize(new Dimension(30, 25));
    JLabel zoom = new JLabel("Zoom: ");
    JSlider slider = new JSlider(0, 100, 50);
    slider.setMaximumSize(new Dimension(200, 30));
    JButton minusMagnifier = new JButton("-");
    JButton plusMagnifier = new JButton("+");
    top.add(Box.createHorizontalGlue());
    top.add(stroke);
    top.add(strokeButton);
    top.add(Box.createRigidArea(new Dimension(50, 40)));
    top.add(fill);
    top.add(fillButton);
    top.add(Box.createRigidArea(new Dimension(100, 40)));
    top.add(zoom);
    top.add(slider);
    top.add(minusMagnifier);
    top.add(plusMagnifier);
    top.add(Box.createRigidArea(new Dimension(50, 40)));
    top.add(pointerButton);
    top.add(Box.createRigidArea(new Dimension(100, 400)));
    top.add(Box.createHorizontalGlue());

    wrapper.add(top);
    JPanel middle = new JPanel();
    middle.setLayout(new BorderLayout());
    JPanel left = new JPanel();
    left.setPreferredSize(new Dimension(200, 600));
    left.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    JPanel right = new JPanel();
    right.setPreferredSize(new Dimension(600, 600));
    right.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    middle.add(left, BorderLayout.WEST);
    middle.add(right, BorderLayout.EAST);
    wrapper.add(middle);
    JPanel bottom = new JPanel();
    bottom.setPreferredSize(new Dimension(800, 25));
    bottom.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    wrapper.add(bottom);
    add(wrapper);

    JLabel f1 = new JLabel("    Press F1 for help");
    f1.setPreferredSize(new Dimension(197, 25));
    JLabel view = new JLabel("  View");
    view.setPreferredSize(new Dimension(55, 25));
    JLabel dimensions = new JLabel(CANVAS_WIDTH + " x " + CANVAS_HEIGHT);
    dimensions.setPreferredSize(new Dimension(75, 25));
    coordinates = new JLabel("Coordinates: (" + xCord + ", " + yCord + ")");
    coordinates.setPreferredSize(new Dimension(150, 25));
    bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS));
    JSeparator separator = new JSeparator(JSeparator.VERTICAL);
    JSeparator separator2 = new JSeparator(JSeparator.VERTICAL);
    JSeparator separator3 = new JSeparator(JSeparator.VERTICAL);
    bottom.add(Box.createHorizontalGlue());
    bottom.add(f1);
    bottom.add(separator);

    bottom.add(view);
    bottom.add(Box.createRigidArea(new Dimension(100, 25)));
    bottom.add(separator2);
    bottom.add(dimensions);
    bottom.add(separator3);
    bottom.add(Box.createRigidArea(new Dimension(100, 25)));
    bottom.add(coordinates);
    bottom.add(Box.createHorizontalGlue());

    right.setLayout(new BorderLayout());
    JPanel template = new JPanel();
    template.setPreferredSize(new Dimension(580, 580));
    template.setLayout(new BoxLayout(template, BoxLayout.Y_AXIS));
    template.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    right.add(template, BorderLayout.CENTER);

    JPanel titlePanel = new JPanel();
    titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.X_AXIS));
    titlePanel.setPreferredSize(new Dimension(580, 25));
    titlePanel.setBackground(new Color(13, 16, 59));
    title = new JLabel("Untitled");
    title.setForeground(new Color(242, 245, 230));
    // ImageIcon deleteIcon = new ImageIcon(new
    // ImageIcon(getClass().getResource("/resources/deleteIcon.png")).getImage().getScaledInstance(10,  10,  Image.SCALE_SMOOTH));
    ImageIcon deletehIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/deletehIcon.png"))
                .getImage()
                .getScaledInstance(10, 10, Image.SCALE_SMOOTH));
    JButton closeButton = new JButton(deletehIcon);
    closeButton.setBorder(null);
    closeButton.setBackground(new Color(13, 16, 59));
    closeButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (changesMade != 0) {
              requestClose();
            } else {
              restartCanvas();
            }
          }
        });
    // closeButton.setRolloverIcon(deletehIcon);
    titlePanel.add(Box.createHorizontalGlue());
    titlePanel.add(Box.createRigidArea(new Dimension(275, 25)));
    titlePanel.add(title);
    titlePanel.add(Box.createRigidArea(new Dimension(235, 25)));
    titlePanel.add(closeButton);
    titlePanel.add(Box.createRigidArea(new Dimension(15, 25)));
    titlePanel.add(Box.createHorizontalGlue());
    canvasCover = new JPanel();
    canvasCover.setBackground(new Color(26, 103, 150, 50));
    canvasCover.setLayout(new GridBagLayout());
    canvasCover.setPreferredSize(new Dimension(580, 580));
    canvas.setMaximumSize(new Dimension(560, 540));
    canvas.setPreferredSize(new Dimension(560, 540));
    canvas.setMinimumSize(new Dimension(560, 540));
    canvas.setBackground(Color.WHITE);
    canvas.requestFocus();
    canvasCover.add(canvas);

    template.add(Box.createVerticalGlue());
    template.add(titlePanel);
    template.add(canvasCover);
    template.add(Box.createVerticalGlue());

    // Create the Menu
    JMenuBar menubar = new JMenuBar();

    // Menu Names
    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    JMenu edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);

    // Menu Items and Listeners

    ImageIcon closeIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/closeIcon.png"))
                .getImage()
                .getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    ImageIcon exitIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/exitIcon.png"))
                .getImage()
                .getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    ImageIcon newIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/newIcon.png"))
                .getImage()
                .getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    ImageIcon saveIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/saveIcon.png"))
                .getImage()
                .getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    ImageIcon openIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/openIcon.png"))
                .getImage()
                .getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    ImageIcon printIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/printIcon.png"))
                .getImage()
                .getScaledInstance(20, 20, Image.SCALE_SMOOTH));

    JMenuItem closeMenuItem = new JMenuItem("Close", closeIcon);
    closeMenuItem.setMnemonic(KeyEvent.VK_W);
    closeMenuItem.setToolTipText("Close current window");
    closeMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
    closeMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (changesMade != 0) {
              requestClose();
            } else {
              restartCanvas();
            }
          }
        });

    JMenuItem exitMenuItem = new JMenuItem("Exit", exitIcon);
    exitMenuItem.setToolTipText("Exit Application");
    exitMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });

    JMenuItem newMenuItem = new JMenuItem("New", newIcon);
    newMenuItem.setMnemonic(KeyEvent.VK_N);
    newMenuItem.setToolTipText("Start a new file");
    newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
    newMenuItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {
            restartCanvas();
            title.setText("Untitled");
          }
        });

    JMenuItem openMenuItem = new JMenuItem("Open File...", openIcon);
    openMenuItem.setMnemonic(KeyEvent.VK_O);
    openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    openMenuItem.setToolTipText("New");
    openMenuItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {
            open();
          }
        });

    JMenuItem saveAsMenuItem = new JMenuItem("Save As...", saveIcon);
    saveAsMenuItem.setMnemonic(KeyEvent.VK_S);
    saveAsMenuItem.setToolTipText("Save As");
    saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    saveAsMenuItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {
            save();
          }
        });

    JMenuItem printMenuItem = new JMenuItem("Print", printIcon);
    printMenuItem.setMnemonic(KeyEvent.VK_P);
    printMenuItem.setToolTipText("Print Current Window");
    printMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
    printMenuItem.addActionListener(new PrintJob());

    JMenuItem aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.setMnemonic(KeyEvent.VK_A);
    aboutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    aboutMenuItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {}
        });

    JMenuItem helpMenuItem = new JMenuItem("Help");
    helpMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

    // Add Items to Menus
    file.add(newMenuItem);
    file.add(openMenuItem);
    file.addSeparator();
    file.add(closeMenuItem);
    file.addSeparator();
    file.add(saveAsMenuItem);
    file.addSeparator();
    file.add(printMenuItem);
    file.addSeparator();
    file.add(exitMenuItem);
    help.add(aboutMenuItem);
    help.add(helpMenuItem);

    // Add Menus
    menubar.add(file);
    menubar.add(edit);
    menubar.add(help);

    // Add Menu Bar
    setJMenuBar(menubar);

    // Side Panel
    JPanel shapePanel = new JPanel();
    shapePanel.setLayout(new BorderLayout());
    JLabel shapesLabel = new JLabel("Shapes", JLabel.CENTER);
    shapesLabel.setFont(new Font("Georgia", Font.BOLD, 14));
    shapesLabel.setBorder(new EmptyBorder(new Insets(10, 0, 10, 20)));

    JPanel shapeArea = new JPanel();
    shapeArea.setLayout(new GridLayout(2, 2, 2, 0));

    // Create the shape buttons and their icons

    squareIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/square.png"))
                .getImage()
                .getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH));
    triangleIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/triangle.png"))
                .getImage()
                .getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH));
    rectangleIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/rectangle.png"))
                .getImage()
                .getScaledInstance(45, 30, java.awt.Image.SCALE_SMOOTH));
    hexagonIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/hexagon.png"))
                .getImage()
                .getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH));
    squarehIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/squareh.png"))
                .getImage()
                .getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH));
    trianglehIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/triangleh.png"))
                .getImage()
                .getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH));
    rectanglehIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/rectangleh.png"))
                .getImage()
                .getScaledInstance(45, 30, java.awt.Image.SCALE_SMOOTH));
    hexagonhIcon =
        new ImageIcon(
            new ImageIcon(getClass().getResource("/resources/hexagonh.png"))
                .getImage()
                .getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH));

    squareButton = new JButton(squarehIcon);
    squareButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    squareButton.setContentAreaFilled(false);
    squareButton.setPressedIcon(squarehIcon);
    squareButton.setSelectedIcon(squarehIcon);
    squareButton.setRolloverIcon(squarehIcon);
    squareButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            clearButtons();
            shapePressed = SQUARE;
            squareButton.setIcon(squarehIcon);
          }
        });

    triangleButton = new JButton(triangleIcon);
    triangleButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    triangleButton.setContentAreaFilled(false);
    triangleButton.setPressedIcon(trianglehIcon);
    triangleButton.setSelectedIcon(trianglehIcon);
    triangleButton.setRolloverIcon(trianglehIcon);
    triangleButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            clearButtons();
            shapePressed = TRIANGLE;
            triangleButton.setIcon(trianglehIcon);
          }
        });

    rectangleButton = new JButton(rectangleIcon);
    rectangleButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    rectangleButton.setContentAreaFilled(false);
    rectangleButton.setPressedIcon(rectanglehIcon);
    rectangleButton.setSelectedIcon(rectanglehIcon);
    rectangleButton.setRolloverIcon(rectanglehIcon);
    rectangleButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            clearButtons();
            shapePressed = RECTANGLE;
            rectangleButton.setIcon(rectanglehIcon);
          }
        });

    hexagonButton = new JButton(hexagonIcon);
    hexagonButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    hexagonButton.setContentAreaFilled(false);
    hexagonButton.setPressedIcon(hexagonhIcon);
    hexagonButton.setSelectedIcon(hexagonhIcon);
    hexagonButton.setRolloverIcon(hexagonhIcon);
    hexagonButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            clearButtons();
            shapePressed = HEXAGON;
            hexagonButton.setIcon(hexagonhIcon);
          }
        });

    shapeArea.add(squareButton);
    shapeArea.add(triangleButton);
    shapeArea.add(rectangleButton);
    shapeArea.add(hexagonButton);

    shapePanel.add(shapesLabel, BorderLayout.NORTH);
    shapePanel.add(shapeArea);
    shapePanel.setBorder(BorderFactory.createBevelBorder(NORMAL, Color.BLACK, Color.BLACK));

    left.setLayout(new GridBagLayout());
    // left.add(Box.createVerticalGlue());
    left.add(shapePanel);
    // left.add(Box.createVerticalGlue());

    setResizable(false);
    // setSize(new Dimension(816, 726));
    // setMinimumSize(new Dimension(816, 726));
    // setMaximumSize(new Dimension(816, 726));
    // setPreferredSize(new Dimension(816, 726));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("Fold");
    pack();
    setLocationRelativeTo(null); // pack all the components in the JFrame
    setVisible(true); // show it
    requestFocus();
  }