Ejemplo n.º 1
0
  public DialogButtonsPanel getButtonsPanel() {
    helpButton = new JButton("Help");
    helpButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            helpActionPerformed();
          }
        });

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            cancelActionPerformed();
          }
        });

    finishButton = new JButton("Ok");
    finishButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            finishActionPerformed();
          }
        });

    finishButton.setDefaultCapable(true);

    return new DialogButtonsPanel(Arrays.asList(cancelButton, finishButton, helpButton));
  }
Ejemplo n.º 2
0
  private void initComponents() {
    // Message - JLabel
    lblMessage =
        new JLabel(
            String.format(
                "An unexpected error has occurred: %s",
                e == null ? "Unexpected exception" : e.getMessage()));
    lblMessage.setIcon(icon);
    lblMessage.setPreferredSize(new Dimension(360, 40));
    lblMessage.setBorder(BorderFactory.createLineBorder(Color.red));

    // txtTrace - ExceptionTracePane
    txtTrace = new ExceptionTracePane();
    txtTrace.setBackground(new Color(92, 0, 0));
    txtTrace.setException(e);

    // srlTrace - JScrollPane
    JPanel traceWrapper = new JPanel(new BorderLayout());
    traceWrapper.add(txtTrace, BorderLayout.CENTER);
    srlTrace = new JScrollPane(traceWrapper);
    srlTrace.setPreferredSize(new Dimension(360, 200));
    srlTrace.setVisible(false);

    // btnDetails - JButton
    btnDetails = new JButton(new DetailsButtonAction());
    btnDetails.setPreferredSize(new Dimension(100, 40));

    // btnClose - JButton
    btnClose = new JButton(new CloseButtonAction());
    btnClose.setDefaultCapable(true);
    btnClose.setPreferredSize(new Dimension(100, 40));
  }
  /*
   * The following method creates the textfield to change the text
   *     and the button to update the label.
   * postcondition: returns the panel containing the textfield and button.
   */
  public JPanel createUpdateButton() {
    JLabel textLabel = new JLabel(new String("Change text to: "));

    textField = new JTextField(new String("Big Java"), 20);
    textField.setFont(new Font(("Times"), Font.PLAIN, 12));

    update = new JButton(new String("Update"));
    update.setDefaultCapable(true);

    // This class is used to create a special ActionListener for this menu item
    class ButtonListener implements ActionListener {
      /*
       * This method is called when the update button is clicked
       */
      public void actionPerformed(ActionEvent event) {
        // Call the method to change the text on the screen.
        setSampleFont();
      } // end actionPerformed method
    }
    ActionListener listener = new ButtonListener();
    update.addActionListener(listener);

    JPanel panel = new JPanel();

    panel.add(textLabel);
    panel.add(textField);
    panel.add(update);

    return panel;
  } // end createUpdateButton method
Ejemplo n.º 4
0
  private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    // JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "4dlu, d:grow, 4dlu", // columns
            "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, "
                + // rows
                "p, 2dlu, p, 4dlu"); // btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd"));
    contentPB.add(label, cc.xywh(2, 2, 1, 1));

    mediaTypeModel = new MediaTypeModel();
    mediaTypeTable = new JTable(mediaTypeModel);
    JTableHeader tableHeader = mediaTypeTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    // adjust column witdh of checkbox
    JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class);
    TableColumn column = mediaTypeTable.getColumnModel().getColumn(0);
    column.setMaxWidth(box.getPreferredSize().width + 2);
    column.setMinWidth(box.getPreferredSize().width + 2);
    mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer());
    // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable );
    contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1));

    // button bar
    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    okBtn.setDefaultCapable(true);
    okBtn.setRequestFocusEnabled(true);

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);

    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(okBtn);

    pack();
    setLocationRelativeTo(getParent());
  }
Ejemplo n.º 5
0
 public JButton getFindNextButton() {
   if (findNextButton == null) {
     findNextButton = new JButton();
     findNextButton.setText("Find Next");
     findNextButton.setMnemonic('F');
     findNextButton.setDefaultCapable(true);
     findNextButton.addActionListener(this);
   }
   return findNextButton;
 }
Ejemplo n.º 6
0
 public JButton getReplaceButton() {
   if (replaceButton == null) {
     replaceButton = new JButton();
     replaceButton.setText("Replace");
     replaceButton.setMnemonic('R');
     replaceButton.setDefaultCapable(true);
     replaceButton.addActionListener(this);
   }
   return replaceButton;
 }
