コード例 #1
0
  /**
   * Create the panel for the history setting
   *
   * @return The history setting panel
   */
  private JPanel createHistoryPanel() {
    JPanel historyPanel = new JPanel();
    historyPanel.setBorder(BorderFactory.createTitledBorder(HISTORYTITLE));
    historyPanel.add(new JLabel("History limit:"));

    m_limitField = new JTextField();
    m_limitField.setColumns(INPUTFIELDCOLUMNS);
    m_limitField.setHorizontalAlignment(SwingConstants.TRAILING);
    m_limitField.setText("" + ApplicationSettings.getHistoryLimit());
    m_limitField.setActionCommand("Save");
    m_limitField.addActionListener(this);

    historyPanel.add(m_limitField);
    historyPanel.add(new JLabel("steps"));
    return historyPanel;
  }
コード例 #2
0
 /** Save the history settings with the new value. */
 private void saveHistorySettings() {
   try {
     int steps = Integer.parseInt(m_limitField.getText());
     if (steps < 0) {
       throw new NumberFormatException("Integer should be a positive number");
     }
     ApplicationSettings.setHistoryLimit(steps);
     dispose();
   } catch (NumberFormatException e1) {
     JOptionPane.showMessageDialog(
         this,
         "You inserted an invalid value in the steps history field: " + e1.getMessage(),
         "Input Error",
         JOptionPane.WARNING_MESSAGE);
   }
 }