Exemplo n.º 1
0
  public ComponentHolder(ManagerInterface manager, Dimension mapDimension) {
    peer = manager;
    mapPanel = new JMapPanel(new GridLayout(1, 1, 2, 2), mapDimension, peer.getLoader());
    modifiedFilesListModel = new ModifiedListModel();
    originalFilesListModel = new OriginalFilesListModel();
    contentListModel = new ContentListModel();
    exhibitPhotosModel = new ExhibitPhotosModel();
    exhibitNameModel = new ExhibitListModel();
    groupListModel = new GroupListModel();
    groupExhibitsModel = new GroupExhibitsModel();
    exhibitAliasesModel = new ExhibitAliasesModel();
    eventsListModel = new EventsListModel();

    Calendar calendar = Calendar.getInstance();
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -100);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 200);
    Date latestDate = calendar.getTime();
    SpinnerModel dateModel1 =
        new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.DATE);
    SpinnerModel dateModel2 =
        new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.DATE);
    eventStart = new JSpinner(dateModel1);
    eventEnd = new JSpinner(dateModel2);
    eventStart.setEditor(new JSpinner.DateEditor(eventStart, "MM/dd/yyyy"));
    eventEnd.setEditor(new JSpinner.DateEditor(eventEnd, "MM/dd/yyyy"));
  }
Exemplo n.º 2
0
    /*
     * @param parent the interval item's parent component
     */
    private IntervalItemPanel(final IntervalPanel parent, final DataType type) {
      super(new GridLayout(1, 0));
      m_parent = parent;

      m_bin = new JSpinner(createNumberModel(type));
      m_bin.setPreferredSize(new Dimension(50, 25));
      JSpinner.DefaultEditor editorBin = new JSpinner.NumberEditor(m_bin, "0.0##############");
      editorBin.getTextField().setColumns(15);
      m_bin.setEditor(editorBin);
      m_bin.setPreferredSize(new Dimension(125, 25));

      m_left = new JSpinner(createNumberModel(type));
      JSpinner.DefaultEditor editorLeft = new JSpinner.NumberEditor(m_left, "0.0##############");
      editorLeft.getTextField().setColumns(15);
      m_left.setEditor(editorLeft);
      m_left.setPreferredSize(new Dimension(125, 25));

      m_right = new JSpinner(createNumberModel(type));
      JSpinner.DefaultEditor editorRight = new JSpinner.NumberEditor(m_right, "0.0##############");
      editorRight.getTextField().setColumns(15);
      m_right.setEditor(editorRight);
      m_right.setPreferredSize(new Dimension(125, 25));

      m_borderLeft.setPreferredSize(new Dimension(50, 25));
      m_borderLeft.setLightWeightPopupEnabled(false);
      m_borderLeft.addItem(RIGHT);
      m_borderLeft.addItem(LEFT);

      m_borderRight.setPreferredSize(new Dimension(50, 25));
      m_borderRight.setLightWeightPopupEnabled(false);
      m_borderRight.addItem(LEFT);
      m_borderRight.addItem(RIGHT);
    }
  public SpinnerModelEditorDemo() {
    // Group labels
    JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayout(4, 1));
    panel1.add(new JLabel("Date"));
    panel1.add(new JLabel("Day"));
    panel1.add(new JLabel("Month"));
    panel1.add(new JLabel("Year"));

    // Group spinners
    JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayout(4, 1));
    panel2.add(jspDate);
    panel2.add(jspDay);
    panel2.add(jspMonth);
    panel2.add(spinnerYear);

    // Add spinner and label to the UI
    add(panel1, BorderLayout.WEST);
    add(panel2, BorderLayout.CENTER);

    // Set editor for date
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(jspDate, "MMM dd, yyyy");
    jspDate.setEditor(dateEditor);

    // Set editor for year
    JSpinner.NumberEditor yearEditor = new JSpinner.NumberEditor(spinnerYear, "####");
    spinnerYear.setEditor(yearEditor);

    // Update date to synchronize with the day, month, and year
    updateDate();

    // Register and create a listener for jspDay
    jspDay.addChangeListener(
        new ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent e) {
            updateDate();
          }
        });

    // Register and create a listener for jspMonth
    jspMonth.addChangeListener(
        new ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent e) {
            updateDate();
          }
        });

    // Register and create a listener for spinnerYear
    spinnerYear.addChangeListener(
        new ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent e) {
            updateDate();
          }
        });
  }
Exemplo n.º 4
0
  private JPanel getYearAndMonthPanal() {
    Calendar c = getDateCalendar();
    int currentYear = c.get(Calendar.YEAR);
    int currentMonth = c.get(Calendar.MONTH) + 1;
    int currentHour = c.get(Calendar.HOUR_OF_DAY);
    int currentMinute = c.get(Calendar.MINUTE);
    int currentSecond = c.get(Calendar.SECOND);

    JPanel result = new JPanel();
    result.setLayout(new FlowLayout());
    result.setBackground(controlLineColor);

    yearSpin = new JSpinner(new SpinnerNumberModel(currentYear, startYear, lastYear, 1));
    yearSpin.setPreferredSize(new Dimension(48, 20));
    yearSpin.setName("Year");
    yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
    yearSpin.addChangeListener(this);
    result.add(yearSpin);
    JLabel yearLabel = new JLabel("年");
    yearLabel.setForeground(controlTextColor);
    result.add(yearLabel);

    monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1, 12, 1));
    monthSpin.setPreferredSize(new Dimension(35, 20));
    monthSpin.setName("Month");
    monthSpin.addChangeListener(this);
    result.add(monthSpin);
    JLabel monthLabel = new JLabel("月");
    monthLabel.setForeground(controlTextColor);
    result.add(monthLabel);

    hourSpin = new JSpinner(new SpinnerNumberModel(currentHour, 0, 23, 1));
    hourSpin.setPreferredSize(new Dimension(35, 20));
    hourSpin.setName("Hour");
    hourSpin.addChangeListener(this);
    result.add(hourSpin);
    JLabel hourLabel = new JLabel("时");
    hourLabel.setForeground(controlTextColor);
    result.add(hourLabel);

    minuteSpin = new JSpinner(new SpinnerNumberModel(currentMinute, 0, 59, 1));
    minuteSpin.setPreferredSize(new Dimension(35, 20));
    minuteSpin.setName("Minute");
    minuteSpin.addChangeListener(this);
    result.add(minuteSpin);
    JLabel minuteLabel = new JLabel("分");
    hourLabel.setForeground(controlTextColor);
    result.add(minuteLabel);

    secondSpin = new JSpinner(new SpinnerNumberModel(currentSecond, 0, 59, 1));
    secondSpin.setPreferredSize(new Dimension(35, 20));
    secondSpin.setName("Second");
    secondSpin.addChangeListener(this);
    result.add(secondSpin);
    JLabel secondLabel = new JLabel("秒");
    secondLabel.setForeground(controlTextColor);
    result.add(secondLabel);

    return result;
  }
Exemplo n.º 5
0
  private MainPanel() {
    super(new BorderLayout());
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < 100; i++) {
      String s = i + LF;
      buf.append(s);
    }

    final JScrollPane scrollPane = new JScrollPane(new JTextArea(buf.toString()));
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    JSpinner spinner =
        new JSpinner(
            new SpinnerNumberModel(
                scrollPane.getVerticalScrollBar().getUnitIncrement(1), 1, 100000, 1));
    spinner.setEditor(new JSpinner.NumberEditor(spinner, "#####0"));
    spinner.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            JSpinner s = (JSpinner) e.getSource();
            scrollPane.getVerticalScrollBar().setUnitIncrement((Integer) s.getValue());
          }
        });
    Box box = Box.createHorizontalBox();
    box.add(new JLabel("Unit Increment:"));
    box.add(Box.createHorizontalStrut(2));
    box.add(spinner);
    box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(box, BorderLayout.NORTH);
    add(scrollPane);
    setPreferredSize(new Dimension(320, 240));
  }
 public void setFormats(Format inputFormat, Format outputFormat) {
   this.inputFormat = inputFormat;
   this.outputFormat = outputFormat;
   // System.out.println("Spinner model: " + spinner.getModel());
   spinner.setModel(spinner.getModel());
   // System.out.println("**** Setting spinner editor");
   if (inputFormat instanceof DecimalFormat) {
     spinner.setEditor(
         new JSpinner.NumberEditor(spinner, ((DecimalFormat) inputFormat).toPattern()));
   } else if (outputFormat instanceof SimpleDateFormat) {
     spinner.setEditor(
         new JSpinner.DateEditor(spinner, ((SimpleDateFormat) inputFormat).toPattern()));
   }
   initSpinner();
   initComboBox();
 }
