public MenuButtonAcqMode(Color color, String toolTip) {
   back = new JButton(null, new ColoredIcon(Color.black));
   back.setPreferredSize(new Dimension(22, 22));
   setMainButton(back);
   setPopupMenu(new ColorPanel(back));
   setPopupLocation(MenuedButton.BELOW);
   setSelectedColor(color);
   setToolTipText(toolTip);
 }
  public void layoutComponents() {
    setLayout(new BorderLayout());
    add(main, BorderLayout.CENTER);

    if (popperIsVisible) {
      if (getPopperButtonLocation() == RIGHT) {
        popper.setPreferredSize(new Dimension(14, main.getHeight()));
        add(popper, BorderLayout.EAST);
      } else if (getPopperButtonLocation() == BOTTOM) {
        popper.setPreferredSize(new Dimension(main.getWidth(), 14));
        add(popper, BorderLayout.SOUTH);

        setPopperArrowDirection(DOWN);
        setPopupLocation(popper.getX(), popper.getY() + popper.getHeight() + 5);
      }
    }

    Utilities.updateView(this);
  }
Exemplo n.º 3
0
  private JPanel createButton(String num, String desc, boolean enabled) {
    JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 8, 0));
    pane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

    JButton btn = new JButton("Tutorial" + num);
    btn.setPreferredSize(new Dimension(120, 25));
    btn.addActionListener(this);
    btn.setEnabled(enabled);
    btn.setFont(new Font("Verdana", Font.BOLD, 12));

    JLabel label = new JLabel(desc);
    label.setFont(new Font("Verdana", Font.PLAIN, 11));

    pane.add(btn);
    pane.add(label);

    return pane;
  }
Exemplo n.º 4
0
    private void initButton() {
      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
          JButton numberButton = new JButton();
          numberButton.setBorder(BorderFactory.createEmptyBorder());
          numberButton.setHorizontalAlignment(SwingConstants.CENTER);
          numberButton.setActionCommand(String.valueOf(actionCommandId));

          numberButton.addMouseListener(this);

          numberButton.setBackground(palletTableColor);
          numberButton.setForeground(dateFontColor);
          numberButton.setText(String.valueOf(actionCommandId));
          numberButton.setPreferredSize(new Dimension(25, 25));
          daysButton[i][j] = numberButton;
          actionCommandId++;
        }
      }
    }