Ejemplo n.º 7
0
  private void createGUIDialog() {
    JPanel mainPanel = new JPanel(new BorderLayout());
    setContentPane(mainPanel);
    mainPanel.add(new JLabel("Select dimensions to rulerender: "), BorderLayout.PAGE_START);

    JPanel combosPanel = new JPanel(new GridLayout(2, 2, 10, 10));
    mainPanel.add(combosPanel, BorderLayout.CENTER);

    combosPanel.add(new JLabel("Dimension 1:"));
    box1 = new JComboBox(choices.toArray());
    box1.setEditable(false);
    box1.setSelectedIndex(0);
    combosPanel.add(box1);

    combosPanel.add(new JLabel("Dimension 2:"));
    box2 = new JComboBox(choices.toArray());
    box2.setEditable(false);
    box2.setSelectedIndex(Math.min(choices.size(), 1));
    combosPanel.add(box2);

    Box h = Box.createHorizontalBox();
    mainPanel.add(h, BorderLayout.PAGE_END);
    h.add(Box.createHorizontalGlue());
    JButton okButton = new JButton("OK");
    h.add(okButton);
    okButton.setDefaultCapable(true);

    h.add(Box.createHorizontalStrut(10));

    JButton cancelButton = new JButton("Cancel");
    h.add(cancelButton);

    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            returnCode = OK_BUTTON;
            dispose();
          }
        });

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            returnCode = CANCEL_BUTTON;
            dispose();
          }
        });
  }
  private JButton createHeaderPopupCornerButton(final JPopupMenu headerPopup) {
    final JButton cornerButton = new JButton(Icons.getIcon(GeneralIcons.HIDE_COLUMN));
    cornerButton.setToolTipText(Bundle.ReferencesBrowserControllerUI_ShowHideColumnsString());
    cornerButton.setDefaultCapable(false);

    if (UIUtils.isWindowsClassicLookAndFeel()) {
      cornerButton.setMargin(new Insets(0, 0, 2, 2));
    } else if (UIUtils.isWindowsXPLookAndFeel()) {
      cornerButton.setMargin(new Insets(0, 0, 0, 1));
    } else if (UIUtils.isMetalLookAndFeel()) {
      cornerButton.setMargin(new Insets(0, 0, 2, 1));
    }

    cornerButton.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(final KeyEvent evt) {
            if (evt.getKeyCode() == KeyEvent.VK_SPACE) {
              showColumnSelectionPopup(headerPopup, cornerButton);
            }
          }
        });

    cornerButton.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent mouseEvent) {
            if (headerPopup.isVisible()) {
              internalCornerButtonClick = true;
              cornerButton.getModel().setArmed(false);
            } else {
              internalCornerButtonClick = false;

              if (mouseEvent.getModifiers() == InputEvent.BUTTON3_MASK) {
                showColumnSelectionPopup(headerPopup, cornerButton);
              }
            }
          }

          public void mouseClicked(MouseEvent mouseEvent) {
            if ((mouseEvent.getModifiers() == InputEvent.BUTTON1_MASK)
                && (!internalCornerButtonClick)) {
              showColumnSelectionPopup(headerPopup, cornerButton);
            }
          }
        });

    return cornerButton;
  }
 private void init() {
   setTitle("Synchronization Results");
   // Add a OK button
   JPanel southPane = new JPanel();
   southPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 8, 8));
   JButton closeBtn = new JButton("Close");
   closeBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           dispose();
         }
       });
   closeBtn.setMnemonic('C');
   closeBtn.setDefaultCapable(true);
   getRootPane().setDefaultButton(closeBtn);
   southPane.add(closeBtn);
   getContentPane().add(southPane, BorderLayout.SOUTH);
   // Initialize actions
   initUpdateFromDBAction();
   initCommitToDBAction();
   initShowComparisonAction();
   initClearRecordAction();
   // Add a toolbar
   JToolBar toolbar = new JToolBar();
   Insets insets = new Insets(0, 0, 0, 0);
   JButton updateFromDBBtn = toolbar.add(updateFromDBAction);
   updateFromDBBtn.setText((String) updateFromDBAction.getValue(Action.NAME));
   JButton commitToDBBtn = toolbar.add(commitToDBAction);
   commitToDBBtn.setText((String) commitToDBAction.getValue(Action.NAME));
   JButton showComparisonBtn = toolbar.add(showComparisonAction);
   showComparisonBtn.setText((String) showComparisonAction.getValue(Action.NAME));
   JButton clearRecordBtn = toolbar.add(clearRecordAction);
   clearRecordBtn.setText((String) clearRecordAction.getValue(Action.NAME));
   if (!GKApplicationUtilities.isMac()) {
     updateFromDBBtn.setMargin(insets);
     commitToDBBtn.setMargin(insets);
     showComparisonBtn.setMargin(insets);
     clearRecordBtn.setMargin(insets);
   }
   getContentPane().add(toolbar, BorderLayout.NORTH);
   setSize(600, 700);
   GKApplicationUtilities.center(this);
   setModal(true);
   isLocalHasUnexpIECommitAllowed =
       SynchronizationManager.getManager().isLocalHasUnexpIECommitAllowed();
 }
Ejemplo n.º 10
0
    Buttons(PickerModel selectionModel) {
      this.selectionModel = selectionModel;

      setLayout(new java.awt.GridLayout(1, 2));

      JButton b = new JButton("Select All");
      b.setMnemonic('S');
      b.setDefaultCapable(true);
      b.setActionCommand("SELECT_ALL");
      b.addActionListener(this);
      add(b);

      b = new JButton("Clear All");
      b.setMnemonic('C');
      b.setActionCommand("CLEAR");
      b.addActionListener(this);
      add(b);
    }
Ejemplo n.º 11
0
  /**
   * Builds and returns a panel containing the bottom four buttons.
   *
   * @return the four buttons OK, Apply, Revert, and Cancel
   */
  protected JPanel closeButtonPanel() {
    JPanel buttonPanel = new JPanel();
    JButton button;

    buttonPanel.add(button = new JButton(I18N.get("GUI.ok")));
    button.addActionListener(this);
    button.setDefaultCapable(true);

    buttonPanel.add(button = new JButton(I18N.get("GUI.apply")));
    button.addActionListener(this);

    buttonPanel.add(revertButton = new JButton(I18N.get("GUI.revert")));
    revertButton.addActionListener(this);
    revertButton.setEnabled(false);

    buttonPanel.add(button = new JButton(I18N.get("GUI.cancel")));
    button.addActionListener(this);

    return buttonPanel;
  }