Exemplo n.º 7
0
	/**
	 * Returns the maximum frequency spinner.
	 * If the spinner doesn't exist it is created:
	 * <ul>
	 * <li>with the specified {@link #getMaxFrequencyModel() model},</li>
	 * <li>to have specified size (80x25 pixel),</li>
	 * <li>with the listener which updates the value of the {@link
	 * #getMinFrequencySpinner() minimum frequency spinner} to be at least
	 * {@code 0.01} smaller then the value of this spinner.</li></ul>
	 * @return the maximum frequency spinner
	 */
	public JSpinner getMaxFrequencySpinner() {
		if (maxFrequencySpinner == null) {
			maxFrequencySpinner = new JSpinner(getMaxFrequencyModel());

			Dimension spinnerSize = new Dimension(80,25);
			maxFrequencySpinner.setPreferredSize(spinnerSize);
			maxFrequencySpinner.setMinimumSize(spinnerSize);
			maxFrequencySpinner.setMaximumSize(spinnerSize);

			maxFrequencySpinner.addChangeListener(new ChangeListener() {

				@Override
				public void stateChanged(ChangeEvent e) {

					double value = ((Number) maxFrequencySpinner.getValue()).doubleValue();

					double otherValue = ((Number) getMinFrequencySpinner().getValue()).doubleValue();

					if ((value-0.01) < otherValue) {
						getMinFrequencySpinner().setValue(value - 0.01);
					}

				}

			});

			maxFrequencySpinner.setEditor(new JSpinner.NumberEditor(maxFrequencySpinner, "0.00"));
			maxFrequencySpinner.setFont(maxFrequencySpinner.getFont().deriveFont(Font.PLAIN));

		}
		return maxFrequencySpinner;
	}
Exemplo n.º 8
0
 public SpinSlider() {
   this.setLayout(new FlowLayout());
   final JSpinner spinner = new JSpinner();
   final JSlider slider = new JSlider();
   slider.addChangeListener(
       new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
           JSlider s = (JSlider) e.getSource();
           spinner.setValue(s.getValue());
         }
       });
   this.add(slider);
   spinner.setModel(new SpinnerNumberModel(50, 0, 100, 1));
   spinner.setEditor(new JSpinner.NumberEditor(spinner, "0'%'"));
   spinner.addChangeListener(
       new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
           JSpinner s = (JSpinner) e.getSource();
           slider.setValue((Integer) s.getValue());
         }
       });
   this.add(spinner);
 }
  public ObstetCalculatorWindow() {
    Calendar dtNow = Calendar.getInstance();
    // Date dtNow = new Date();

    dtDay = dtNow.get(Calendar.DAY_OF_MONTH);
    dtMonth = dtNow.get(Calendar.MONTH);
    dtYear = dtNow.get(Calendar.YEAR);

    initComponents();

    spinDays.setModel(new SpinnerNumberModel(dtDay, 1, maxDay(), 1));
    spinMonth.setModel(new SpinnerNumberModel(dtMonth + 1, 1, 12, 1));
    spinYear.setModel(new SpinnerNumberModel(dtYear, dtYear - 1, dtYear + 1, 1));
    spinYear.setEditor(new javax.swing.JSpinner.NumberEditor(spinYear, "####"));

    SetListeners();

    txtWeek.addKeyListener(keyListW);
    txtDays.addKeyListener(keyListD);

    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // setMaximizedBounds(new java.awt.Rectangle(0, 0, 0, 0));
    setResizable(false);
    this.setTitle("Obstet Tools");
  }
    protected JPanel createForm() {
      JPanel panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
      // Time
      JPanel pT = new JPanel(new FlowLayout());
      pT.setBorder(BorderFactory.createTitledBorder("Start Time"));
      hh = new JSpinner(new SpinnerNumberModel(Util.getHours(myrow.getTime()), 0, 99, 1));
      hh.setEditor(new JSpinner.NumberEditor(hh, "00"));
      pT.add(hh);
      pT.add(new JLabel("h "));
      mm = new JSpinner(new SpinnerNumberModel(Util.getMinutes(myrow.getTime()), 0, 59, 1));
      mm.setEditor(new JSpinner.NumberEditor(mm, "00"));
      pT.add(mm);
      pT.add(new JLabel("m "));
      ss = new JSpinner(new SpinnerNumberModel(Util.getSeconds(myrow.getTime()), 0, 59, 1));
      ss.setEditor(new JSpinner.NumberEditor(ss, "00"));
      pT.add(ss);
      pT.add(new JLabel("s"));
      panel.add(pT);
      // Green
      JPanel pG = new JPanel(new BorderLayout());
      pG.setBorder(BorderFactory.createTitledBorder("Green (sec.)"));
      green = new JSpinner(new SpinnerNumberModel(myrow.getGreen() * conversion, 0.0, 99999.99, 1));
      green.setEditor(new JSpinner.NumberEditor(green, "####0.##"));
      pG.add(green);
      panel.add(pG);
      // Red
      JPanel pR = new JPanel(new BorderLayout());
      pR.setBorder(BorderFactory.createTitledBorder("Red (sec.)"));
      red = new JSpinner(new SpinnerNumberModel(myrow.getRed() * conversion, 0.0, 99999.99, 1));
      red.setEditor(new JSpinner.NumberEditor(red, "####0.##"));
      pR.add(red);
      panel.add(pR);

      JPanel bp = new JPanel(new FlowLayout());
      JButton bOK = new JButton("    OK    ");
      bOK.setActionCommand(cmdOK);
      bOK.addActionListener(new ButtonEventsListener());
      JButton bCancel = new JButton("Cancel");
      bCancel.setActionCommand(cmdCancel);
      bCancel.addActionListener(new ButtonEventsListener());
      bp.add(bOK);
      bp.add(bCancel);
      panel.add(bp);
      return panel;
    }
Exemplo n.º 11
0
 /**
  * Initializes event editing panel.
  *
  * @param ne Network Element.
  * @param em Event Manager.
  * @param evt Event.
  */
 protected void initialize(AbstractNetworkElement ne, EventManager em) {
   myNE = ne;
   myEventManager = em;
   setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
   JPanel pH = new JPanel(new FlowLayout());
   JLabel lD =
       new JLabel(
           "<html><font color=\"blue\">"
               + TypesHWC.typeString(myNE.getType())
               + " "
               + myNE.toString()
               + "</font></html>");
   pH.add(lD);
   add(pH);
   // Box dp = Box.createVerticalBox();
   JPanel pD = new JPanel(new BorderLayout());
   pD.setBorder(BorderFactory.createTitledBorder("Description"));
   desc.setText(myEvent.getDescription());
   pD.add(new JScrollPane(desc), BorderLayout.CENTER);
   // dp.add(pD);
   add(pD);
   fillPanel();
   // Box fp = Box.createVerticalBox();
   JPanel pT = new JPanel(new FlowLayout());
   pT.setBorder(BorderFactory.createTitledBorder("Activation Time"));
   hh = new JSpinner(new SpinnerNumberModel(Util.getHours(myEvent.getTime()), 0, 99, 1));
   hh.setEditor(new JSpinner.NumberEditor(hh, "00"));
   pT.add(hh);
   pT.add(new JLabel("h "));
   mm = new JSpinner(new SpinnerNumberModel(Util.getMinutes(myEvent.getTime()), 0, 59, 1));
   mm.setEditor(new JSpinner.NumberEditor(mm, "00"));
   pT.add(mm);
   pT.add(new JLabel("m "));
   ss = new JSpinner(new SpinnerNumberModel(Util.getSeconds(myEvent.getTime()), 0, 59.99, 1));
   ss.setEditor(new JSpinner.NumberEditor(ss, "00.##"));
   pT.add(ss);
   pT.add(new JLabel("s"));
   // fp.add(pT);
   add(pT);
   winEE = new WindowEventEditor(this, null);
   winEE.setVisible(true);
   return;
 }
Exemplo n.º 12
0
 private void initCommon() {
   dt_initdebate_timeofhansard.setModel(
       new SpinnerDateModel(new Date(), null, null, Calendar.HOUR));
   dt_initdebate_timeofhansard.setEditor(
       new JSpinner.DateEditor(
           dt_initdebate_timeofhansard,
           BungeniEditorProperties.getEditorProperty("metadataTimeFormat")));
   ((JSpinner.DefaultEditor) dt_initdebate_timeofhansard.getEditor())
       .getTextField()
       .setEditable(false);
 }