Exemplo n.º 5
0
 void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5);
   panel1.setLayout(borderLayout1);
   jPanel1.setLayout(borderLayout2);
   jScrollPane1.getViewport().setBackground(Color.white);
   jPanel2.setLayout(gridBagLayout1);
   jLabel1.setText("Profile Name : ");
   nameTextField.setMinimumSize(new Dimension(4, 18));
   nameTextField.setPreferredSize(new Dimension(63, 18));
   jLabel2.setText("Profile Type : ");
   openButton.setMaximumSize(new Dimension(73, 24));
   openButton.setMinimumSize(new Dimension(73, 24));
   openButton.setPreferredSize(new Dimension(73, 24));
   openButton.setText("Open");
   openButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           openButton_actionPerformed(e);
         }
       });
   cancelButton.setMaximumSize(new Dimension(73, 24));
   cancelButton.setMinimumSize(new Dimension(73, 24));
   cancelButton.setPreferredSize(new Dimension(73, 24));
   cancelButton.setMargin(new Insets(0, 5, 0, 5));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           cancelButton_actionPerformed(e);
         }
       });
   profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   profileList.addMouseListener(
       new java.awt.event.MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           profileList_mouseClicked(e);
         }
       });
   jPanel2.setBorder(border1);
   typeComboBox.setMaximumSize(new Dimension(32767, 18));
   typeComboBox.setMinimumSize(new Dimension(122, 18));
   typeComboBox.setPreferredSize(new Dimension(176, 18));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jScrollPane1, BorderLayout.CENTER);
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel1,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 7, 0),
           0,
           0));
   jPanel2.add(
       nameTextField,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 7, 0),
           0,
           0));
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 17, 0),
           0,
           0));
   jScrollPane1.getViewport().add(profileList, null);
   jPanel2.add(
       openButton,
       new GridBagConstraints(
           3,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 2, 10),
           0,
           0));
   jPanel2.add(
       cancelButton,
       new GridBagConstraints(
           3,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 9, 10),
           0,
           0));
   jPanel2.add(
       typeComboBox,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 17, 0),
           0,
           0));
 }
  /** Method to set up the next and previous buttons for the pixel location information */
  private void setUpNextAndPreviousButtons() {
    // create the image icons for the buttons
    Icon prevIcon =
        new ImageIcon(DigitalPicture.class.getResource("leftArrow.gif"), "previous index");
    Icon nextIcon = new ImageIcon(DigitalPicture.class.getResource("rightArrow.gif"), "next index");
    // create the arrow buttons
    colPrevButton = new JButton(prevIcon);
    colNextButton = new JButton(nextIcon);
    rowPrevButton = new JButton(prevIcon);
    rowNextButton = new JButton(nextIcon);

    // set the tool tip text
    colNextButton.setToolTipText("Click to go to the next column value");
    colPrevButton.setToolTipText("Click to go to the previous column value");
    rowNextButton.setToolTipText("Click to go to the next row value");
    rowPrevButton.setToolTipText("Click to go to the previous row value");

    // set the sizes of the buttons
    int prevWidth = prevIcon.getIconWidth() + 2;
    int nextWidth = nextIcon.getIconWidth() + 2;
    int prevHeight = prevIcon.getIconHeight() + 2;
    int nextHeight = nextIcon.getIconHeight() + 2;
    Dimension prevDimension = new Dimension(prevWidth, prevHeight);
    Dimension nextDimension = new Dimension(nextWidth, nextHeight);
    colPrevButton.setPreferredSize(prevDimension);
    rowPrevButton.setPreferredSize(prevDimension);
    colNextButton.setPreferredSize(nextDimension);
    rowNextButton.setPreferredSize(nextDimension);

    // handle previous column button press
    colPrevButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            colIndex--;
            if (colIndex < 0) colIndex = 0;
            displayPixelInformation(colIndex, rowIndex);
          }
        });

    // handle previous row button press
    rowPrevButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            rowIndex--;
            if (rowIndex < 0) rowIndex = 0;
            displayPixelInformation(colIndex, rowIndex);
          }
        });

    // handle next column button press
    colNextButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            colIndex++;
            if (colIndex >= picture.getWidth()) colIndex = picture.getWidth() - 1;
            displayPixelInformation(colIndex, rowIndex);
          }
        });

    // handle next row button press
    rowNextButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            rowIndex++;
            if (rowIndex >= picture.getHeight()) rowIndex = picture.getHeight() - 1;
            displayPixelInformation(colIndex, rowIndex);
          }
        });
  }