Ejemplo n.º 12
0
    TransferDialog(Frame owner, String title, String account, Set<String> accounts) {
      super(owner, title);

      JButton btn_ok = new JButton("Ok");
      JButton btn_cancel = new JButton("Cancel");
      ArrayList<String> accnumbers = new ArrayList<String>(accounts);
      Collections.sort(accnumbers);
      accountcombo = new JComboBox<String>(accnumbers.toArray(new String[] {}));

      // Create Layout
      JPanel p = new JPanel(new GridLayout(4, 2, 10, 10));
      p.add(new JLabel("From Account:", JLabel.RIGHT));
      p.add(new JLabel(account));
      p.add(new JLabel("To Account:", JLabel.RIGHT));
      p.add(accountcombo);
      p.add(new JLabel("Amount:", JLabel.RIGHT));
      p.add(balancefield);
      p.add(btn_ok);
      p.add(btn_cancel);

      getContentPane().add(p);
      btn_ok.setDefaultCapable(true);
      getRootPane().setDefaultButton(btn_ok);

      // Add ActionListeners
      btn_ok.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              canceled = false;
              setVisible(false);
            }
          });
      btn_cancel.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              canceled = true;
              setVisible(false);
            }
          });
      pack();
    }
Ejemplo n.º 13
0
    AddAccountDialog(Frame owner, String title) {

      super(owner, title);

      // Create Layout
      JButton btn_ok = new JButton("Ok");
      JButton btn_cancel = new JButton("Cancel");
      JPanel p = new JPanel(new GridLayout(3, 2, 10, 10));
      p.add(new JLabel("Owner:", JLabel.RIGHT));
      p.add(ownerfield);
      p.add(new JLabel("Balance:", JLabel.RIGHT));
      p.add(balancefield);
      p.add(btn_ok);
      p.add(btn_cancel);

      getContentPane().add(p);

      btn_ok.setDefaultCapable(true);
      getRootPane().setDefaultButton(btn_ok);

      // Add ActionListeners
      btn_ok.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              canceled = false;
              setVisible(false);
            }
          });
      btn_cancel.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              canceled = true;
              setVisible(false);
            }
          });
      pack();
    }
Ejemplo n.º 14
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    this.setTitle(Language.get("about.title"));
    this.setResizable(false);
    this.setSize(597, 375);
    this.getContentPane().setLayout(new BorderLayout(0, 0));

    JLabel lblIconRita = new JLabel("");
    lblIconRita.setBorder(new EmptyBorder(12, 12, 12, 12));
    lblIconRita.setIcon(
        new ImageIcon(DialogAbout.class.getResource("/images/rita_con_titulo.jpg")));
    this.getContentPane().add(lblIconRita, BorderLayout.WEST);

    JPanel panel = new JPanel();
    panel.setOpaque(false);
    panel.setMaximumSize(new Dimension(100, 32767));
    panel.setBorder(new EmptyBorder(12, 0, 8, 12));
    this.getContentPane().add(panel);
    panel.setLayout(new BorderLayout(0, 8));

    JLabel title = new JLabel(Language.get("about.heading"));
    title.setForeground(new Color(0, 51, 102));
    title.setHorizontalAlignment(SwingConstants.CENTER);
    title.setFont(title.getFont().deriveFont(Font.BOLD, 16f));
    panel.add(title, BorderLayout.NORTH);

    JEditorPane creditsArea = new JEditorPane();
    creditsArea.setEditable(false);
    creditsArea.setContentType("text/html");
    creditsArea.setBackground(SystemColor.control);
    creditsArea.setOpaque(false);
    creditsArea.setText(Language.get("about.text"));
    creditsArea.setCaretPosition(0);
    /* si es posible, abrir links en el browser del sistema operativo */
    creditsArea.addHyperlinkListener(
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent evt) {
            String urlString = evt.getURL().toExternalForm();
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
              try {
                URI uri = new URI(urlString);
                desktop.browse(uri);
              } catch (Exception e) {
              }
            }
          }
        });
    panel.add(new JScrollPane(creditsArea), BorderLayout.CENTER);

    JButton closeButton = new JButton(Language.get("cerrar"));
    closeButton.setSelected(true);
    closeButton.setHorizontalTextPosition(SwingConstants.CENTER);
    closeButton.setDefaultCapable(true);
    closeButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg) {
            DialogAbout.this.setVisible(false);
            DialogAbout.this.dispose();
          }
        });
    panel.add(closeButton, BorderLayout.SOUTH);
    PositionCalc.centerDialog(this);
    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    this.setVisible(true);
  }