Exemplo n.º 13
0
 public IntegerSpinner(int initialValue) {
   numberModel = new SpinnerNumberModel(initialValue, null, null, 1);
   spinner = new JSpinner(numberModel);
   DecimalFormat decimalFormat = new DecimalFormat();
   decimalFormat.setGroupingSize(0);
   JSpinner.NumberEditor numberEditor =
       new JSpinner.NumberEditor(spinner, decimalFormat.toPattern());
   initDigitsOnlyDocument(numberEditor.getTextField());
   spinner.setEditor(numberEditor);
   numberEditor.getTextField().setValue(initialValue);
 }
Exemplo n.º 14
0
  public ListPanel() {
    list.setTitle("Title");

    textField.setFont(new Font(MONOSPACED, PLAIN, 11));

    list.setTransferablePolicy(new FileListTransferablePolicy(list));
    list.setExportHandler(new FileBotListExportHandler(list));

    list.getRemoveAction().setEnabled(true);

    JSpinner fromSpinner = new JSpinner(fromSpinnerModel);
    JSpinner toSpinner = new JSpinner(toSpinnerModel);

    fromSpinner.setEditor(new NumberEditor(fromSpinner, "#"));
    toSpinner.setEditor(new NumberEditor(toSpinner, "#"));

    setLayout(
        new MigLayout("nogrid, fill, insets dialog", "align center", "[pref!, center][fill]"));

    add(new JLabel("Pattern:"), "gapbefore indent");
    add(textField, "gap related, wmin 2cm, sizegroupy editor");
    add(new JLabel("From:"), "gap 5mm");
    add(fromSpinner, "gap related, wmax 14mm, sizegroup spinner, sizegroupy editor");
    add(new JLabel("To:"), "gap 5mm");
    add(toSpinner, "gap related, wmax 14mm, sizegroup spinner, sizegroupy editor");
    add(new JButton(createAction), "gap 7mm, gapafter indent, wrap paragraph");

    add(list, "grow");

    // panel with buttons that will be added inside the list component
    JPanel buttonPanel = new JPanel(new MigLayout("insets 1.2mm, nogrid, fill", "align center"));
    buttonPanel.add(new JButton(new LoadAction(list.getTransferablePolicy())));
    buttonPanel.add(new JButton(new SaveAction(list.getExportHandler())), "gap related");

    list.add(buttonPanel, BorderLayout.SOUTH);

    TunedUtilities.installAction(this, KeyStroke.getKeyStroke("ENTER"), createAction);
  }
Exemplo n.º 15
0
  public NewGameDialog(GUI parent) {
    this.parent = parent;
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setTitle("New game");
    this.setSize(250, 150);
    this.setResizable(false);
    this.setLocationRelativeTo(null);
    JPanel contentPane = new JPanel();
    this.add(contentPane);
    contentPane.setLayout(new FlowLayout()); // BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    SpinnerNumberModel model = new SpinnerNumberModel(1, 1, 3, 1);
    JLabel numAIlabel = new JLabel("Number of opponents:");
    numAIlabel.setMaximumSize(numAIlabel.getPreferredSize());
    contentPane.add(numAIlabel);

    numAI = new JSpinner(model); /*{
            @Override
            public Dimension getMaximumSize() {
                Dimension dim = super.getMaximumSize();
                dim.height = getPreferredSize().height;
                return dim;
            }
        };*/
    numAI.setEditor(new JSpinner.DefaultEditor(numAI));
    numAI.setPreferredSize(new Dimension(100, 30));

    // numAI.setMaximumSize(numAI.getPreferredSize());

    contentPane.add(numAI);
    chooseDifficulty = new ButtonGroup();
    JRadioButton easy = new JRadioButton("Easy");
    JRadioButton intermediate = new JRadioButton("Intermediate");
    JRadioButton hard = new JRadioButton("Hard");
    easy.setActionCommand("EASY");
    intermediate.setActionCommand("INTERMEDIATE");
    hard.setActionCommand("HARD");
    chooseDifficulty.add(easy);
    chooseDifficulty.add(intermediate);
    chooseDifficulty.add(hard);
    contentPane.add(easy);
    contentPane.add(intermediate);
    contentPane.add(hard);
    easy.doClick();
    JButton confirm = new JButton("Confirm");
    contentPane.add(confirm);
    confirm.addActionListener(this);

    this.setVisible(true);
  }
Exemplo n.º 16
0
  /** @param model */
  public DoubleWidget(PropertyModel model, AbstractController controller) {
    super(model, controller);

    double min, max, inc;
    if (model.hasValueForParameter(MIN_VALUE_PARAM)) {
      min = model.getDoubleValueForParameter(MIN_VALUE_PARAM);
    } else {
      min = DEFAULT_MIN_VALUE;
    }
    if (model.hasValueForParameter(MAX_VALUE_PARAM)) {
      max = model.getDoubleValueForParameter(MAX_VALUE_PARAM);
    } else {
      max = DEFAULT_MAX_VALUE;
    }
    if (model.hasValueForParameter(INCREMENT_VALUE_PARAM)) {
      inc = model.getDoubleValueForParameter(INCREMENT_VALUE_PARAM);
    } else {
      inc = DEFAULT_INC_VALUE;
    }

    SpinnerNumberModel valueModel = new SpinnerNumberModel(min, min, max, inc);
    valueChooser = new JSpinner(valueModel);
    valueChooser.setEditor(new JSpinner.NumberEditor(valueChooser /*, "#.##"*/));
    valueChooser.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (e.getSource() == valueChooser) {
              updateModelFromWidget();
            }
          }
        });
    valueChooser.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    JComponent editor = valueChooser.getEditor();
    if (editor instanceof DefaultEditor) {
      ((DefaultEditor) editor).getTextField().setHorizontalAlignment(SwingConstants.LEFT);
      if (ToolBox.getPLATFORM() != ToolBox.MACOS) {
        ((DefaultEditor) editor)
            .getTextField()
            .setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
      }
    }
    if (model.hasValueForParameter(READONLY_TEXTFIELD)
        && model.getBooleanValueForParameter(READONLY_TEXTFIELD)) {
      valueChooser.setEnabled(false);
    }

    getDynamicComponent().addFocusListener(new WidgetFocusListener(this));
  }
Exemplo n.º 17
0
    public DateTimePropertyInputField(
        final Object value, final UpdateStatus status, final Color bgColor) {
      setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
      setBackground(bgColor);

      GregorianCalendar cal = (value == null ? new GregorianCalendar() : (GregorianCalendar) value);
      timezone = cal.getTimeZone();

      day = new SpinnerNumberModel(cal.get(Calendar.DATE), 1, 31, 1);
      addSpinner(new JSpinner(day), status);

      month = new SpinnerListModel(MONTH_STRINGS);
      month.setValue(MONTH_STRINGS[cal.get(Calendar.MONTH)]);
      JSpinner monthSpinner = new JSpinner(month);
      JComponent editor = monthSpinner.getEditor();
      if (editor instanceof JSpinner.DefaultEditor) {
        JFormattedTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
        tf.setColumns(6);
        tf.setHorizontalAlignment(JTextField.RIGHT);
      }
      addSpinner(monthSpinner, status);

      year = new SpinnerNumberModel(cal.get(Calendar.YEAR), 0, 9999, 1);
      JSpinner yearSpinner = new JSpinner(year);
      yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
      yearSpinner.getEditor().setBackground(bgColor);
      addSpinner(yearSpinner, status);

      add(new JLabel("  "));

      hour = new SpinnerNumberModel(cal.get(Calendar.HOUR_OF_DAY), 0, 23, 1);
      JSpinner hourSpinner = new JSpinner(hour);
      addSpinner(hourSpinner, status);

      add(new JLabel(":"));

      min = new SpinnerNumberModel(cal.get(Calendar.MINUTE), 0, 59, 1);
      JSpinner minSpinner = new JSpinner(min);
      addSpinner(minSpinner, status);

      add(new JLabel(":"));

      sec = new SpinnerNumberModel(cal.get(Calendar.SECOND), 0, 59, 1);
      JSpinner secSpinner = new JSpinner(sec);
      addSpinner(secSpinner, status);

      add(new JLabel(" " + timezone.getDisplayName(true, TimeZone.SHORT)));
    }