Exemplo n.º 7
0
  /** ** Constructor. Sets up user interface and initializations */
  public Secondtry() {
    operators = true;
    doClear = false;

    frame = new JFrame("Calculator");
    frame.setLayout(new BorderLayout(10, 10));

    display = new JTextArea();
    display.setSize(245, 100);
    display.setFont(new Font("SansSerif", Font.BOLD, 28));
    display.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

    // create the numeric buttons for calculator
    for (int i = 0; i < 10; i++) {
      jb[i] = new JButton("" + (i));
      jb[i].addActionListener(this);
      jb[i].setFont(new Font("SansSerif", Font.BOLD, 14));
    }
    // create the square root button
    root = new JButton("\u221A");
    root.addActionListener(this);
    root.setFont(new Font("SansSerif", Font.BOLD, 14));

    // create the clear button
    clear = new JButton("C");
    clear.addActionListener(this);
    clear.setFont(new Font("SansSerif", Font.BOLD, 14));

    // create the plus button
    plus = new JButton("\u002B");
    plus.addActionListener(this);
    plus.setFont(new Font("SansSerif", Font.BOLD, 14));

    // create the minus button
    minus = new JButton("\u002D");
    minus.addActionListener(this);
    minus.setFont(new Font("SansSerif", Font.BOLD, 14));

    // create the multiply button
    mult = new JButton("\u002A");
    mult.addActionListener(this);
    mult.setFont(new Font("SansSerif", Font.BOLD, 14));

    // create the division button
    div = new JButton("\u002F");
    div.addActionListener(this);
    div.setFont(new Font("SansSerif", Font.BOLD, 14));

    // create the equals button
    equals = new JButton("\u003D");
    equals.addActionListener(this);
    equals.setFont(new Font("SansSerif", Font.BOLD, 14));

    equals.setPreferredSize(new Dimension(50, 60));

    // create the point button
    point = new JButton("\u002E");
    point.addActionListener(this);
    point.setFont(new Font("SansSerif", Font.BOLD, 14));

    // button grid
    JPanel buttons = new JPanel(new GridLayout(5, 4, 4, 4));

    // add buttons to grid
    buttons.add(clear);
    buttons.add(root);
    buttons.add(div);
    buttons.add(mult);
    // add numeric buttons to grid
    for (int i = 7; i < 10; i++) buttons.add(jb[i]);
    buttons.add(minus);
    // add numeric buttons to grid
    for (int i = 4; i < 7; i++) buttons.add(jb[i]);
    buttons.add(plus);
    // add numeric buttons to grid
    for (int i = 1; i < 4; i++) buttons.add(jb[i]);
    buttons.add(equals);
    buttons.add(jb[0]);
    buttons.add(point);

    frame.add(display, BorderLayout.CENTER);
    frame.add(buttons, BorderLayout.SOUTH);

    frame.setSize(300, 400);
    frame.setVisible(true);
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Exemplo n.º 8
0
  private void jbInit() throws Exception {

    saveButton.setText("Save");
    saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this));
    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this));
    this.setTitle(this.getTitle() + " Template Editor");
    printfPanel.setLayout(gridBagLayout1);
    formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    formatLabel.setText("Format String:");
    buttonPanel.setLayout(flowLayout1);
    printfPanel.setBorder(BorderFactory.createEtchedBorder());
    printfPanel.setMinimumSize(new Dimension(100, 160));
    printfPanel.setPreferredSize(new Dimension(380, 160));
    parameterPanel.setLayout(gridBagLayout2);
    parameterLabel.setText("Parameters:");
    parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    parameterTextArea.setMinimumSize(new Dimension(100, 25));
    parameterTextArea.setPreferredSize(new Dimension(200, 25));
    parameterTextArea.setEditable(true);
    parameterTextArea.setText("");
    insertButton.setMaximumSize(new Dimension(136, 20));
    insertButton.setMinimumSize(new Dimension(136, 20));
    insertButton.setPreferredSize(new Dimension(136, 20));
    insertButton.setToolTipText(
        "insert the format in the format string and add parameter to list.");
    insertButton.setText("Insert Parameter");
    insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this));
    formatTextArea.setMinimumSize(new Dimension(100, 25));
    formatTextArea.setPreferredSize(new Dimension(200, 15));
    formatTextArea.setText("");
    parameterPanel.setBorder(null);
    parameterPanel.setMinimumSize(new Dimension(60, 40));
    parameterPanel.setPreferredSize(new Dimension(300, 40));
    insertMatchButton.addActionListener(
        new PrintfTemplateEditor_insertMatchButton_actionAdapter(this));
    insertMatchButton.setText("Insert Match");
    insertMatchButton.setToolTipText(
        "insert the match in the format string and add parameter to list.");
    insertMatchButton.setPreferredSize(new Dimension(136, 20));
    insertMatchButton.setMinimumSize(new Dimension(136, 20));
    insertMatchButton.setMaximumSize(new Dimension(136, 20));
    matchPanel.setPreferredSize(new Dimension(300, 40));
    matchPanel.setBorder(null);
    matchPanel.setMinimumSize(new Dimension(60, 60));
    matchPanel.setLayout(gridBagLayout3);
    InsertPanel.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(2);
    gridLayout1.setVgap(0);
    InsertPanel.setBorder(BorderFactory.createEtchedBorder());
    InsertPanel.setMinimumSize(new Dimension(100, 100));
    InsertPanel.setPreferredSize(new Dimension(380, 120));
    editorPane.setText("");
    editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this));
    printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this));
    parameterPanel.add(
        insertButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    parameterPanel.add(
        paramComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    paramComboBox.setRenderer(new MyCellRenderer());
    InsertPanel.add(matchPanel, null);
    InsertPanel.add(parameterPanel, null);
    buttonPanel.add(cancelButton, null);
    buttonPanel.add(saveButton, null);
    this.getContentPane().add(printfTabPane, BorderLayout.NORTH);
    this.getContentPane().add(InsertPanel, BorderLayout.CENTER);
    matchPanel.add(
        insertMatchButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    matchPanel.add(
        matchComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    printfPanel.add(
        parameterLabel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(7, 5, 0, 5),
            309,
            0));
    printfPanel.add(
        formatLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(4, 5, 0, 5),
            288,
            0));
    printfPanel.add(
        formatTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 0, 5),
            300,
            34));
    printfPanel.add(
        parameterTextArea,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 6, 5),
            300,
            34));
    printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor");
    printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf");
    editorPane.setCharacterAttributes(PLAIN_ATTR, true);
    editorPane.addStyle("PLAIN", editorPane.getLogicalStyle());
    editorPanel.getViewport().add(editorPane, null);
    this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    buttonGroup.add(cancelButton);
  }