Ejemplo n.º 15
0
  public static JPanel createButtonsTable(
      final JTable table, final RowEditableTableModel tableModel, boolean addMnemonics) {
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    buttonsPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.insets = new Insets(2, 4, 2, 4);

    final JButton addButton = new JButton();
    addButton.setText(
        addMnemonics ? UIBundle.message("row.add") : UIBundle.message("row.add.without.mnemonic"));
    addButton.setDefaultCapable(false);
    buttonsPanel.add(addButton, gbConstraints);

    final JButton removeButton = new JButton();
    removeButton.setText(
        addMnemonics
            ? UIBundle.message("row.remove")
            : UIBundle.message("row.remove.without.mnemonic"));
    removeButton.setDefaultCapable(false);
    buttonsPanel.add(removeButton, gbConstraints);

    final JButton upButton = new JButton();
    upButton.setText(
        addMnemonics
            ? UIBundle.message("row.move.up")
            : UIBundle.message("row.move.up.without.mnemonic"));
    upButton.setDefaultCapable(false);
    buttonsPanel.add(upButton, gbConstraints);

    final JButton downButton = new JButton();
    downButton.setText(
        addMnemonics
            ? UIBundle.message("row.move.down")
            : UIBundle.message("row.move.down.without.mnemonic"));
    downButton.setDefaultCapable(false);
    buttonsPanel.add(downButton, gbConstraints);

    gbConstraints.weighty = 1;
    buttonsPanel.add(new JPanel(), gbConstraints);

    addButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            TableUtil.stopEditing(table);
            tableModel.addRow();
            final int index = tableModel.getRowCount() - 1;
            table.editCellAt(index, 0);
            table.setRowSelectionInterval(index, index);
            table.setColumnSelectionInterval(0, 0);
            table.getParent().repaint();
            final Component editorComponent = table.getEditorComponent();
            if (editorComponent != null) {
              final Rectangle bounds = editorComponent.getBounds();
              table.scrollRectToVisible(bounds);
              editorComponent.requestFocus();
            }
          }
        });

    removeButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            TableUtil.stopEditing(table);
            int index = table.getSelectedRow();
            if (0 <= index && index < tableModel.getRowCount()) {
              tableModel.removeRow(index);
              if (index < tableModel.getRowCount()) {
                table.setRowSelectionInterval(index, index);
              } else {
                if (index > 0) {
                  table.setRowSelectionInterval(index - 1, index - 1);
                }
              }
              updateButtons(table, tableModel, addButton, removeButton, upButton, downButton);
            }

            table.getParent().repaint();
            table.requestFocus();
          }
        });

    upButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            TableUtil.stopEditing(table);
            int index = table.getSelectedRow();
            if (0 < index && index < tableModel.getRowCount()) {
              tableModel.exchangeRows(index, index - 1);
              table.setRowSelectionInterval(index - 1, index - 1);
            }
            table.requestFocus();
          }
        });

    downButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            TableUtil.stopEditing(table);
            int index = table.getSelectedRow();
            if (0 <= index && index < tableModel.getRowCount() - 1) {
              tableModel.exchangeRows(index, index + 1);
              table.setRowSelectionInterval(index + 1, index + 1);
            }
            table.requestFocus();
          }
        });

    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                updateButtons(table, tableModel, addButton, removeButton, upButton, downButton);
              }
            });
    updateButtons(table, tableModel, addButton, removeButton, upButton, downButton);

    return buttonsPanel;
  }
Ejemplo n.º 16
0
  /** Set up the button bar */
  private void setupButtonBar() {
    bottombar = new JPanel();
    bottombar.setLayout(new BoxLayout(bottombar, BoxLayout.X_AXIS));

    editEntity = new JToggleButton();
    editEntity.setIcon(Builder.getIcon("lock.png", Builder.ICONS, 22));
    editEntity.setSelectedIcon(Builder.getIcon("unlock.png", Builder.ICONS, 22));
    editEntity.setBorderPainted(false);
    editEntity.setContentAreaFilled(false);
    editEntity.setFocusable(false);

    editEntity.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!editEntity.isSelected() && hasChanged) {
              /*if(!warnLosingChanges()) {
              	editEntity.setSelected(true);
              	return;
              }
              else {
              	editEntity.setSelected(false);
              	hasChanged = false;
              }*/
              doSave();
            }
            enableEditing(editEntity.isSelected());
          }
        });

    bottombar.add(editEntity);

    editEntityText = new JLabel(I18n.getText("general.initializing").toLowerCase());
    editEntityText.setLabelFor(editEntity);
    bottombar.add(editEntityText);

    editEntitySave = new JButton(I18n.getText("general.saveChanges"));
    editEntityCancel = new JButton(I18n.getText("general.cancel"));

    // don't let an errant enter key fire these buttons!
    editEntitySave.setDefaultCapable(false);
    editEntityCancel.setDefaultCapable(false);

    editEntitySave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doSave();
          }
        });

    editEntityCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hasChanged = false;
            editEntity.setSelected(false);
            enableEditing(false);
          }
        });

    bottombar.add(Box.createHorizontalGlue());
    bottombar.add(editEntitySave);
    bottombar.add(Box.createHorizontalStrut(6));
    bottombar.add(editEntityCancel);
    bottombar.add(Box.createHorizontalStrut(6));
  }