Exemplo n.º 18
0
  /**
   * Configures the given date picker and associated time spinner
   *
   * @param picker the date picker
   * @param spinner the time spinner
   */
  private void initDatePicker(JXDatePicker picker, JSpinner spinner) {
    picker.setFormats(new SimpleDateFormat("E dd/MM/yyyy"));
    picker.addPropertyChangeListener("date", this);

    DateEditor editor = new JSpinner.DateEditor(spinner, "HH:mm");
    DateFormatter formatter = (DateFormatter) editor.getTextField().getFormatter();
    formatter.setAllowsInvalid(false);
    formatter.setOverwriteMode(true);
    formatter.setCommitsOnValidEdit(true);
    spinner.setEditor(editor);
    spinner.addChangeListener(new SpinnerChangeListener());

    // Set the enabled state
    picker.setEnabled(!readOnlyRoute);
    spinner.setEnabled(!readOnlyRoute);
  }
Exemplo n.º 19
0
  private void initComponents() {

    sparklinePanel = new JPanel();

    FormLayout layout = new FormLayout("d", "d");
    sparklinePanel.setLayout(layout);

    model = new SpinnerNumberModel();

    model.setValue(DateUtils.getCurrentYear());
    model.setStepSize(1);

    yearSpinner = new JSpinner(model);

    JSpinner.NumberEditor editor = new JSpinner.NumberEditor(yearSpinner, "####");
    yearSpinner.setEditor(editor);
    yearSpinner.setEnabled(false);
  }
Exemplo n.º 20
0
    private void createYearAndMonthPanal() {
      Calendar c = getNowCalendar();
      int currentYear = c.get(Calendar.YEAR);
      int currentMonth = c.get(Calendar.MONTH) + 1;
      int currentHour = c.get(Calendar.HOUR_OF_DAY);
      yearSpin =
          new JSpinner(new javax.swing.SpinnerNumberModel(currentYear, startYear, lastYear, 1));
      monthSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentMonth, 1, 12, 1));
      hourSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentHour, 0, 23, 1));

      yearPanel.setLayout(new java.awt.FlowLayout());
      yearPanel.setBackground(controlLineColor);

      yearSpin.setPreferredSize(new Dimension(48, 20));
      yearSpin.setName("Year");
      yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
      yearSpin.addChangeListener(this);
      yearPanel.add(yearSpin);

      JLabel yearLabel = new JLabel("年");
      yearLabel.setForeground(controlTextColor);
      yearPanel.add(yearLabel);

      monthSpin.setPreferredSize(new Dimension(35, 20));
      monthSpin.setName("Month");
      monthSpin.addChangeListener(this);
      yearPanel.add(monthSpin);

      JLabel monthLabel = new JLabel("月");
      monthLabel.setForeground(controlTextColor);
      yearPanel.add(monthLabel);

      hourSpin.setPreferredSize(new Dimension(35, 20));
      hourSpin.setName("Hour");
      hourSpin.addChangeListener(this);
      yearPanel.add(hourSpin);

      JLabel hourLabel = new JLabel("日");
      hourLabel.setForeground(controlTextColor);
      yearPanel.add(hourLabel);
    }
Exemplo n.º 21
0
  /**
   * Creates a new IntegerInputComponent.
   *
   * @param param The IntegerParameter to be controlled.
   * @param parameterPanel The ParameterPanel to which this component is to be placed.
   */
  public IntegerInputComponent(IntegerParameter param, ParameterPanel parameterPanel) {
    super(parameterPanel);
    this.param = param;
    this.state = ParameterInputComponent.INPUT_IS_INITIALIZED;
    SpinnerModel model = new NullableSpinnerModel();
    model.setValue(param.getValue());
    this.spinner = new JSpinner(model);
    spinner.addFocusListener(this);
    spinner.setPreferredSize(ParameterInputComponent.PREFERRED_SIZE);

    // The second parameter of NumberEditor constructor is number format
    // The string "0" means that it is a digit without any thousand separators
    // or decimals
    spinner.setEditor(new NullableSpinnerEditor(spinner, "0"));

    spinner.addChangeListener(this);
    field = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
    field.addCaretListener(this);
    field.setBackground(BG_VALID);
    this.add(spinner, BorderLayout.CENTER);
  }
Exemplo n.º 22
0
  @Override
  protected void initFieldsEdit() {
    dt_initdebate_timeofhansard.setModel(
        new SpinnerDateModel(new Date(), null, null, Calendar.HOUR));
    dt_initdebate_timeofhansard.setEditor(
        new JSpinner.DateEditor(dt_initdebate_timeofhansard, "HH:mm"));
    ((JSpinner.DefaultEditor) dt_initdebate_timeofhansard.getEditor())
        .getTextField()
        .setEditable(false);

    if (getOoDocument().propertyExists("Bungeni_DebateOfficialTime")) {
      try {
        ooDocMetadata meta = new ooDocMetadata(getOoDocument());
        String strTime = meta.GetProperty("Bungeni_DebateOfficialTime");
        SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
        dt_initdebate_timeofhansard.setValue(timeFormat.parse(strTime));
      } catch (ParseException ex) {
        log.error("initFieldsEdit : " + ex.getMessage());
      }
    }
    return;
  }
Exemplo n.º 23
0
  /** constructor */
  public JSpinnerExampleAUT() {
    super("JSpinner Example AUT");

    final int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    SpinnerNumberModel yearModel = new SpinnerNumberModel(currentYear, 0, 3000, 1);
    JSpinner spinnerYear = new JSpinner(yearModel);
    spinnerYear.setEditor(new JSpinner.NumberEditor(spinnerYear, "#"));
    spinnerYear.setName("Year Spinner");

    String[] months =
        new String[] {
          "January",
          "February",
          "March",
          "April",
          "May",
          "June",
          "July",
          "August",
          "September",
          "October",
          "November",
          "December"
        };
    SpinnerListModel monthModel = new SpinnerListModel(months);
    JSpinner spinnerMonth = new JSpinner(monthModel);
    spinnerMonth.setName("Month Spinner");

    Component spinnerEditor = spinnerMonth.getEditor();
    JFormattedTextField jftf = ((JSpinner.DefaultEditor) spinnerEditor).getTextField();
    jftf.setColumns(7);

    super.getContentPane().setLayout(new FlowLayout());
    super.getContentPane().add(spinnerYear);
    super.getContentPane().add(spinnerMonth);
  }