Ejemplo n.º 17
0
    /** Creates the ui of this panel, laying out all the ui elements. */
    private void createUI() {
      I18n i18n = getI18n();

      final int labelPad = 4; // To align labels with checkboxes

      // Time controls
      JLabel timeLabel = i18n.createLabel("timeLabel");
      timeLabel.setLabelFor(timeField);

      JLabel incLabel = i18n.createLabel("incrementLabel");
      incLabel.setLabelFor(incField);

      JLabel secondsLabel = i18n.createLabel("secondsLabel");
      JLabel minutesLabel = i18n.createLabel("minutesLabel");

      timeField.setMaximumSize(timeField.getPreferredSize());
      incField.setMaximumSize(incField.getPreferredSize());

      JComponent timeContainer = new JPanel(new TableLayout(5, labelPad, 2));
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(timeLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(timeField);
      timeContainer.add(minutesLabel);
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(incLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(incField);
      timeContainer.add(secondsLabel);

      // Variant
      JLabel variantLabel = i18n.createLabel("variantLabel");
      variantLabel.setLabelFor(variantChoice);
      variantChoice.setMaximumSize(variantChoice.getPreferredSize());

      JComponent variantContainer = SwingUtils.createHorizontalBox();
      variantContainer.add(Box.createHorizontalStrut(labelPad));
      variantContainer.add(variantLabel);
      variantContainer.add(Box.createHorizontalStrut(10));
      variantContainer.add(variantChoice);
      variantContainer.add(Box.createHorizontalGlue());

      // Color
      JLabel colorLabel = i18n.createLabel("colorLabel");

      JComponent colorContainer = SwingUtils.createHorizontalBox();
      colorContainer.add(Box.createHorizontalStrut(labelPad));
      colorContainer.add(colorLabel);
      colorContainer.add(Box.createHorizontalStrut(15));
      colorContainer.add(autoColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(whiteColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(blackColor);
      colorContainer.add(Box.createHorizontalGlue());

      // Limit opponent rating
      JLabel minLabel = i18n.createLabel("minRatingLabel");
      minLabel.setLabelFor(minRatingField);
      JLabel maxLabel = i18n.createLabel("maxRatingLabel");
      maxLabel.setLabelFor(maxRatingField);
      minRatingField.setMaximumSize(minRatingField.getPreferredSize());
      maxRatingField.setMaximumSize(minRatingField.getPreferredSize());

      JComponent limitRatingBoxContainer = SwingUtils.createHorizontalBox();
      limitRatingBoxContainer.add(limitRatingBox);
      limitRatingBoxContainer.add(Box.createHorizontalGlue());

      final JComponent minMaxContainer = SwingUtils.createHorizontalBox();
      minMaxContainer.add(Box.createHorizontalStrut(40));
      minMaxContainer.add(minLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(minRatingField);
      minMaxContainer.add(Box.createHorizontalStrut(20));
      minMaxContainer.add(maxLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(maxRatingField);
      minMaxContainer.add(Box.createHorizontalGlue());

      JComponent limitRatingContainer = SwingUtils.createVerticalBox();
      limitRatingContainer.add(limitRatingBoxContainer);
      limitRatingContainer.add(Box.createVerticalStrut(3));
      limitRatingContainer.add(minMaxContainer);

      // Buttons panel
      JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      JButton issueSeekButton = i18n.createButton("issueSeekButton");
      JButton cancelButton = i18n.createButton("cancelButton");

      setDefaultButton(issueSeekButton);
      cancelButton.setDefaultCapable(false);

      buttonsPanel.add(issueSeekButton);
      buttonsPanel.add(cancelButton);

      JButton moreLessButton = i18n.createButton("moreOptionsButton");
      moreLessButton.setDefaultCapable(false);
      moreLessButton.setActionCommand("more");
      JPanel moreLessPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      moreLessPanel.add(moreLessButton);

      final JComponent advancedPanelHolder = new JPanel(new BorderLayout());

      // Layout the subcontainers in the main container
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      timeContainer.setAlignmentX(LEFT_ALIGNMENT);
      add(timeContainer);
      add(Box.createVerticalStrut(2));
      isRatedBox.setAlignmentX(LEFT_ALIGNMENT);
      add(isRatedBox);
      advancedPanelHolder.setAlignmentX(LEFT_ALIGNMENT);
      add(advancedPanelHolder);
      add(Box.createVerticalStrut(5));
      moreLessPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(moreLessPanel);

      add(Box.createVerticalStrut(10));
      buttonsPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(buttonsPanel);

      // Advanced options panel
      final JComponent advancedPanel = SwingUtils.createVerticalBox();
      advancedPanel.add(Box.createVerticalStrut(4));
      variantContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(variantContainer);
      advancedPanel.add(Box.createVerticalStrut(4));
      colorContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(colorContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      limitRatingContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(limitRatingContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      manualAcceptBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(manualAcceptBox);
      advancedPanel.add(Box.createVerticalStrut(2));
      useFormulaBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(useFormulaBox);

      AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
      limitRatingBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
            }
          });

      moreLessButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              if (evt.getActionCommand().equals("more")) {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("lessOptionsButton.text"));
                moreLessButton.setActionCommand("less");
                advancedPanelHolder.add(advancedPanel, BorderLayout.CENTER);
                SeekPanel.this.resizeContainerToFit();
              } else {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("moreOptionsButton.text"));
                moreLessButton.setActionCommand("more");
                advancedPanelHolder.remove(advancedPanel);
                SeekPanel.this.resizeContainerToFit();
              }
            }
          });

      cancelButton.addActionListener(new ClosingListener(null));
      issueSeekButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              int time, inc;

              try {
                time = Integer.parseInt(timeField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("timeError");
                return;
              }

              try {
                inc = Integer.parseInt(incField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("incError");
                return;
              }

              boolean isRated = isRatedBox.isSelected();

              WildVariant variant = (WildVariant) variantChoice.getSelectedItem();

              Player color =
                  autoColor.isSelected()
                      ? null
                      : whiteColor.isSelected() ? Player.WHITE_PLAYER : Player.BLACK_PLAYER;

              int minRating, maxRating;
              if (limitRatingBox.isSelected()) {
                try {
                  minRating = Integer.parseInt(minRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("minRatingError");
                  return;
                }
                try {
                  maxRating = Integer.parseInt(maxRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("maxRatingError");
                  return;
                }
              } else {
                minRating = Integer.MIN_VALUE;
                maxRating = Integer.MAX_VALUE;
              }

              boolean manualAccept = manualAcceptBox.isSelected();
              boolean useFormula = useFormulaBox.isSelected();

              close(
                  new UserSeek(
                      time,
                      inc,
                      isRated,
                      variant,
                      color,
                      minRating,
                      maxRating,
                      manualAccept,
                      useFormula));
            }
          });
    }
Ejemplo n.º 18
0
  private void createGUI() {
    setTitle(WINDOW_TITLE);
    setPreferredSize(new Dimension(800, 600));
    setMinimumSize(new Dimension(300, 120));

    setLayout(new BorderLayout());

    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

    final Font labelFont = UIManager.getFont("Label.font");
    final Font boldFont = labelFont.deriveFont(Font.BOLD, labelFont.getSize2D() * 1.2f);

    final JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    final JLabel nameLabel = new JLabel(object.getName());
    nameLabel.setFont(boldFont);
    topPanel.add(nameLabel);
    topPanel.add(new JLabel(object.getId()));
    add(topPanel, BorderLayout.PAGE_START);

    JScrollPane scrollPane = new JScrollPane(panel);
    add(scrollPane, BorderLayout.CENTER);

    propertyPanels = new ArrayList<PropertyEditorFrame.PropertyInputPanel>();

    int position = 0;
    for (PropertyDefinition<?> propDef : object.getType().getPropertyDefinitions().values()) {
      boolean isUpdatable =
          (propDef.getUpdatability() == Updatability.READWRITE)
              || (propDef.getUpdatability() == Updatability.WHENCHECKEDOUT
                  && object
                      .getAllowableActions()
                      .getAllowableActions()
                      .contains(Action.CAN_CHECK_IN));

      if (isUpdatable) {
        PropertyInputPanel propertyPanel =
            new PropertyInputPanel(propDef, object.getPropertyValue(propDef.getId()), position++);

        propertyPanels.add(propertyPanel);
        panel.add(propertyPanel);
      }
    }

    JButton updateButton = new JButton("Update");
    updateButton.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    updateButton.setDefaultCapable(true);
    updateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (doUpdate()) {
              dispose();
            }
          }
        });

    add(updateButton, BorderLayout.PAGE_END);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
  }
Ejemplo n.º 19
0
  /**
   * Create the main panel
   *
   * @return
   */
  private JPanel createContentPane() {
    // ... Create an independent GridLayout panel of buttons.
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(5, 1, GAP, GAP));

    findBtn = new JButton(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.find"));
    findBtn.setActionCommand("FindNext");
    findBtn.setMnemonic('f');
    findBtn.addActionListener(this);

    replaceBtn = new JButton(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.replace"));
    replaceBtn.setActionCommand("Replace");
    replaceBtn.setMnemonic('r');
    replaceBtn.addActionListener(this);

    replAllBtn = new JButton(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.replaceAll"));
    replAllBtn.setActionCommand("ReplaceAll");
    replAllBtn.setMnemonic('a');
    replAllBtn.addActionListener(this);

    closeBtn = new JButton(I18N.getString("orbisgis.org.orbisgis.ui.close"));
    closeBtn.setActionCommand("Close");
    closeBtn.setMnemonic('c');
    closeBtn.addActionListener(this);
    closeBtn.setDefaultCapable(true);

    buttonPanel.add(findBtn);
    buttonPanel.add(replaceBtn);
    buttonPanel.add(replAllBtn);
    buttonPanel.add(closeBtn);

    // ... Create an independent GridLayout panel of check boxes.
    JPanel checkBoxPanel = new JPanel();
    checkBoxPanel.setLayout(new GridLayout(3, 2));
    matchCaseCB = new JCheckBox(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.matchCase"));
    matchCaseCB.setMnemonic('m');

    wholeWrdsCB = new JCheckBox(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.wholeWords"));
    wholeWrdsCB.setMnemonic('w');

    regexCB =
        new JCheckBox(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.regularExpressions"));
    regexCB.setMnemonic('x');
    regexCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (regexCB.isSelected()) {
              wholeWrdsCB.setSelected(false);
              matchCaseCB.setSelected(false);
              wholeWrdsCB.setEnabled(false);
              matchCaseCB.setEnabled(false);
            } else {
              wholeWrdsCB.setEnabled(true);
              matchCaseCB.setEnabled(true);
            }
          }
        });

    markAllCB = new JCheckBox(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.markAll"));
    markAllCB.setMnemonic('a');
    markAllCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (!markAllCB.isSelected()) {
              rSyntaxTextArea.clearMarkAllHighlights();
            }
          }
        });

    upCB = new JCheckBox(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.searchUp"), true);
    upCB.setMnemonic('u');
    upCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (!upCB.isSelected()) {
              downCB.setSelected(true);
            } else {
              downCB.setSelected(false);
            }
          }
        });
    downCB = new JCheckBox(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.searchDown"));
    downCB.setMnemonic('d');
    downCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (!downCB.isSelected()) {
              upCB.setSelected(true);
            } else {
              upCB.setSelected(false);
            }
          }
        });

    checkBoxPanel.add(matchCaseCB);
    checkBoxPanel.add(wholeWrdsCB);
    checkBoxPanel.add(regexCB);
    checkBoxPanel.add(markAllCB);
    checkBoxPanel.add(upCB);
    checkBoxPanel.add(downCB);

    // ... Create GridBagLayout content pane; set border.
    JPanel content = new JPanel(new GridBagLayout());
    content.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER));

    // GridBagLayout code begins here
    GBHelper pos = new GBHelper(); // Create GridBag helper object.

    // ... First row
    findLbl =
        new JLabel(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.findWhat"), JLabel.LEFT);
    content.add(findLbl, pos);
    content.add(new Gap(GAP), pos.nextCol());
    findTF = new JTextField(20);
    content.add(findTF, pos.nextCol().expandW());
    content.add(new Gap(GAP), pos.nextCol());
    content.add(buttonPanel, pos.nextCol().height(5).align(GridBagConstraints.NORTH));

    content.add(new Gap(GAP), pos.nextRow()); // Add a gap below

    // ... Next row.
    replaceLbl =
        new JLabel(I18N.getString("orbisgis.org.orbisgis.ui.findReplace.replaceWith"), JLabel.LEFT);
    content.add(replaceLbl, pos.nextRow());
    content.add(new Gap(GAP), pos.nextCol());
    replaceTF = new JTextField(20);
    content.add(replaceTF, pos.nextCol().expandW());

    content.add(new Gap(2 * GAP), pos.nextRow()); // Add a big gap below

    // ... Last content row.
    content.add(checkBoxPanel, pos.nextRow().nextCol().nextCol());

    // ... Add an area that can expand at the bottom.
    content.add(new Gap(), pos.nextRow().width().expandH());
    return content;
  }
  /** Initializes all GUI components */
  private void initComponents() {

    mainPanel = new JPanel();
    editPanel = new JPanel();
    editPanelLeft = new JPanel();
    editPanelCenter = new JPanel();
    editPanelRight = new JPanel();
    tablePanel = new JPanel();

    companyIdTextField = new JTextField();
    companyIdTextField.setEditable(false);
    companyNameTextField = new JTextField();
    urlTextField = new JTextField();
    insuranceTypesTextField = new JTextField();
    telephoneTextField = new JTextField();
    percentageTextField = new JTextField();
    percentageTextField.setToolTipText("<html>Only <b>numerical</b> values allowed</html>");
    searchTextField = new JTextField();
    searchTextField.setToolTipText(
        "<html>Use either <b>AND</b> or <b>OR</b> for combined search queries<br>You can also use <b>spaces</b> instead of <b>OR</b></html>");
    generalDescriptionTextField = new JTextField();

    companyIdLabel = new InsuranceCompanyLabel("ID");
    companyNameLabel = new InsuranceCompanyLabel("Company");
    urlLabel = new InsuranceCompanyLabel("Website");
    insuranceTypesLabel = new InsuranceCompanyLabel("Insurance Types");
    telephoneLabel = new InsuranceCompanyLabel("Telephone");
    percentageLabel = new InsuranceCompanyLabel("Broker Percentage");
    searchLabel = new InsuranceCompanyLabel("Search Insurance Types");
    generalDescriptionLabel = new InsuranceCompanyLabel("General Description");
    sortLabel = new InsuranceCompanyLabel("Sorting");

    addInsuranceCompanyButton = new InsuranceCompanyButton("New Insurance Company", 190, 45);
    addInsuranceCompanyButton.setToolTipText(
        "<html>Create a new <b>empty</b> Insurance Company</html>");
    saveInsuranceCompanyButton = new InsuranceCompanyButton("Save Insurance Company", 190, 45);
    saveInsuranceCompanyButton.setToolTipText(
        "<html>Save the <b>selected</b> Insurance Company<br>Hint: Press <b>Enter</b> to quickly save an entry</html>");
    saveInsuranceCompanyButton.setDefaultCapable(true);
    getRootPane()
        .setDefaultButton(
            saveInsuranceCompanyButton); // Set the save button as default button, so quicker
                                         // editing by pressing Enter is possible
    deleteInsuranceCompanyButton = new InsuranceCompanyButton("Delete Insurance Company", 190, 45);
    deleteInsuranceCompanyButton.setToolTipText(
        "<html>Delete the <b>selected</b> Insurance Company</html>");
    clearSearchButton = new InsuranceCompanyButton("x", 40, 35);
    clearSearchButton.setToolTipText("<html>Click to <b>clear</b> the search field</html>");

    String[] sortStrategies = {"ID", "Company Name", "Percentage"};
    sortComboBox = new JComboBox(sortStrategies);

    tableData = new InsuranceCompanyTableModel(model.getInsuranceCompanies());
    insuranceCompaniesTable = new JTable();

    insuranceCompanyScrollPane = new JScrollPane(insuranceCompaniesTable);

    // Set layout and add components to panels
    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(editPanel, BorderLayout.NORTH);
    editPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    editPanel.setLayout(new BorderLayout());
    editPanel.add(editPanelLeft, BorderLayout.CENTER);
    editPanelLeft.setBorder(new EmptyBorder(0, 0, 5, 15));
    editPanelLeft.setLayout(new GridLayout(4, 4, 5, 0));
    editPanelLeft.add(companyIdLabel);
    editPanelLeft.add(companyNameLabel);
    editPanelLeft.add(urlLabel);
    editPanelLeft.add(telephoneLabel);
    editPanelLeft.add(companyIdTextField);
    editPanelLeft.add(companyNameTextField);
    editPanelLeft.add(urlTextField);
    editPanelLeft.add(telephoneTextField);
    editPanelLeft.add(percentageLabel);
    editPanelLeft.add(searchLabel);
    editPanelLeft.add(new JLabel());
    editPanelLeft.add(sortLabel);
    editPanelLeft.add(percentageTextField);
    editPanelLeft.add(searchTextField);
    Container searchBox = Box.createVerticalBox();
    searchBox.add(clearSearchButton);
    editPanelLeft.add(searchBox);
    editPanelLeft.add(sortComboBox);
    editPanel.add(editPanelRight, BorderLayout.EAST);
    Container box = Box.createVerticalBox();
    box.add(saveInsuranceCompanyButton);
    box.add(Box.createVerticalStrut(5));
    box.add(addInsuranceCompanyButton);
    box.add(Box.createVerticalStrut(5));
    box.add(deleteInsuranceCompanyButton);
    editPanelRight.add(box);
    editPanel.add(editPanelCenter, BorderLayout.SOUTH);
    editPanelCenter.setLayout(new GridLayout(4, 1));
    editPanelCenter.add(insuranceTypesLabel);
    editPanelCenter.add(insuranceTypesTextField);
    editPanelCenter.add(generalDescriptionLabel);
    editPanelCenter.add(generalDescriptionTextField);
    mainPanel.add(tablePanel, BorderLayout.CENTER);
    tablePanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10), "Insurance Companies Overview"));
    tablePanel.setLayout(new BorderLayout());
    tablePanel.add(insuranceCompanyScrollPane, BorderLayout.CENTER);

    setMinimumSize(new Dimension(800, 600));
    setPreferredSize(new Dimension(900, 600));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
  }