Exemplo n.º 24
0
  /**
   * Set up the calendar panel with the basic layout and components. These are not date specific.
   */
  private void createCalendarComponents() {
    // The date panel will hold the calendar and/or the time spinner

    JPanel datePanel = new JPanel(new BorderLayout(2, 2));

    // Create the calendar if we are displaying a calendar

    if ((selectedComponents & DISPLAY_DATE) > 0) {
      formatMonth = new SimpleDateFormat("MMM", locale);
      formatWeekDay = new SimpleDateFormat("EEE", locale);

      // Set up the shared keyboard bindings

      setInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);
      setActionMap(actionMap);

      // Set up the decrement buttons

      yearDecrButton =
          new JButton(
              new ButtonAction(
                  "YearDecrButton",
                  "YearDecrButtonMnemonic",
                  "YearDecrButtonAccelerator",
                  "YearDecrButtonImage",
                  "YearDecrButtonShort",
                  "YearDecrButtonLong",
                  YEAR_DECR_BUTTON));
      monthDecrButton =
          new JButton(
              new ButtonAction(
                  "MonthDecrButton",
                  "MonthDecrButtonMnemonic",
                  "MonthDecrButtonAccelerator",
                  "MonthDecrButtonImage",
                  "MonthDecrButtonShort",
                  "MonthDecrButtonLong",
                  MONTH_DECR_BUTTON));
      JPanel decrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
      decrPanel.add(yearDecrButton);
      decrPanel.add(monthDecrButton);

      // Set up the month/year label

      monthYearLabel = new JLabel();
      monthYearLabel.setHorizontalAlignment(JLabel.CENTER);

      // Set up the increment buttons

      monthIncrButton =
          new JButton(
              new ButtonAction(
                  "MonthIncrButton",
                  "MonthIncrButtonMnemonic",
                  "MonthIncrButtonAccelerator",
                  "MonthIncrButtonImage",
                  "MonthIncrButtonShort",
                  "MonthIncrButtonLong",
                  MONTH_INCR_BUTTON));
      yearIncrButton =
          new JButton(
              new ButtonAction(
                  "YearIncrButton",
                  "YearIncrButtonMnemonic",
                  "YearIncrButtonAccelerator",
                  "YearIncrButtonImage",
                  "YearIncrButtonShort",
                  "YearIncrButtonLong",
                  YEAR_INCR_BUTTON));
      JPanel incrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
      incrPanel.add(monthIncrButton);
      incrPanel.add(yearIncrButton);

      // Put them all together

      JPanel monthYearNavigator = new JPanel(new BorderLayout(2, 2));
      monthYearNavigator.add(decrPanel, BorderLayout.WEST);
      monthYearNavigator.add(monthYearLabel);
      monthYearNavigator.add(incrPanel, BorderLayout.EAST);

      // Set up the day panel

      JPanel dayPanel = new JPanel(new GridLayout(7, 7));
      int firstDay = displayCalendar.getFirstDayOfWeek();

      // Get the week day labels. The following technique is used so
      // that we can start the calendar on the right day of the week and
      // we can get the week day labels properly localized

      Calendar temp = Calendar.getInstance(locale);
      temp.set(2000, Calendar.MARCH, 15);
      while (temp.get(Calendar.DAY_OF_WEEK) != firstDay) {
        temp.add(Calendar.DATE, 1);
      }
      dayOfWeekLabels = new JLabel[7];
      for (int i = 0; i < 7; i++) {
        Date date = temp.getTime();
        String dayOfWeek = formatWeekDay.format(date);
        dayOfWeekLabels[i] = new JLabel(dayOfWeek);
        dayOfWeekLabels[i].setHorizontalAlignment(JLabel.CENTER);
        dayPanel.add(dayOfWeekLabels[i]);
        temp.add(Calendar.DATE, 1);
      }

      // Add all the day buttons

      dayButtons = new JToggleButton[6][7];
      dayGroup = new ButtonGroup();
      DayListener dayListener = new DayListener();
      for (int row = 0; row < 6; row++) {
        for (int day = 0; day < 7; day++) {
          dayButtons[row][day] = new JToggleButton();
          dayButtons[row][day].addItemListener(dayListener);
          dayPanel.add(dayButtons[row][day]);
          dayGroup.add(dayButtons[row][day]);
        }
      }

      // We add this special button to the button group, so we have a
      // way of unselecting all the visible buttons

      offScreenButton = new JToggleButton("X");
      dayGroup.add(offScreenButton);

      // Combine the navigators and days

      datePanel.add(monthYearNavigator, BorderLayout.NORTH);
      datePanel.add(dayPanel);
    }

    // Create the time spinner field if we are displaying the time

    if ((selectedComponents & DISPLAY_TIME) > 0) {

      // Create the time component

      spinnerDateModel = new SpinnerDateModel();
      spinnerDateModel.addChangeListener(new TimeListener());
      spinner = new JSpinner(spinnerDateModel);

      JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(spinner, timePattern);
      dateEditor.getTextField().setEditable(false);
      dateEditor.getTextField().setHorizontalAlignment(JTextField.CENTER);
      spinner.setEditor(dateEditor);

      // Set the input/action maps for the spinner. (Only BACK_SPACE
      // seems to work!)

      InputMap sim = new InputMap();
      sim.put(KeyStroke.getKeyStroke("BACK_SPACE"), "setNullDate");
      sim.put(KeyStroke.getKeyStroke("DELETE"), "setNullDate");
      sim.setParent(spinner.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));

      ActionMap sam = new ActionMap();
      sam.put(
          "setNullDate",
          new AbstractAction("setNullDate") {
            public void actionPerformed(ActionEvent e) {
              JCalendar.this.setDate(null);
            }
          });
      sam.setParent(spinner.getActionMap());

      spinner.setInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, sim);
      spinner.setActionMap(sam);

      // Create a special panel for the time display

      JPanel timePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 2, 2));
      timePanel.add(spinner);

      // Now add it to the bottom

      datePanel.add(timePanel, BorderLayout.SOUTH);
    }

    setLayout(new BorderLayout(2, 2));
    add(datePanel);

    // Add today's date at the bottom of the calendar/time, if needed

    if (isTodayDisplayed) {
      Object[] args = {new Date()};
      String todaysDate = MessageFormat.format(bundle.getString("Today"), args);
      todaysLabel = new JLabel(todaysDate);
      todaysLabel.setHorizontalAlignment(JLabel.CENTER);

      // Add today's date at the very bottom

      add(todaysLabel, BorderLayout.SOUTH);
    }
  }
Exemplo n.º 25
0
  /** This method is called from within the constructor to initialize the form. */
  private void initComponents() {
    // name of application
    title = new JLabel();
    title.setFont(new Font("Serif", Font.BOLD, 24));

    // elements for error message
    errorMessage = new JLabel();
    errorMessage.setForeground(Color.RED);

    // elements for registration
    itemList = new JComboBox<String>(new String[0]);
    itemList.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            JComboBox<String> cb = (JComboBox<String>) evt.getSource();
            selectedItem = cb.getSelectedIndex();
          }
        });
    itemLabel = new JLabel();
    storeVisitList = new JComboBox<String>(new String[0]);
    storeVisitList.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            JComboBox<String> cb = (JComboBox<String>) evt.getSource();
            selectedStoreVisit = cb.getSelectedIndex();
          }
        });
    storeVisitLabel = new JLabel();

    addToShoppingListButton = new JButton();
    separator1 = new JSeparator(SwingConstants.HORIZONTAL);

    // elements for participant
    itemNameTextField = new JTextField();
    itemNameLabel = new JLabel();
    addItemButton = new JButton();
    separator2 = new JSeparator(SwingConstants.HORIZONTAL);

    // elements for event
    storeVisitNameTextField = new JTextField();
    storeVisitNameLabel = new JLabel();

    SqlDateModel model = new SqlDateModel();
    Properties p = new Properties();
    p.put("text.today", "Today");
    p.put("text.month", "Month");
    p.put("text.year", "Year");
    JDatePanelImpl datePanel = new JDatePanelImpl(model, p);
    storeVisitDatePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter());

    storeVisitDateLabel = new JLabel();
    storeVisitStartTimeSpinner = new JSpinner(new SpinnerDateModel());
    JSpinner.DateEditor startTimeEditor =
        new JSpinner.DateEditor(storeVisitStartTimeSpinner, "HH:mm");
    storeVisitStartTimeSpinner.setEditor(startTimeEditor); // will only show the current time
    storevisitStartTimeLabel = new JLabel();
    storeVisitEndTimeSpinner = new JSpinner(new SpinnerDateModel());
    JSpinner.DateEditor endTimeEditor = new JSpinner.DateEditor(storeVisitEndTimeSpinner, "HH:mm");
    storeVisitEndTimeSpinner.setEditor(endTimeEditor); // will only show the current time
    storeVisitEndTimeLabel = new JLabel();
    addStoreVisitButton = new JButton();

    // global settings and listeners
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("Shopping List");

    title.setText("Shopping List:");
    itemLabel.setText("Select Item:");
    storeVisitLabel.setText("Select Store Visit:");
    addToShoppingListButton.setText("Add to Shopping List");
    addToShoppingListButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            addToShoppingListButtonActionPerformed(evt);
          }
        });

    itemNameLabel.setText("Name:");
    addItemButton.setText("Add Item");
    addItemButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            addItemButtonActionPerformed(evt);
          }
        });

    storeVisitNameLabel.setText("Name:");
    storeVisitDateLabel.setText("Date:");
    storevisitStartTimeLabel.setText("Start Time:");
    storeVisitEndTimeLabel.setText("End time:");
    addStoreVisitButton.setText("Add Store Visit");
    addStoreVisitButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            addStoreVisitButtonActionPerformed(evt);
          }
        });

    // layout
    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup()
            .addComponent(title)
            .addComponent(errorMessage)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup()
                            .addComponent(itemLabel)
                            .addComponent(storeVisitLabel))
                    .addGroup(
                        layout
                            .createParallelGroup()
                            .addComponent(itemList)
                            .addComponent(storeVisitList)
                            .addComponent(addToShoppingListButton)))
            .addComponent(separator1)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(itemNameLabel)
                    .addGroup(
                        layout
                            .createParallelGroup()
                            .addComponent(itemNameTextField, 200, 200, 400)
                            .addComponent(addItemButton)))
            .addComponent(separator2)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup()
                            .addComponent(storeVisitNameLabel)
                            .addComponent(storeVisitDateLabel)
                            .addComponent(storevisitStartTimeLabel)
                            .addComponent(storeVisitEndTimeLabel))
                    .addGroup(
                        layout
                            .createParallelGroup()
                            .addComponent(storeVisitNameTextField, 200, 200, 400)
                            .addComponent(storeVisitDatePicker)
                            .addComponent(storeVisitStartTimeSpinner)
                            .addComponent(storeVisitEndTimeSpinner)
                            .addComponent(addStoreVisitButton))));

    layout.linkSize(
        SwingConstants.HORIZONTAL,
        new java.awt.Component[] {
          itemList,
          storeVisitList,
          addToShoppingListButton,
          itemNameTextField,
          addItemButton,
          storeVisitNameTextField,
          storeVisitDatePicker,
          storeVisitStartTimeSpinner,
          storeVisitEndTimeSpinner,
          addStoreVisitButton
        });
    layout.linkSize(
        SwingConstants.HORIZONTAL,
        new java.awt.Component[] {storeVisitLabel, itemNameLabel, storeVisitNameLabel});

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addComponent(title)
            .addComponent(errorMessage)
            .addGroup(layout.createParallelGroup().addComponent(itemLabel).addComponent(itemList))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(storeVisitLabel)
                    .addComponent(storeVisitList))
            .addComponent(addToShoppingListButton)
            .addComponent(separator1)
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(itemNameLabel)
                    .addComponent(itemNameTextField))
            .addComponent(addItemButton)
            .addComponent(separator2)
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(storeVisitNameLabel)
                    .addComponent(storeVisitNameTextField))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(storeVisitDateLabel)
                    .addComponent(storeVisitDatePicker))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(storevisitStartTimeLabel)
                    .addComponent(storeVisitStartTimeSpinner))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(storeVisitEndTimeLabel)
                    .addComponent(storeVisitEndTimeSpinner))
            .addComponent(addStoreVisitButton));

    pack();
  }
Exemplo n.º 26
0
 /** Fills the panel with event specific fields. */
 protected void fillPanel() {
   JLabel l;
   Box fdp = Box.createVerticalBox();
   fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram"));
   fdChart = makeFDChart();
   ChartPanel cp = new ChartPanel(fdChart);
   cp.setMinimumDrawWidth(100);
   cp.setMinimumDrawHeight(60);
   cp.setPreferredSize(new Dimension(250, 80));
   fdp.add(new JScrollPane(cp));
   JPanel prmp = new JPanel(new SpringLayout());
   l = new JLabel("Capacity:", JLabel.TRAILING);
   prmp.add(l);
   spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0));
   spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00"));
   spinMaxFlow.addChangeListener(this);
   spinMaxFlow.setName(nmSpinMaxFlow);
   l.setLabelFor(spinMaxFlow);
   prmp.add(spinMaxFlow);
   l = new JLabel("Cap.Drop:", JLabel.TRAILING);
   prmp.add(l);
   spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0));
   spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00"));
   spinCapDrop.addChangeListener(this);
   spinCapDrop.setName(nmSpinCapDrop);
   l.setLabelFor(spinCapDrop);
   prmp.add(spinCapDrop);
   l = new JLabel("C.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0));
   spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00"));
   spinCritDen.addChangeListener(this);
   spinCritDen.setName(nmSpinCritDen);
   l.setLabelFor(spinCritDen);
   prmp.add(spinCritDen);
   l = new JLabel("  V:", JLabel.TRAILING);
   prmp.add(l);
   spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0));
   spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00"));
   spinVff.addChangeListener(this);
   spinVff.setName(nmSpinVff);
   l.setLabelFor(spinVff);
   prmp.add(spinVff);
   l = new JLabel("J.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0));
   spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00"));
   spinJamDen.addChangeListener(this);
   spinJamDen.setName(nmSpinJamDen);
   l.setLabelFor(spinJamDen);
   prmp.add(spinJamDen);
   l = new JLabel("  W:", JLabel.TRAILING);
   prmp.add(l);
   if (jd == cd) jd = cd + 1;
   int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999);
   spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0));
   spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00"));
   spinWc.addChangeListener(this);
   spinWc.setName(nmSpinWc);
   l.setLabelFor(spinWc);
   prmp.add(spinWc);
   SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2);
   fdp.add(prmp);
   // add(new JScrollPane(fdp));
   add(fdp);
   return;
 }
  public static void main(String[] xx) {
    // 0. Bikin Frame
    JFrame fr = new JFrame("Demo Tab");

    // 1. Set size
    fr.setSize(400, 400);

    // 2. Tambahkan panel
    JTabbedPane isi = new JTabbedPane();
    isi.setTabPlacement(JTabbedPane.BOTTOM);
    fr.getContentPane().add(isi);

    // 3. Tambahkan komponen
    JRadioButton rbPria = new JRadioButton("Pria");
    JRadioButton rbWanita = new JRadioButton("Wanita");

    // dalam satu group harus pilih salah satu
    ButtonGroup bgJenis = new ButtonGroup();
    bgJenis.add(rbPria);
    bgJenis.add(rbWanita);

    JPanel pnlJenis = new JPanel();
    pnlJenis.add(new JLabel("Jenis Kelamin : "));
    pnlJenis.add(rbPria);
    pnlJenis.add(rbWanita);
    isi.addTab("Jenis Kelamin", pnlJenis);

    JCheckBox cbMembaca = new JCheckBox("Membaca");
    JCheckBox cbBerenang = new JCheckBox("Berenang");
    JPanel pnlHobi = new JPanel();
    pnlHobi.add(new JLabel("Hobi"));
    pnlHobi.add(cbMembaca);
    pnlHobi.add(cbBerenang);
    isi.addTab("Hobi", pnlHobi);

    JButton btnSimpan = new JButton("Simpan");
    JButton btnBatal = new JButton("Batal");
    btnBatal.setEnabled(false); // enable/disable
    JPanel pnlTombol = new JPanel();
    pnlTombol.add(btnSimpan);
    pnlTombol.add(btnBatal);
    isi.addTab("Proses", pnlTombol);

    JSlider slider =
        new JSlider(
            JSlider.HORIZONTAL,
            0, // minimum
            100, // maksimum
            10 // posisi awal
            );

    JPanel pnlSlider = new JPanel();
    pnlSlider.add(new JLabel("Volume : "));
    pnlSlider.add(slider);
    isi.addTab("Slider", pnlSlider);

    int tahun = 2012;
    SpinnerModel spTahun =
        new SpinnerNumberModel(
            tahun, // posisi awal
            tahun - 100, // minimum
            tahun + 100, // maksimum
            1 // increment/decrement
            );
    JSpinner spinner = new JSpinner(spTahun);
    spinner.setEditor(new JSpinner.NumberEditor(spinner, "####"));
    JPanel pnlSpin = new JPanel();
    pnlSpin.add(new JLabel("Tahun : "));
    pnlSpin.add(spinner);
    isi.addTab("Spinner", pnlSpin);

    // 4. Tampilkan
    fr.setLocationRelativeTo(null);
    fr.setVisible(true);
  }