Ejemplo n.º 21
0
  public WelcomeDialog(Object[] options) {
    setUndecorated(true);
    setModal(true);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setBackground(Color.WHITE);
    Icon welcome = new javax.swing.ImageIcon(ProjectFrame.class.getResource("/frinika.png"));
    JLabel label = new JLabel(welcome);
    label.setHorizontalTextPosition(SwingConstants.CENTER);
    label.setVerticalTextPosition(SwingConstants.BOTTOM);
    label.setFont(label.getFont().deriveFont(Font.PLAIN));
    label.setText(AboutDialog.MAIN_TITLE);
    label.setBorder(BorderFactory.createEmptyBorder(25, 5, 5, 5));
    panel.add(label, BorderLayout.NORTH);
    panel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));

    JPanel contentpane = new JPanel();
    contentpane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
    contentpane.setLayout(new BorderLayout());
    contentpane.add(panel);
    setContentPane(contentpane);

    JPanel buttonpanel = new JPanel();
    buttonpanel.setOpaque(false);
    for (int i = 0; i < options.length; i++) {
      ix = i;
      JButton button = new JButton(options[i].toString());
      button.addActionListener(
          new ActionListener() {
            int index = ix;

            public void actionPerformed(ActionEvent e) {

              ActionListener listener = listeners.get(index);
              if (listener != null) {
                listener.actionPerformed(e);
                return;
              }

              sel = index;
              setVisible(false);
            }
          });
      if (i == 0) {
        button.setDefaultCapable(true);
        getRootPane().setDefaultButton(button);
      }

      buttonpanel.add(button);
    }
    panel.add(buttonpanel, BorderLayout.CENTER);

    JPanel copyrightpanel = new JPanel();
    copyrightpanel.setOpaque(false);

    JLabel line = new JLabel(AboutDialog.COPYRIGHT_NOTICE);
    line.setHorizontalTextPosition(SwingConstants.CENTER);
    line.setFont(line.getFont().deriveFont(10f).deriveFont(Font.PLAIN));

    copyrightpanel.add(line);

    panel.add(copyrightpanel, BorderLayout.SOUTH);

    setTitle("Welcome");

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    panel.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sel = -1;
            setVisible(false);
          }
        },
        stroke,
        JComponent.WHEN_IN_FOCUSED_WINDOW);

    pack();

    Rectangle windowSize;
    Insets windowInsets;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    GraphicsEnvironment ge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
    if (gc == null) gc = getGraphicsConfiguration();

    if (gc != null) {
      windowSize = gc.getBounds();
    } else {
      windowSize = new java.awt.Rectangle(toolkit.getScreenSize());
    }

    Dimension size = getSize();
    Point parent_loc = getLocation();
    setLocation(
        parent_loc.x + windowSize.width / 2 - (size.width / 2),
        parent_loc.y + windowSize.height / 2 - (size.height / 2));
  }