Exemplo n.º 28
0
 public void setPattern(String pattern) {
   String oldValue = this.pattern;
   this.pattern = pattern;
   super.setEditor(this.createNewEditor(pattern));
   this.notificarAlteracao(PROP_PATTERN, oldValue, this.pattern);
 }
  /** Creates the GUI */
  private void createGUI() {
    JPanel content = (JPanel) this.getContentPane();
    content.setLayout(new BorderLayout());
    content.setBorder(UiUtilities.DIALOG_BORDER);

    Vector<String> data = new Vector<String>();

    data.add(TIMETEXT[0]);
    data.add(TIMETEXT[1]);
    data.add(TIMETEXT[2]);

    TimeFormatter formatter = new TimeFormatter();

    for (int time : mTimes) {
      int h = time / 60;
      int m = time % 60;
      StringBuilder builder = new StringBuilder();
      builder.append(mLocalizer.msg("at", "at"));
      builder.append(' ');
      builder.append(formatter.formatTime(h, m));
      data.add(builder.toString());
    }

    data.add(mLocalizer.msg("configureTimes", "Configure Times"));

    mBox = new JComboBox(data);

    mBox.addActionListener(
        new ActionListener() {

          private int lastSelected = 0;

          public void actionPerformed(ActionEvent e) {
            if (mBox.getSelectedIndex() == mBox.getItemCount() - 1) {
              mBox.setSelectedIndex(lastSelected);
              Plugin.getPluginManager().showSettings(SettingsItem.TIMEBUTTONS);
            } else {
              lastSelected = mDate.getSelectedIndex();
              int time = calcTimeForSelection(mBox.getSelectedIndex());
              generateList(new Date(), time);
            }
          }
        });

    ButtonGroup group = new ButtonGroup();
    group.add(mRuns);
    group.add(mOn);

    JPanel datetimeselect = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));

    Vector<Date> dates = new Vector<Date>();

    Date currentDate = Date.getCurrentDate();
    for (int i = 0; i < 14; i++) {
      dates.add(currentDate.addDays(i));
    }

    mDate = new JComboBox(dates);

    datetimeselect.add(mDate);

    datetimeselect.add(new JLabel(" " + mLocalizer.msg("at", "at") + " "));

    JSpinner.DateEditor dateEditor =
        new JSpinner.DateEditor(mTimeSpinner, Settings.getTimePattern());

    mTimeSpinner.setEditor(dateEditor);

    CaretPositionCorrector.createCorrector(dateEditor.getTextField(), new char[] {':'}, -1);

    datetimeselect.add(mTimeSpinner);

    Vector<String> filters = new Vector<String>();
    filters.add(mLocalizer.msg("filterAll", "all channels"));
    for (String filterName : FilterComponentList.getInstance().getChannelFilterNames()) {
      filters.add(filterName);
    }
    filters.add(mLocalizer.ellipsisMsg("filterDefine", "define filter"));
    mChannels = new JComboBox(filters);
    datetimeselect.add(new JLabel("    "));
    datetimeselect.add(mChannels);

    // Event-Handler

    mRuns.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            refreshView();
          }
        });

    mOn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            refreshView();
          }
        });

    mDate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            refreshView();
          }
        });

    mTimeSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            refreshView();
          }
        });

    mChannels.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // user defined selection
            if (mChannels.getSelectedIndex() == mChannels.getItemCount() - 1) {
              EditFilterComponentDlg dlg =
                  new EditFilterComponentDlg(null, null, ChannelFilterComponent.class);
              FilterComponent rule = dlg.getFilterComponent();
              if (rule == null) {
                return;
              }
              if (!(rule instanceof ChannelFilterComponent)) {
                return;
              }
              FilterComponentList.getInstance().add(rule);
              FilterComponentList.getInstance().store();
              String filterName = rule.getName();
              mChannels.removeAllItems();
              mChannels.addItem(mLocalizer.msg("filterAll", "all channels"));
              for (String channel : FilterComponentList.getInstance().getChannelFilterNames()) {
                mChannels.addItem(channel);
              }
              mChannels.addItem(mLocalizer.ellipsisMsg("filterDefine", "define filter"));
              mChannels.setSelectedItem(filterName);
            }
            mModel.removeAllRows();
            refreshView();
          }
        });

    mRuns.setSelected(true);
    mDate.setEnabled(false);
    mTimeSpinner.setEnabled(false);

    JLabel filterLabel = new JLabel("Filter:");
    filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);

    mFilterBox = new JComboBox(Plugin.getPluginManager().getFilterManager().getAvailableFilters());
    mFilterBox.setSelectedItem(Plugin.getPluginManager().getFilterManager().getCurrentFilter());
    mFilterBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              mCurrentFilter = (ProgramFilter) e.getItem();
              refreshView();
            }
          }
        });

    // Upper Panel

    JPanel topPanel =
        new JPanel(
            new FormLayout(
                "pref, 3dlu, pref, 15dlu, pref, 3dlu, pref, 3dlu, pref", "pref, 1dlu, pref, 3dlu"));

    CellConstraints cc = new CellConstraints();

    topPanel.add(mRuns, cc.xy(1, 1));
    topPanel.add(mBox, cc.xy(3, 1));
    topPanel.add(mOn, cc.xy(5, 1));
    topPanel.add(datetimeselect, cc.xy(7, 1));

    topPanel.add(filterLabel, cc.xy(1, 3));
    topPanel.add(mFilterBox, cc.xyw(3, 3, 5));

    content.add(topPanel, BorderLayout.NORTH);

    // Rest of the GUI
    mProgramTable = new ListTable(mModel);
    mProgramTable.getTableHeader().setReorderingAllowed(false);
    mProgramTable.getTableHeader().setResizingAllowed(false);
    mProgramTable.setToolTipText("");

    mProgramTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopup(evt);
            }
          }

          @Override
          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopup(evt);
            }
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            mouseClickedOnTable(e);
          }
        });

    // Dispatch the KeyEvent to the RootPane for Closing the Dialog.
    // Needed for Java 1.4.
    mProgramTable.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            mProgramTable.getRootPane().dispatchEvent(e);
          }
        });

    setTableColumProperties();

    JScrollPane scroll =
        new JScrollPane(
            mProgramTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    content.add(scroll, BorderLayout.CENTER);

    JPanel buttonPn = new JPanel(new BorderLayout());
    buttonPn.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    content.add(buttonPn, BorderLayout.SOUTH);

    JButton closeButton = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE));
    closeButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent evt) {
            dispose();
          }
        });

    JPanel p = new JPanel(new FormLayout("pref,5dlu,pref,5dlu,pref", "pref"));
    JButton settings = new JButton(TVBrowserIcons.preferences(TVBrowserIcons.SIZE_SMALL));
    settings.setToolTipText(mLocalizer.msg("settings", "Open settings"));

    settings.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            close();
            Plugin.getPluginManager().showSettings(ListViewPlugin.getInstance());
          }
        });

    final JCheckBox showAtStartup = new JCheckBox(mLocalizer.msg("showAtStart", "Show at start"));
    showAtStartup.setSelected(mSettings.getProperty("showAtStartup", "false").equals("true"));

    showAtStartup.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (showAtStartup.isSelected()) {
              mSettings.setProperty("showAtStartup", "true");
            } else {
              mSettings.setProperty("showAtStartup", "false");
            }
          }
        });

    p.add(settings, cc.xy(1, 1));
    p.add(showAtStartup, cc.xy(3, 1));

    buttonPn.add(p, BorderLayout.WEST);

    buttonPn.add(closeButton, BorderLayout.EAST);
    getRootPane().setDefaultButton(closeButton);
  }
Exemplo n.º 30
0
  private void initializeComponents() {
    this.setTitle("Configuration");
    this.setResizable(false);

    setLayout(new BorderLayout(20, 20));

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    mainPanel.setBorder(new LineBorder(mainPanel.getBackground(), 10));
    add(mainPanel, BorderLayout.CENTER);

    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.gridx = 0;
    labelConstraints.anchor = GridBagConstraints.WEST;
    labelConstraints.insets = new Insets(5, 5, 5, 5);

    GridBagConstraints inputConstraints = new GridBagConstraints();
    inputConstraints.gridx = 1;
    inputConstraints.anchor = GridBagConstraints.EAST;
    inputConstraints.weightx = 1;
    inputConstraints.insets = new Insets(5, 5, 5, 5);

    JPanel evolutionOptionsPanel = new JPanel();
    evolutionOptionsPanel.setBorder(new TitledBorder("Evolution"));
    evolutionOptionsPanel.setLayout(new BoxLayout(evolutionOptionsPanel, BoxLayout.Y_AXIS));
    mainPanel.add(evolutionOptionsPanel);

    // world size
    JPanel worldSizePanel = new JPanel(new GridBagLayout());
    evolutionOptionsPanel.add(worldSizePanel);
    JLabel worldSizeLabel = new JLabel("World Size");
    worldSizeLabel.setToolTipText("Size of the world in pixels. Width x Height.");
    worldSizePanel.add(worldSizeLabel, labelConstraints);
    JPanel worldSizeInputPanel = new JPanel();
    worldSizeInputPanel.setLayout(new GridBagLayout());
    final AutoSelectOnFocusSpinner worldSizeWidthSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.getDimension().width, 1, Integer.MAX_VALUE, 1));
    final AutoSelectOnFocusSpinner worldSizeHeightSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.getDimension().height, 1, Integer.MAX_VALUE, 1));
    worldSizeInputPanel.add(worldSizeWidthSpinner);
    JLabel separatorLabel = new JLabel("x");
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(0, 5, 0, 5);
    worldSizeInputPanel.add(separatorLabel, c);
    worldSizeInputPanel.add(worldSizeHeightSpinner);
    worldSizePanel.add(worldSizeInputPanel, inputConstraints);

    // starting energy
    JPanel startingEnergyPanel = new JPanel(new GridBagLayout());
    evolutionOptionsPanel.add(startingEnergyPanel);
    JLabel startingEnergyLabel = new JLabel("Starting Energy");
    startingEnergyLabel.setToolTipText(
        "<html>The amount of energy all newly painted pixels start out with.<br />Note that changing this will not affect already painted pixels.</html>");
    startingEnergyPanel.add(startingEnergyLabel, labelConstraints);
    final AutoSelectOnFocusSpinner startingEnergySpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.startingEnergy, 1, Integer.MAX_VALUE, 1));
    startingEnergyPanel.add(startingEnergySpinner, inputConstraints);

    // mutation rate
    JPanel mutationRatePanel = new JPanel(new GridBagLayout());
    evolutionOptionsPanel.add(mutationRatePanel);
    JLabel mutationRateLabel = new JLabel("Mutation Rate");
    mutationRateLabel.setToolTipText(
        "<html>Chance for a mutation to occur during copy or mixing operations.<br />A value of 0.01 means a 1% chance, a value of 0 disables mutation.</html>");
    mutationRatePanel.add(mutationRateLabel, labelConstraints);
    final JSpinner mutationRateSpinner =
        new JSpinner(new SpinnerNumberModel(config.mutationRate, 0.0, 1.0, 0.01));
    mutationRateSpinner.setEditor(
        new JSpinner.NumberEditor(mutationRateSpinner, "#.##############"));
    mutationRateSpinner.setPreferredSize(
        new Dimension(180, mutationRateSpinner.getPreferredSize().height));
    final JFormattedTextField mutationRateSpinnerText =
        ((JSpinner.NumberEditor) mutationRateSpinner.getEditor()).getTextField();
    mutationRateSpinnerText.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    mutationRateSpinnerText.selectAll();
                  }
                });
          }

          public void focusLost(FocusEvent e) {}
        });
    mutationRatePanel.add(mutationRateSpinner, inputConstraints);

    JPanel guiOptionsPanel = new JPanel();
    guiOptionsPanel.setBorder(new TitledBorder("GUI"));
    guiOptionsPanel.setLayout(new BoxLayout(guiOptionsPanel, BoxLayout.Y_AXIS));
    mainPanel.add(guiOptionsPanel);

    // background color
    JPanel backgroundColorPanel = new JPanel(new GridBagLayout());
    guiOptionsPanel.add(backgroundColorPanel, labelConstraints);
    JLabel backgroundColorLabel = new JLabel("Background Color");
    backgroundColorLabel.setToolTipText(
        "<html>Pick the background color.<br />If you have a lot of dark pixels, you might want to set this to a light color.</html>");
    backgroundColorPanel.add(backgroundColorLabel, labelConstraints);
    backgroundColor = new PixelColor(config.backgroundColor);
    JPanel backgroundColorAlignmentPanel = new JPanel();
    backgroundColorAlignmentPanel.setLayout(new GridBagLayout());
    backgroundColorAlignmentPanel.setPreferredSize(mutationRateSpinner.getPreferredSize());
    final ColorChooserLabel backgroundColorChooserLabel = new ColorChooserLabel(backgroundColor);
    backgroundColorAlignmentPanel.add(backgroundColorChooserLabel);
    backgroundColorPanel.add(backgroundColorAlignmentPanel, inputConstraints);

    // FPS
    JPanel fpsPanel = new JPanel(new GridBagLayout());
    guiOptionsPanel.add(fpsPanel);
    JLabel fpsLabel = new JLabel("FPS");
    fpsLabel.setToolTipText(
        "<html>The repaint interval in frames per second (FPS).<br />Set this to a lower value to save a few CPU cycles.</html>");
    fpsPanel.add(fpsLabel, labelConstraints);
    final AutoSelectOnFocusSpinner fpsSpinner =
        new AutoSelectOnFocusSpinner(new SpinnerNumberModel(config.fps, 1, Integer.MAX_VALUE, 1));
    fpsPanel.add(fpsSpinner, inputConstraints);

    // paint history size
    JPanel paintHistorySizePanel = new JPanel(new GridBagLayout());
    guiOptionsPanel.add(paintHistorySizePanel);
    JLabel paintHistorySizeLabel = new JLabel("Paint-History Size");
    paintHistorySizeLabel.setToolTipText(
        "<html>Sets the number of entries in the paint history.<br />In case you have not found it yet: the paint history is the little menu that appears when you right-click on the image.</html>");
    paintHistorySizePanel.add(paintHistorySizeLabel, labelConstraints);
    final AutoSelectOnFocusSpinner paintHistorySizeSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.paintHistorySize, 1, Integer.MAX_VALUE, 1));
    paintHistorySizePanel.add(paintHistorySizeSpinner, inputConstraints);

    JPanel videoOptionsPanel = new JPanel();
    videoOptionsPanel.setBorder(new TitledBorder("Video Recording"));
    videoOptionsPanel.setLayout(new BoxLayout(videoOptionsPanel, BoxLayout.Y_AXIS));
    mainPanel.add(videoOptionsPanel);

    // FPS video
    JPanel fpsVideoPanel = new JPanel(new GridBagLayout());
    videoOptionsPanel.add(fpsVideoPanel);
    JLabel fpsVideoLabel = new JLabel("FPS of videos");
    fpsVideoLabel.setToolTipText("The number of frames per second (FPS) in recorded videos.");
    fpsVideoPanel.add(fpsVideoLabel, labelConstraints);
    final AutoSelectOnFocusSpinner fpsVideoSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.fpsVideo, 1, Integer.MAX_VALUE, 1));
    fpsVideoPanel.add(fpsVideoSpinner, inputConstraints);

    // video encoder command
    JPanel videoEncoderPanel = new JPanel(new GridBagLayout());
    videoOptionsPanel.add(videoEncoderPanel);
    JLabel videoEncoderLabel = new JLabel("Video Encoder");
    videoEncoderLabel.setToolTipText(
        "<html>The command to invoke your video encoder.<br />Use the tokens INPUT_FILE and OUTPUT_FILE to denote input and output files of your encoder.</html>");
    videoEncoderPanel.add(videoEncoderLabel, labelConstraints);
    final JTextArea videoEncoderTextArea = new JTextArea(Configuration.ENCODER_COMMAND);
    videoEncoderTextArea.setLineWrap(true);
    videoEncoderTextArea.setWrapStyleWord(true);
    JScrollPane videoEncoderScrollPane =
        new JScrollPane(
            videoEncoderTextArea,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    videoEncoderScrollPane.setViewportBorder(null);
    videoEncoderScrollPane.setPreferredSize(
        new Dimension(worldSizeInputPanel.getPreferredSize().width, 100));
    videoEncoderPanel.add(videoEncoderScrollPane, inputConstraints);

    JPanel controlPanel = new JPanel();
    add(controlPanel, BorderLayout.SOUTH);

    JButton okButton = new JButton("OK");
    okButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            new Thread() {

              @Override
              public void run() {
                config.world.addChangeListener(
                    new IChangeListener() {

                      public void changed() {
                        int i, j;
                        double d;
                        String s;

                        // evolution

                        i = (Integer) worldSizeWidthSpinner.getValue();
                        j = (Integer) worldSizeHeightSpinner.getValue();
                        if (config.getDimension().width != i || config.getDimension().height != i) {
                          config.setDimension(new Dimension(i, j));
                        }

                        i = (Integer) startingEnergySpinner.getValue();
                        if (config.startingEnergy != i) {
                          config.startingEnergy = i;
                        }

                        d = (Double) mutationRateSpinner.getValue();
                        if (config.mutationRate != d) {
                          config.mutationRate = d;
                        }

                        // gui

                        i = backgroundColor.getInteger();
                        if (config.backgroundColor != i) {
                          config.backgroundColor = i;
                        }

                        i = (Integer) fpsSpinner.getValue();
                        if (config.fps != i) {
                          config.fps = i;
                        }

                        i = (Integer) paintHistorySizeSpinner.getValue();
                        if (config.paintHistorySize != i) {
                          config.paintHistorySize = i;
                        }

                        // video recording

                        i = (Integer) fpsVideoSpinner.getValue();
                        if (config.fpsVideo != i) {
                          config.fpsVideo = i;
                        }

                        s = videoEncoderTextArea.getText();
                        if (false == Configuration.ENCODER_COMMAND.equals(s)) {
                          Configuration.ENCODER_COMMAND = s;
                        }

                        dispose();
                      }
                    });
              }
            }.start();
          }
        });
    controlPanel.add(okButton);
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    controlPanel.add(cancelButton);

    pack();
  }