Ejemplo n.º 22
0
  protected void buildButtons(Action helpAction) {

    next = new JButton(C.i18n("wizard.next_>"));
    next.setName(NAME_NEXT);
    next.setMnemonic(C.i18n("wizard.next_mnemonic").charAt(0));

    prev = new JButton(C.i18n("wizard.<_prev"));
    prev.setName(NAME_PREV);
    prev.setMnemonic(C.i18n("wizard.prev_mnemonic").charAt(0));

    finish = new JButton(C.i18n("wizard.finish"));
    finish.setName(NAME_FINISH);
    finish.setMnemonic(C.i18n("wizard.finish_mnemonic").charAt(0));

    cancel = new JButton(C.i18n("wizard.cancel"));
    cancel.setName(NAME_CANCEL);
    cancel.setMnemonic(C.i18n("wizard.cancel_mnemonic").charAt(0));

    help = new JButton();
    if (helpAction != null) help.setAction(helpAction);
    if (helpAction == null || helpAction.getValue(Action.NAME) == null) {
      help.setText(C.i18n("wizard.help"));
      help.setMnemonic(C.i18n("wizard.help_mnemonic").charAt(0));
    }

    next.setDefaultCapable(true);
    prev.setDefaultCapable(true);

    help.setVisible(helpAction != null);

    // Use standard default-button-last order on Aqua L&F
    final boolean aqua = "Aqua".equals(UIManager.getLookAndFeel().getID());

    buttons =
        new JPanel() {
          public void doLayout() {
            Insets ins = getInsets();
            JButton b = aqua ? finish : cancel;

            Dimension n = b.getPreferredSize();
            int y = ((getHeight() - (ins.top + ins.bottom)) / 2) - (n.height / 2);
            int gap = 5;
            int x = getWidth() - (12 + ins.right + n.width);

            b.setBounds(x, y, n.width, n.height);

            b = aqua ? next : finish;
            n = b.getPreferredSize();
            x -= n.width + gap;
            b.setBounds(x, y, n.width, n.height);

            b = aqua ? prev : next;
            n = b.getPreferredSize();
            x -= n.width + gap;
            b.setBounds(x, y, n.width, n.height);

            b = aqua ? cancel : prev;
            n = b.getPreferredSize();
            x -= n.width + gap;
            b.setBounds(x, y, n.width, n.height);

            b = help;
            n = b.getPreferredSize();
            x -= n.width + (gap * 2);
            b.setBounds(x, y, n.width, n.height);
          }
        };
    buttons.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager.getColor("textText")));

    buttons.add(prev);
    buttons.add(next);
    buttons.add(finish);
    buttons.add(cancel);
    buttons.add(help);

    next.addActionListener(this);
    prev.addActionListener(this);
    finish.addActionListener(this);
    cancel.addActionListener(this);
  }