public ParameterEditDialog(Field field) { targetField = field; setBounds(20, 10, 100, 100); // Fieldの型を取得する Class<?> type = targetField.getType(); if (type.isPrimitive()) { JSpinner valueSpnipper = new JSpinner(); valueSpnipper.setPreferredSize(new Dimension(80, 20)); GridBagLayoutUtil.setGbcLayout( 0, 0, new GridBagConstraints(), valueSpnipper, new GridBagLayout(), this); } addKeyListener( new KeyListener() { @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) {} @Override public void keyPressed(KeyEvent e) { if (e.equals(KeyEvent.VK_ENTER)) {} } }); }
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; }
/* * @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); }
/** * 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; }
/** Performs the action of loading a session from a file. */ public void actionPerformed(ActionEvent e) { DataModel dataModel = getDataEditor().getSelectedDataModel(); if (!(dataModel instanceof DataSet)) { JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set."); return; } this.dataSet = (DataSet) dataModel; SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(getNumLags(), 0, 20, 1); JSpinner jSpinner = new JSpinner(spinnerNumberModel); jSpinner.setPreferredSize(jSpinner.getPreferredSize()); spinnerNumberModel.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SpinnerNumberModel model = (SpinnerNumberModel) e.getSource(); setNumLags(model.getNumber().intValue()); } }); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); Box b = Box.createVerticalBox(); Box b1 = Box.createHorizontalBox(); b1.add(new JLabel("Number of time lags: ")); b1.add(Box.createHorizontalGlue()); b1.add(Box.createHorizontalStrut(15)); b1.add(jSpinner); b1.setBorder(new EmptyBorder(10, 10, 10, 10)); b.add(b1); panel.add(b, BorderLayout.CENTER); EditorWindow editorWindow = new EditorWindow(panel, "Create time series data", "Save", true); DesktopController.getInstance().addEditorWindow(editorWindow); editorWindow.setVisible(true); editorWindow.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosed(InternalFrameEvent e) { EditorWindow window = (EditorWindow) e.getSource(); if (!window.isCanceled()) { if (dataSet.isContinuous()) { createContinuousTimeSeriesData(); } else if (dataSet.isDiscrete()) { createDiscreteTimeSeriesData(); } else { JOptionPane.showMessageDialog( JOptionUtils.centeringComp(), "Data set must be either continuous or discrete."); } } } }); }
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); }
private void configureSpinnerFloat(JSpinner spinner) { JSpinner.NumberEditor editor = (JSpinner.NumberEditor) spinner.getEditor(); DecimalFormat format = editor.getFormat(); format.setMinimumFractionDigits(3); format.setMinimumIntegerDigits(1); editor.getTextField().setHorizontalAlignment(SwingConstants.CENTER); Dimension d = spinner.getPreferredSize(); d.width = 60; spinner.setPreferredSize(d); spinner.addChangeListener(this); spinner.setMaximumSize(d); }
private void createStartTimePanel() { // create startTimePanel startTimePanel = new JPanel(new GridBagLayout()); startLab = new JLabel("Start"); GridBagConstraints startLabC = new GridBagConstraints(); startLabC.insets = new Insets(10, 10, 5, 0); startLabC.anchor = GridBagConstraints.LINE_START; startTimePanel.add(startLab, startLabC); startTime = new JDateChooser(); GridBagConstraints startTimeC = new GridBagConstraints(); startTimeC.gridy = 1; startTimeC.gridwidth = 3; startTimeC.insets = new Insets(5, 10, 5, 0); startTimePanel.add(startTime, startTimeC); startHourSpinner = new JSpinner(); startHourSpinner.setPreferredSize(new Dimension(45, 28)); GridBagConstraints hourC = new GridBagConstraints(); hourC.gridy = 2; hourC.insets = new Insets(5, 10, 5, 5); startTimePanel.add(startHourSpinner, hourC); colonLab = new JLabel(":"); GridBagConstraints colonC = new GridBagConstraints(); colonC.gridx = 1; colonC.gridy = 2; startTimePanel.add(colonLab, colonC); startMinuteSpinner = new JSpinner(); startMinuteSpinner.setPreferredSize(new Dimension(45, 28)); GridBagConstraints minuteC = new GridBagConstraints(); minuteC.gridy = 2; minuteC.gridx = 2; minuteC.insets = new Insets(5, 0, 5, 0); minuteC.anchor = GridBagConstraints.LINE_START; startTimePanel.add(startMinuteSpinner, minuteC); }
private void createEndTimePanel() { // create endTimePanel endTimePanel = new JPanel(new GridBagLayout()); endLab = new JLabel("End"); GridBagConstraints endLabC = new GridBagConstraints(); endLabC.insets = new Insets(10, 10, 5, 0); endLabC.anchor = GridBagConstraints.LINE_START; endTimePanel.add(endLab, endLabC); endTime = new JDateChooser(); GridBagConstraints endTimeC = new GridBagConstraints(); endTimeC.gridy = 1; endTimeC.gridwidth = 3; endTimeC.insets = new Insets(5, 10, 5, 0); endTimePanel.add(endTime, endTimeC); endHourSpinner = new JSpinner(); endHourSpinner.setPreferredSize(new Dimension(45, 28)); GridBagConstraints eHourC = new GridBagConstraints(); eHourC.gridy = 2; eHourC.insets = new Insets(5, 10, 5, 5); endTimePanel.add(endHourSpinner, eHourC); colonLab = new JLabel(":"); GridBagConstraints eColonC = new GridBagConstraints(); eColonC.gridx = 1; eColonC.gridy = 2; endTimePanel.add(colonLab, eColonC); endMinuteSpinner = new JSpinner(); endMinuteSpinner.setPreferredSize(new Dimension(45, 28)); GridBagConstraints eMinuteC = new GridBagConstraints(); eMinuteC.gridy = 2; eMinuteC.gridx = 2; eMinuteC.insets = new Insets(5, 0, 5, 0); eMinuteC.anchor = GridBagConstraints.LINE_START; endTimePanel.add(endMinuteSpinner, eMinuteC); }
public PlayerPanel() { super(); innerPanel.setLayout(new GridBagLayout()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.insets.set(3, 3, 3, 3); for (int i = 0; i < MAXPLAYERS; i++) { final JCheckBox cb = new JCheckBox(); if (i < 4) { cb.setSelected(true); if (i < 2) { cb.setEnabled(false); } } final JTextField tf = new JTextField(); tf.setText("Player " + (i + 1)); tf.setPreferredSize(new Dimension(130, 20)); final JSpinner sp = new JSpinner(new SpinnerNumberModel(1500, 100, 1000000000, 100)); sp.setPreferredSize(new Dimension(100, 20)); final JComboBox co = new JComboBox(ControllerInfo.getControllers()); co.setPreferredSize(new Dimension(200, 20)); if (i > 0) { co.setSelectedIndex(3); } checkBoxes.add(cb); textFields.add(tf); spinners.add(sp); comboBoxes.add(co); constraints.gridy = i; constraints.gridx = 0; innerPanel.add(cb, constraints); constraints.gridx++; innerPanel.add(tf, constraints); constraints.gridx++; innerPanel.add(sp, constraints); constraints.gridx++; innerPanel.add(co, constraints); } innerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); add(innerPanel); }
/** * This method initializes spnCapacity * * @return javax.swing.JSpinner * @uml.property name="spnCapacity" */ private JSpinner getSpnCapacity() { if (spnCapacity == null) { spnCapacity = new JSpinner(); spnCapacity.setPreferredSize(new Dimension(50, 20)); spnCapacity.setModel(new SpinnerNumberModel(1, 1, 10000, 1)); spnCapacity.addChangeListener( new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { currentSchool.setCapacity((Integer) spnCapacity.getValue()); } }); } return spnCapacity; }
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); }
@Override protected JSpinner createSpinner(int b) { JSpinner spinner = new JSpinner(); SpinnerListModel model = new SpinnerListModel(_keyList); spinner.setModel(model); ((JSpinner.ListEditor) spinner.getEditor()).getTextField().setEditable(false); model.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { update(); } }); Dimension d = new Dimension(40, spinner.getPreferredSize().height); spinner.setMinimumSize(d); spinner.setPreferredSize(d); return spinner; }
public SatelliteMultiViewerCorner() { layer = new SpinnerListModel(); layer.addChangeListener( new ChangeListener() { @SuppressWarnings("rawtypes") @Override public void stateChanged(ChangeEvent e) { // find viewer for satellite if (layer.getValue() instanceof LayerViewer) setViewer((LayerViewer) layer.getValue()); else setViewer(null); } }); spinner = new JSpinner(layer); // Workaround to fix the satellite jumping issue // caused by changeevent-setviewer-dolayout-setvalue-(layoutinvalid) spinner.setPreferredSize(new Dimension(105, 22)); getSatellite().getContentPane().add(spinner, BorderLayout.NORTH); // by default disabled setEnabled(false); }
/** * 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); }
/** Builds the panel. */ public void setup() { SpinnerNumberModel model = new SpinnerNumberModel(this.params.getInt("numTimeLags", 1), 0, Integer.MAX_VALUE, 1); JSpinner jSpinner = new JSpinner(model); jSpinner.setPreferredSize(jSpinner.getPreferredSize()); model.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SpinnerNumberModel model = (SpinnerNumberModel) e.getSource(); params.set("numTimeLags", model.getNumber().intValue()); } }); Box b1 = Box.createHorizontalBox(); b1.add(new JLabel("Number of lags: ")); b1.add(Box.createHorizontalGlue()); b1.add(Box.createHorizontalStrut(15)); b1.add(jSpinner); b1.setBorder(new EmptyBorder(10, 10, 10, 10)); add(b1, BorderLayout.CENTER); }
/** @return spinner_rotation */ private JSpinner getSpinner_rotation() { if (spinner_rotation == null) { spinner_rotation = new JSpinner(); spinner_rotation.setMaximumSize(new Dimension(80, 27)); spinner_rotation.setMinimumSize(new Dimension(80, 27)); spinner_rotation.setPreferredSize(new Dimension(80, 27)); spinner_rotation.setModel( new SpinnerNumberModel(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 1)); spinner_rotation.setValue(TwoAxes3D.getRotation()); spinner_rotation.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { TwoAxes3D.setRotation((Double) spinner_rotation.getValue()); fireActionEvent( new ActionEvent( TwoAxes3DSettingsPanel.this, 0, SycamoreFiredActionEvents.UPDATE_AGREEMENTS_GRAPHICS.name())); } }); } return spinner_rotation; }
private JPanel generateConfigPanel() { final JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(3, 3, 3, 3); final JSpinner spinnerThreshold = new JSpinner(new SpinnerNumberModel(getThreshold(), 0.0, Double.MAX_VALUE, 0.1)); final JSpinner spinnerLowValue = new JSpinner( new SpinnerNumberModel(getLowValue(), -Double.MAX_VALUE, Double.MAX_VALUE, 0.1)); final JSpinner spinnerHighValue = new JSpinner( new SpinnerNumberModel(getHighValue(), -Double.MAX_VALUE, Double.MAX_VALUE, 0.1)); Dimension prefSize = new Dimension(120, spinnerThreshold.getPreferredSize().height); spinnerThreshold.setPreferredSize(prefSize); spinnerLowValue.setPreferredSize(prefSize); spinnerHighValue.setPreferredSize(prefSize); spinnerThreshold.setEditor(new JSpinner.NumberEditor(spinnerThreshold, "0.00")); spinnerLowValue.setEditor(new JSpinner.NumberEditor(spinnerLowValue, "0.00")); spinnerHighValue.setEditor(new JSpinner.NumberEditor(spinnerHighValue, "0.00")); gbc.gridx = 1; gbc.gridy = 1; panel.add(new JLabel(" Threshold: "), gbc); gbc.gridx++; panel.add(spinnerThreshold, gbc); gbc.gridx++; panel.add(new JLabel(" Low value: "), gbc); gbc.gridx++; panel.add(spinnerLowValue, gbc); gbc.gridx++; panel.add(new JLabel(" High value: "), gbc); gbc.gridx++; panel.add(spinnerHighValue, gbc); spinnerThreshold.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setThreshold( ((SpinnerNumberModel) spinnerThreshold.getModel()).getNumber().doubleValue()); panel.firePropertyChange(DataGenerator.property, 0, System.currentTimeMillis()); } }); spinnerLowValue.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setLowValue( ((SpinnerNumberModel) spinnerLowValue.getModel()).getNumber().doubleValue()); panel.firePropertyChange(DataGenerator.property, 0, System.currentTimeMillis()); } }); spinnerHighValue.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setHighValue( ((SpinnerNumberModel) spinnerHighValue.getModel()).getNumber().doubleValue()); panel.firePropertyChange(DataGenerator.property, 0, System.currentTimeMillis()); } }); return panel; }
/** performs the creation of the dialog and all its components. */ protected void initGUI() { JPanel panel; SpinnerNumberModel model; JPanel panel2; getContentPane().setLayout(new BorderLayout()); panel = new JPanel(new GridLayout(6, 1)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); getContentPane().add(panel, BorderLayout.CENTER); // mean precision m_MeanPrecSpinner = new JSpinner(); m_MeanPrecSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); model = (SpinnerNumberModel) m_MeanPrecSpinner.getModel(); model.setMaximum(new Integer(20)); model.setMinimum(new Integer(0)); m_MeanPrecLabel = new JLabel("Mean Precision"); m_MeanPrecLabel.setDisplayedMnemonic('M'); m_MeanPrecLabel.setLabelFor(m_MeanPrecSpinner); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_MeanPrecLabel); panel2.add(m_MeanPrecSpinner); panel.add(panel2); // stddev precision m_StdDevPrecSpinner = new JSpinner(); m_StdDevPrecSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); model = (SpinnerNumberModel) m_StdDevPrecSpinner.getModel(); model.setMaximum(new Integer(20)); model.setMinimum(new Integer(0)); m_StdDevPrecLabel = new JLabel("StdDev. Precision"); m_StdDevPrecLabel.setDisplayedMnemonic('S'); m_StdDevPrecLabel.setLabelFor(m_StdDevPrecSpinner); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_StdDevPrecLabel); panel2.add(m_StdDevPrecSpinner); panel.add(panel2); // Format m_OutputFormatComboBox = new JComboBox(m_OutputFormatNames); m_OutputFormatComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { getData(); } }); m_OutputFormatLabel = new JLabel("Output Format"); m_OutputFormatLabel.setDisplayedMnemonic('F'); m_OutputFormatLabel.setLabelFor(m_OutputFormatComboBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_OutputFormatLabel); panel2.add(m_OutputFormatComboBox); panel.add(panel2); // Average m_ShowAverageCheckBox = new JCheckBox(""); m_ShowAverageCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); m_ShowAverageLabel = new JLabel("Show Average"); m_ShowAverageLabel.setDisplayedMnemonic('A'); m_ShowAverageLabel.setLabelFor(m_ShowAverageCheckBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_ShowAverageLabel); panel2.add(m_ShowAverageCheckBox); panel.add(panel2); // Remove filter classname m_RemoveFilterNameCheckBox = new JCheckBox(""); m_RemoveFilterNameCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); m_RemoveFilterNameLabel = new JLabel("Remove filter classnames"); m_RemoveFilterNameLabel.setDisplayedMnemonic('R'); m_RemoveFilterNameLabel.setLabelFor(m_RemoveFilterNameCheckBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_RemoveFilterNameLabel); panel2.add(m_RemoveFilterNameCheckBox); panel.add(panel2); // Advanced setup m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); m_ResultMatrixEditor = new GenericObjectEditor(true); m_ResultMatrixEditor.setClassType(ResultMatrix.class); m_ResultMatrixEditor.setValue(m_ResultMatrix); m_ResultMatrixEditor.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { // user selected different class? if (!m_ResultMatrix.getClass().equals(m_ResultMatrixEditor.getValue().getClass())) { // if it's the preferred class, then automaticallly use the Experimenter defaults if (m_ResultMatrixEditor .getValue() .getClass() .equals(ExperimenterDefaults.getOutputFormat().getClass())) { m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); m_ResultMatrixEditor.setValue(ExperimenterDefaults.getOutputFormat()); } else { m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue(); } setData(); } repaint(); } }); ((GenericObjectEditor.GOEPanel) m_ResultMatrixEditor.getCustomEditor()) .addOkListener( new ActionListener() { public void actionPerformed(ActionEvent e) { m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue(); setData(); } }); m_ResultMatrixPanel = new PropertyPanel(m_ResultMatrixEditor, false); m_ResultMatrixLabel = new JLabel("Advanced setup"); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_ResultMatrixLabel); panel2.add(m_ResultMatrixPanel); panel.add(panel2); // Buttons panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(panel, BorderLayout.SOUTH); m_CancelButton = new JButton("Cancel"); m_CancelButton.setMnemonic('C'); m_CancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { m_Result = CANCEL_OPTION; setVisible(false); } }); m_OkButton = new JButton("OK"); m_OkButton.setMnemonic('O'); m_OkButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { getData(); m_Result = APPROVE_OPTION; setVisible(false); } }); panel.add(m_OkButton); panel.add(m_CancelButton); // default button getRootPane().setDefaultButton(m_OkButton); // initial layout (to get widths and heights) pack(); // adjust dimensions m_MeanPrecLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_MeanPrecLabel.getHeight())); m_MeanPrecSpinner.setPreferredSize( new Dimension(m_MeanPrecSpinner.getWidth() * 3, m_MeanPrecSpinner.getHeight())); m_StdDevPrecLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_StdDevPrecLabel.getHeight())); m_StdDevPrecSpinner.setPreferredSize( new Dimension(m_StdDevPrecSpinner.getWidth() * 3, m_StdDevPrecSpinner.getHeight())); m_OutputFormatLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_OutputFormatLabel.getHeight())); m_ShowAverageLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ShowAverageLabel.getHeight())); m_ResultMatrixLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ResultMatrixLabel.getHeight())); m_ResultMatrixPanel.setPreferredSize( new Dimension( (int) (m_ResultMatrixPanel.getWidth() * 1.5), m_ResultMatrixPanel.getHeight())); // final layout pack(); }
private JPanel pnlContenido() { // contenido subpanel 1 lblTorre = new JLabel("Torre"); lblPiso = new JLabel("Piso"); lblPlaca = new JLabel("Placa"); lblTelefono = new JLabel("Teléfono"); lblCitofono = new JLabel("Citófono"); txtPlaca = new JTextField(); txtCitofono = new JTextField(); txtTelefono = new JTextField(); mdlTorre = new DefaultComboBoxModel<>(); cbxTorre = new JComboBox<>(mdlTorre); cbxTorre.addItemListener(new EventosComboBox()); mdlPiso = new SpinnerNumberModel(1, 1, 1, 1); spnPiso = new JSpinner(mdlPiso); btnAgregar = new JButton("Agregar"); btnCancelar = new JButton("Cancelar"); btnAgregar.setActionCommand(AGREGAR); btnCancelar.setActionCommand(CANCELAR); btnAgregar.addActionListener(this); btnCancelar.addActionListener(this); ImageIcon iconAgregar = new ImageIcon(getClass().getResource("/conjunto/views/icons/check.png")); Image imgAgregar = iconAgregar.getImage().getScaledInstance(-1, 22, Image.SCALE_SMOOTH); iconAgregar.setImage(imgAgregar); ImageIcon iconCancelar = new ImageIcon(getClass().getResource("/conjunto/views/icons/denied.png")); Image imgCancelar = iconCancelar.getImage().getScaledInstance(-1, 22, Image.SCALE_SMOOTH); iconCancelar.setImage(imgCancelar); btnAgregar.setIcon(iconAgregar); btnCancelar.setIcon(iconCancelar); Dimension lbls = new Dimension(80, 27); Dimension txts = new Dimension(150, 27); Dimension btns = new Dimension(100, 30); lblTorre.setPreferredSize(lbls); lblPiso.setPreferredSize(lbls); lblPlaca.setPreferredSize(lbls); lblTelefono.setPreferredSize(lbls); lblCitofono.setPreferredSize(lbls); cbxTorre.setPreferredSize(txts); spnPiso.setPreferredSize(txts); txtPlaca.setPreferredSize(txts); txtCitofono.setPreferredSize(txts); txtTelefono.setPreferredSize(txts); btnCancelar.setPreferredSize(btns); btnAgregar.setPreferredSize(btns); JPanel pnl = new JPanel(); pnl.setBorder(BorderFactory.createEtchedBorder()); pnl.setLayout(new FlowLayout(FlowLayout.CENTER)); pnl.add(lblTorre); pnl.add(cbxTorre); pnl.add(lblPiso); pnl.add(spnPiso); pnl.add(lblPlaca); pnl.add(txtPlaca); pnl.add(lblCitofono); pnl.add(txtCitofono); pnl.add(lblTelefono); pnl.add(txtTelefono); pnl.add(btnCancelar); pnl.add(btnAgregar); return pnl; }
public LingDisplay(final Ling.StoredGraphs storedGraphs) { this.storedGraphs = storedGraphs; if (storedGraphs.getNumGraphs() == 0) { workbench = new GraphWorkbench(); } else { workbench = new GraphWorkbench(storedGraphs.getGraph(0)); } subsetIndices = getStableIndices(storedGraphs); final SpinnerNumberModel model = new SpinnerNumberModel(subsetIndices.size() == 0 ? 0 : 1, 0, subsetIndices.size(), 1); model.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { int index = model.getNumber().intValue(); workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1))); } }); spinner = new JSpinner(); subsetCombo = new JComboBox(new String[] {"Show Stable", "Show Unstable", "Show All"}); subsetCombo.setSelectedItem("Show Stable"); spinner.setModel(model); totalLabel = new JLabel(" of " + subsetIndices.size()); subsetCombo.setMaximumSize(subsetCombo.getPreferredSize()); subsetCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { resetDisplay(); } }); spinner.setPreferredSize(new Dimension(50, 20)); spinner.setMaximumSize(spinner.getPreferredSize()); Box b = Box.createVerticalBox(); Box b1 = Box.createHorizontalBox(); // b1.add(Box.createHorizontalGlue()); // b1.add(Box.createHorizontalStrut(10)); b1.add(subsetCombo); b1.add(Box.createHorizontalGlue()); b1.add(new JLabel("DAG ")); b1.add(spinner); b1.add(totalLabel); b.add(b1); Box b2 = Box.createHorizontalBox(); JPanel graphPanel = new JPanel(); graphPanel.setLayout(new BorderLayout()); JScrollPane jScrollPane = new JScrollPane(workbench); // jScrollPane.setPreferredSize(new Dimension(400, 400)); graphPanel.add(jScrollPane); // graphPanel.setBorder(new TitledBorder("DAG")); b2.add(graphPanel); b.add(b2); setLayout(new BorderLayout()); // add(menuBar(), BorderLayout.NORTH); add(b, BorderLayout.CENTER); }
/** Construct a new font selector. */ public FontSelector() { Dimension d; // Widgets are laid out horizontally. setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); // Set up font family names and a 12-point normal font for each family. myFontFamilies = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); // Set up combo box for font family name. myFontFamilyComboBox = new JComboBox(myFontFamilies); d = myFontFamilyComboBox.getPreferredSize(); myFontFamilyComboBox.setMinimumSize(d); myFontFamilyComboBox.setMaximumSize(d); myFontFamilyComboBox.setPreferredSize(d); myFontFamilyComboBox.setEditable(false); myFontFamilyComboBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateSelectedFont(); } } }); add(myFontFamilyComboBox); add(Box.createHorizontalStrut(GAP)); // Set up combo box for font style. myFontStyleComboBox = new JComboBox(new String[] {"Plain", "Bold", "Italic", "Bold Italic"}); d = myFontStyleComboBox.getPreferredSize(); myFontStyleComboBox.setMinimumSize(d); myFontStyleComboBox.setMaximumSize(d); myFontStyleComboBox.setPreferredSize(d); myFontStyleComboBox.setEditable(false); myFontStyleComboBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateSelectedFont(); } } }); add(myFontStyleComboBox); add(Box.createHorizontalStrut(GAP)); // Set up spinner for font size. myFontSizeSpinner = new JSpinner(new SpinnerNumberModel(12, 1, 144, 1)); d = myFontSizeSpinner.getPreferredSize(); myFontSizeSpinner.setMinimumSize(d); myFontSizeSpinner.setMaximumSize(d); myFontSizeSpinner.setPreferredSize(d); myFontSizeSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { updateSelectedFont(); } }); add(myFontSizeSpinner); add(Box.createHorizontalStrut(GAP)); // Set up text sample. myTextSample = new JLabel("Quick Brown Fox 123"); d = myTextSample.getPreferredSize(); myTextSample.setMinimumSize(d); myTextSample.setMaximumSize(d); myTextSample.setPreferredSize(d); add(myTextSample); // Set default selected font. setSelectedFont(new Font("SansSerif", Font.PLAIN, 12)); }
private void jbInit() { setLayout(bolThis); pnlDisplay.setLayout(crdDisplay); cmdSave.setText("Save"); cmdSave.addActionListener(this); cmdUnzoom.addActionListener(this); cmdResetView.addActionListener(this); cmdUnzoom.setText("Unzoom"); cmdResetView.setText("Reset View"); pnlDisplayControls.setLayout(crdDisplayControls); pnlControls.setLayout(gblControls); pnlHistogramControls.setLayout(gblHistogramControls); lblBins.setText("Bins:"); spnBins.setMinimumSize(new Dimension(60, 20)); spnBins.setPreferredSize(new Dimension(60, 20)); spnBins.addChangeListener(this); spnBins.setModel(new SpinnerNumberModel(new Integer(10), new Integer(1), null, new Integer(1))); pnlZoomControls.setLayout(crdZoomControls); pnlZoomable.setLayout(gblZoomable); scpLineChart.setBorder(BorderFactory.createLoweredBevelBorder()); scpHistogram.setBorder(BorderFactory.createLoweredBevelBorder()); scpRaw.setBorder(BorderFactory.createLoweredBevelBorder()); cboDisplayType.addItemListener(this); txaRaw.setEditable(false); pnlHistogram.setYAxisLabel("Count"); cmdMaximize.setText("Maximize"); cmdMaximize.addActionListener(new LandscapePanel_cmdMaximize_actionAdapter(this)); this.add(pnlControls, java.awt.BorderLayout.SOUTH); this.add(pnlDisplay, java.awt.BorderLayout.CENTER); pnlDisplay.add(scpLineChart, "Line Chart"); pnlDisplay.add(scpHistogram, "Histogram"); pnlDisplay.add(scpRaw, "Raw Text"); scpLineChart.getViewport().add(pnlLineChart); scpHistogram.getViewport().add(pnlHistogram); scpRaw.getViewport().add(txaRaw); pnlLineChart.addSelectionListener(this); pnlHistogram.addSelectionListener(this); cboDisplayType.addItem(new DisplayPair<String, Component>("Line Chart", scpLineChart)); cboDisplayType.addItem(new DisplayPair<String, Component>("Histogram", scpHistogram)); cboDisplayType.addItem(new DisplayPair<String, Component>("Raw Text", scpRaw)); pnlZoomControls.add(pnlZoomable, "Zoomable"); pnlZoomControls.add(pnlUnzoomable, "Unzoomable"); pnlZoomable.add( cmdUnzoom, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); pnlZoomable.add( cmdResetView, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); pnlHistogramControls.add( lblBins, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); pnlHistogramControls.add( spnBins, new GridBagConstraints( 2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); pnlDisplayControls.add(pnlLineChartControls, "Line Chart"); pnlDisplayControls.add(pnlHistogramControls, "Histogram"); pnlDisplayControls.add(pnlRawControls, "Raw Text"); pnlControls.add( pnlZoomControls, new GridBagConstraints( 1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); pnlControls.add( cboDisplayType, new GridBagConstraints( 0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0)); pnlControls.add( pnlDisplayControls, new GridBagConstraints( 3, 0, 1, 2, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlControls.add( cmdMaximize, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); pnlControls.add( cmdSave, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); }
@Override public Component getComponent() { if (dockableComponent == null) { JScrollPane scrollPane = new ExtendedJScrollPane(this); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(null); dockableComponent = new JPanel(new BorderLayout()); JPanel toolBarPanel = new JPanel(new BorderLayout()); ViewToolBar toolBar = new ViewToolBar(); JToggleButton toggleExpertModeButton = mainFrame.TOGGLE_EXPERT_MODE_ACTION.createToggleButton(); toggleExpertModeButton.setText(null); toolBar.add(toggleExpertModeButton); Action infoOperatorAction = new InfoOperatorAction() { private static final long serialVersionUID = 6758272768665592429L; @Override protected Operator getOperator() { return mainFrame.getFirstSelectedOperator(); } }; toolBar.add(infoOperatorAction); JToggleButton enableOperatorButton = new ToggleActivationItem(mainFrame.getActions()).createToggleButton(); enableOperatorButton.setText(null); toolBar.add(enableOperatorButton); Action renameOperatorAction = new ResourceAction(true, "rename_in_processrenderer") { { setCondition(OPERATOR_SELECTED, MANDATORY); } private static final long serialVersionUID = -3104160320178045540L; @Override public void actionPerformed(ActionEvent e) { Operator operator = mainFrame.getFirstSelectedOperator(); String name = SwingTools.showInputDialog("rename_operator", operator.getName()); if (name != null && name.length() > 0) { operator.rename(name); } } }; toolBar.add(renameOperatorAction); toolBar.add(new DeleteOperatorAction()); breakpointButton.addToToolBar(toolBar); // toolBar.add(mainFrame.getActions().MAKE_DIRTY_ACTION); toolBarPanel.add(toolBar, BorderLayout.NORTH); JPanel headerPanel = new JPanel(); headerPanel.setBackground(SwingTools.LIGHTEST_BLUE); headerPanel.add(headerLabel); headerPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY)); toolBarPanel.add(headerPanel, BorderLayout.SOUTH); dockableComponent.add(toolBarPanel, BorderLayout.NORTH); dockableComponent.add(scrollPane, BorderLayout.CENTER); // compatibility level and warnings JPanel southPanel = new JPanel(new BorderLayout()); southPanel.add(expertModeHintLabel, BorderLayout.CENTER); compatibilityLabel.setLabelFor(compatibilityLevelSpinner); compatibilityLevelSpinner.setPreferredSize( new Dimension(80, (int) compatibilityLevelSpinner.getPreferredSize().getHeight())); compatibilityPanel.add(compatibilityLabel); compatibilityPanel.add(compatibilityLevelSpinner); southPanel.add(compatibilityPanel, BorderLayout.SOUTH); dockableComponent.add(southPanel, BorderLayout.SOUTH); } return dockableComponent; }
public void setPreferredWidth(int width) { spinner.setPreferredSize(new Dimension(width, spinner.getPreferredSize().height)); }
private JPanel createAutoGeneratedIDPanel() { autoGeneratedIDPanel = new JPanel(); autoGeneratedIDPanel.setLayout(new FlowLayout(FlowLayout.LEADING)); autoGeneratedIDPanel.setBorder(new TitledBorder("Auto-generated ID")); JPanel interiorPanel = new JPanel(new BorderLayout(32, 0)); interiorPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 0, 0)); // Left panel - radio buttons JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); iterativeButton = new JRadioButton("Numeric (iterative)"); uniqueIdButton = new JRadioButton("Globally unique"); final Class<? extends AutoIDGenerator> autoIDGenCls = EntityCreationPreferences.getAutoIDGeneratorClass(); iterativeButton.setSelected(autoIDGenCls.equals(IterativeAutoIDGenerator.class)); uniqueIdButton.setSelected(autoIDGenCls.equals(UniqueIdGenerator.class)); ButtonGroup group = new ButtonGroup(); group.add(iterativeButton); group.add(uniqueIdButton); iterativeButton.addActionListener(this); uniqueIdButton.addActionListener(this); leftPanel.add(iterativeButton); leftPanel.add(uniqueIdButton); leftPanel.add(Box.createVerticalGlue()); // Center panel - random group of components JPanel centerPanel = new JPanel(); centerPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); // Prefix label c.gridx = 0; c.gridy = 0; c.insets = new Insets(0, 0, 5, 0); c.anchor = GridBagConstraints.LINE_END; prefixLabel = new JLabel("Prefix: "); centerPanel.add(prefixLabel, c); // Prefix text field c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDPrefix = new JTextField(); autoIDPrefix.setText(EntityCreationPreferences.getPrefix()); autoIDPrefix.setColumns(30); centerPanel.add(autoIDPrefix, c); // Suffix label c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_END; suffixLabel = new JLabel("Suffix: "); centerPanel.add(suffixLabel, c); // Suffix text field c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDSuffix = new JTextField(); autoIDSuffix.setText(EntityCreationPreferences.getSuffix()); autoIDSuffix.setColumns(30); centerPanel.add(autoIDSuffix, c); // Digit count label c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_END; digitCountLabel = new JLabel("Digit count: "); centerPanel.add(digitCountLabel, c); // Digit count spinner c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.FIRST_LINE_START; c.weightx = 0.5; autoIDDigitCount = new JSpinner(new SpinnerNumberModel(6, 0, 255, 1)); autoIDDigitCount.setValue(EntityCreationPreferences.getAutoIDDigitCount()); autoIDDigitCount.setPreferredSize(new Dimension(100, 20)); centerPanel.add(autoIDDigitCount, c); // Start label c.gridx = 0; c.gridy = 3; c.weightx = 0; c.anchor = GridBagConstraints.LINE_END; startLabel = new JLabel("Start: "); startLabel.setEnabled(iterativeButton.isSelected()); centerPanel.add(startLabel, c); // Start spinner c.gridx = 1; c.gridy = 3; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDStart = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); autoIDStart.setPreferredSize(new Dimension(100, 20)); autoIDStart.setValue(EntityCreationPreferences.getAutoIDStart()); autoIDStart.setEnabled(iterativeButton.isSelected()); autoIDStart.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent event) { if ((Integer) autoIDEnd.getValue() != -1 && (Integer) autoIDEnd.getValue() <= (Integer) autoIDStart.getValue()) { autoIDEnd.setValue(autoIDStart.getValue()); } } }); centerPanel.add(autoIDStart, c); // End label c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.LINE_END; endLabel = new JLabel("End: "); endLabel.setEnabled(iterativeButton.isSelected()); centerPanel.add(endLabel, c); // End spinner c.gridx = 1; c.gridy = 4; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDEnd = new JSpinner(new SpinnerNumberModel(-1, -1, Integer.MAX_VALUE, 1)); autoIDEnd.setPreferredSize(new Dimension(100, 20)); autoIDEnd.setValue(EntityCreationPreferences.getAutoIDEnd()); autoIDEnd.setEnabled(iterativeButton.isSelected()); autoIDEnd.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent event) { if ((Integer) autoIDEnd.getValue() != -1 && (Integer) autoIDEnd.getValue() <= (Integer) autoIDStart.getValue()) { autoIDStart.setValue(autoIDEnd.getValue()); } } }); centerPanel.add(autoIDEnd, c); // Remember last ID checkbox c.gridx = 1; c.gridy = 5; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 1.0; saveIterativeIds = new JCheckBox("Remember last ID between Prot\u00E9g\u00E9 sessions"); saveIterativeIds.setSelected(EntityCreationPreferences.getSaveAutoIDStart()); saveIterativeIds.setEnabled(iterativeButton.isSelected()); centerPanel.add(saveIterativeIds, c); // Dummy label for spacing purposes c.gridx = 2; c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.weighty = 0; centerPanel.add(new JLabel("")); enableAutoGeneratedIDPanel(autoIDIriFragment.isSelected()); enableLabelCreationPanel(autoIDIriFragment.isSelected()); interiorPanel.add(leftPanel, BorderLayout.LINE_START); interiorPanel.add(centerPanel, BorderLayout.CENTER); autoGeneratedIDPanel.add(interiorPanel); return autoGeneratedIDPanel; }
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(); }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; panEdit = new javax.swing.JPanel(); spnPointValue = new javax.swing.JSpinner(); jLabel5 = new javax.swing.JLabel(); labGwk = new javax.swing.JLabel(); splitButton = new javax.swing.JButton(); badGeomButton = new javax.swing.JToggleButton(); jPanel2 = new javax.swing.JPanel(); badGeomCorrectButton = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); lblPointValue = new javax.swing.JLabel(); lblRoute = new javax.swing.JLabel(); panAdd = new AddPanel(); jLabel3 = new javax.swing.JLabel(); panError = new javax.swing.JPanel(); lblError = new javax.swing.JLabel(); setEnabled(false); setOpaque(false); setLayout(new java.awt.CardLayout()); panEdit.setOpaque(false); panEdit.setLayout(new java.awt.GridBagLayout()); spnPointValue.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 0.0d, 1.0d)); spnPointValue.setEditor(new javax.swing.JSpinner.NumberEditor(spnPointValue, "###")); spnPointValue.setMaximumSize(new java.awt.Dimension(100, 28)); spnPointValue.setMinimumSize(new java.awt.Dimension(100, 28)); spnPointValue.setPreferredSize(new java.awt.Dimension(100, 28)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0); panEdit.add(spnPointValue, gridBagConstraints); jLabel5.setIcon( new javax.swing.ImageIcon( getClass() .getResource( "/de/cismet/cids/custom/objecteditors/wrrl_db_mv/station.png"))); // NOI18N jLabel5.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.jLabel5.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); panEdit.add(jLabel5, gridBagConstraints); labGwk.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); labGwk.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.labGwk.text_1")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 6; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); panEdit.add(labGwk, gridBagConstraints); splitButton.setIcon( new javax.swing.ImageIcon( getClass() .getResource( "/de/cismet/cids/custom/objecteditors/wrrl_db_mv/sql-join-left.png"))); // NOI18N splitButton.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.splitButton.text")); // NOI18N splitButton.setToolTipText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.splitButton.toolTipText")); // NOI18N splitButton.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { splitButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0); panEdit.add(splitButton, gridBagConstraints); badGeomButton.setIcon( new javax.swing.ImageIcon( getClass() .getResource( "/de/cismet/cids/custom/objecteditors/wrrl_db_mv/exclamation.png"))); // NOI18N badGeomButton.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.badGeomButton.text")); // NOI18N badGeomButton.setToolTipText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.badGeomButton.toolTipText")); // NOI18N badGeomButton.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { badGeomButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0); panEdit.add(badGeomButton, gridBagConstraints); jPanel2.setMaximumSize(new java.awt.Dimension(32, 0)); jPanel2.setMinimumSize(new java.awt.Dimension(32, 0)); jPanel2.setOpaque(false); jPanel2.setPreferredSize(new java.awt.Dimension(32, 0)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; panEdit.add(jPanel2, gridBagConstraints); badGeomCorrectButton.setIcon( new javax.swing.ImageIcon( getClass() .getResource( "/de/cismet/cids/custom/objecteditors/wrrl_db_mv/node-delete.png"))); // NOI18N badGeomCorrectButton.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.badGeomCorrectButton.text")); // NOI18N badGeomCorrectButton.setToolTipText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.badGeomCorrectButton.toolTipText")); // NOI18N badGeomCorrectButton.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { badGeomCorrectButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0); panEdit.add(badGeomCorrectButton, gridBagConstraints); jPanel3.setMaximumSize(new java.awt.Dimension(32, 0)); jPanel3.setMinimumSize(new java.awt.Dimension(32, 0)); jPanel3.setOpaque(false); jPanel3.setPreferredSize(new java.awt.Dimension(32, 0)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; panEdit.add(jPanel3, gridBagConstraints); lblPointValue.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); lblPointValue.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.lblPointValue.text_1")); // NOI18N lblPointValue.setBorder(javax.swing.BorderFactory.createEtchedBorder()); lblPointValue.setMaximumSize(new java.awt.Dimension(100, 28)); lblPointValue.setMinimumSize(new java.awt.Dimension(100, 28)); lblPointValue.setPreferredSize(new java.awt.Dimension(100, 28)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0); panEdit.add(lblPointValue, gridBagConstraints); lblRoute.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblRoute.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.lblRoute.text_1")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 0); panEdit.add(lblRoute, gridBagConstraints); add(panEdit, "edit"); panAdd.setOpaque(false); panAdd.setLayout(new java.awt.GridBagLayout()); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.jLabel3.text")); // NOI18N panAdd.add(jLabel3, new java.awt.GridBagConstraints()); add(panAdd, "add"); panError.setOpaque(false); panError.setLayout(new java.awt.GridBagLayout()); lblError.setText( org.openide.util.NbBundle.getMessage( StationEditor.class, "StationEditor.lblError.text")); // NOI18N panError.add(lblError, new java.awt.GridBagConstraints()); add(panError, "error"); } // </editor-fold>//GEN-END:initComponents
void jbInit() throws Exception { this.setResizable(false); // Build headerPanel headerPanel.setBackground(Color.WHITE); headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); header.setFont(new java.awt.Font("Dialog", 0, 20)); header.setForeground(new Color(0, 0, 124)); header.setText(Local.getString("Event")); header.setIcon( new ImageIcon( net.sf.memoranda.ui.EventDialog.class.getResource("resources/icons/event48.png"))); headerPanel.add(header); // Build eventPanel lblTime.setText(Local.getString("Time")); lblTime.setMinimumSize(new Dimension(60, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(10, 10, 5, 10); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(lblTime, gbc); timeSpin.setPreferredSize(new Dimension(60, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.insets = new Insets(10, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(timeSpin, gbc); lblText.setText(Local.getString("Text")); lblText.setMinimumSize(new Dimension(120, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 3; gbc.insets = new Insets(5, 10, 5, 10); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(lblText, gbc); textField.setMinimumSize(new Dimension(375, 24)); textField.setPreferredSize(new Dimension(375, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 6; gbc.insets = new Insets(5, 10, 10, 10); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; eventPanel.add(textField, gbc); // Build RepeatPanel repeatBorder = new TitledBorder(BorderFactory.createLineBorder(Color.gray, 1), Local.getString("Repeat")); // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM // --------------------------------------------------- SimpleDateFormat sdf = new SimpleDateFormat(); sdf = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT); // Build ButtonsPanel okB.setMaximumSize(new Dimension(100, 26)); okB.setMinimumSize(new Dimension(100, 26)); okB.setPreferredSize(new Dimension(100, 26)); okB.setText(Local.getString("Ok")); okB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { okB_actionPerformed(e); } }); this.getRootPane().setDefaultButton(okB); cancelB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cancelB_actionPerformed(e); } }); cancelB.setText(Local.getString("Cancel")); cancelB.setPreferredSize(new Dimension(100, 26)); cancelB.setMinimumSize(new Dimension(100, 26)); cancelB.setMaximumSize(new Dimension(100, 26)); buttonsPanel.add(okB); buttonsPanel.add(cancelB); // Finally build the Dialog topPanel.add(headerPanel, BorderLayout.NORTH); topPanel.add(eventPanel, BorderLayout.SOUTH); GridBagConstraints gbc_repeatPanel = new GridBagConstraints(); gbc_repeatPanel.insets = new Insets(0, 0, 0, 5); gbc_repeatPanel.gridx = 1; gbc_repeatPanel.gridy = 3; eventPanel.add(repeatPanel, gbc_repeatPanel); repeatPanel.setBorder(repeatBorder); noRepeatRB.setMaximumSize(new Dimension(80, 35)); noRepeatRB.setSelected(true); noRepeatRB.setText(Local.getString("No repeat")); noRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { noRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 4; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; repeatPanel.add(noRepeatRB, gbc); dailyRepeatRB.setActionCommand("daily"); dailyRepeatRB.setText(Local.getString("Every")); dailyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { dailyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(dailyRepeatRB, gbc); daySpin.setPreferredSize(new Dimension(50, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(daySpin, gbc); lblDays.setText(Local.getString("day(s)")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.gridwidth = 2; gbc.insets = new Insets(5, 5, 5, 40); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblDays, gbc); lblSince.setText(Local.getString("Since")); lblSince.setMinimumSize(new Dimension(70, 16)); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(lblSince, gbc); startDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreStartChanged) return; ignoreStartChanged = true; Date sd = (Date) startDate.getModel().getValue(); Date ed = (Date) endDate.getModel().getValue(); // Commented out, value was resetted to endDate !!! if (sd.after(ed)) { endDate.getModel().setValue(sd); ed = sd; } startCalFrame.cal.set(new CalendarDate(sd)); ignoreStartChanged = false; } }); startDate.setPreferredSize(new Dimension(80, 24)); startDate.setEditor(new JSpinner.DateEditor(startDate, sdf.toPattern())); // --------------------------------------------------- gbc = new GridBagConstraints(); gbc.gridx = 5; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(startDate, gbc); setStartDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setStartDateB_actionPerformed(e); } }); setStartDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setStartDateB.setText(""); setStartDateB.setPreferredSize(new Dimension(24, 24)); gbc = new GridBagConstraints(); gbc.gridx = 6; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setStartDateB, gbc); weeklyRepeatRB.setActionCommand("weekly"); weeklyRepeatRB.setText(Local.getString("Every")); weeklyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { weeklyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(weeklyRepeatRB, gbc); weekdaysCB.setPreferredSize(new Dimension(100, 25)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 2; gbc.insets = new Insets(5, 0, 5, 40); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(weekdaysCB, gbc); enableEndDateCB.setHorizontalAlignment(SwingConstants.RIGHT); enableEndDateCB.setText(Local.getString("Till")); enableEndDateCB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { enableEndDateCB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(enableEndDateCB, gbc); endDate.setPreferredSize(new Dimension(80, 24)); // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM // --------------------------------------------------- endDate.setEditor(new JSpinner.DateEditor(endDate, sdf.toPattern())); // --------------------------------------------------- endDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreEndChanged) return; ignoreEndChanged = true; Date sd = (Date) startDate.getModel().getValue(); Date ed = (Date) endDate.getModel().getValue(); if (sd.after(ed)) { endDate.getModel().setValue(sd); ed = sd; } endCalFrame.cal.set(new CalendarDate(ed)); ignoreEndChanged = false; } }); // working days workingDaysOnlyCB.setText(Local.getString("Working days only")); workingDaysOnlyCB.setHorizontalAlignment(SwingConstants.RIGHT); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 3; gbc.gridwidth = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(workingDaysOnlyCB, gbc); // ------------------------------------- gbc = new GridBagConstraints(); gbc.gridx = 5; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(endDate, gbc); setEndDateB.setMinimumSize(new Dimension(24, 24)); setEndDateB.setPreferredSize(new Dimension(24, 24)); setEndDateB.setText(""); setEndDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setEndDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setEndDateB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 6; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setEndDateB, gbc); monthlyRepeatRB.setActionCommand("daily"); monthlyRepeatRB.setText(Local.getString("Every")); monthlyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { monthlyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(monthlyRepeatRB, gbc); dayOfMonthSpin.setPreferredSize(new Dimension(50, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(dayOfMonthSpin, gbc); lblDoM.setText(Local.getString("day of month")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblDoM, gbc); yearlyRepeatRB.setActionCommand("yearly"); yearlyRepeatRB.setText(Local.getString("Yearly")); yearlyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { yearlyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 5; gbc.insets = new Insets(5, 5, 5, 10); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(yearlyRepeatRB, gbc); // Exception label lblExceptions.setText("Specific days to not recur on (exceptions)"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; gbc.insets = new Insets(5, 5, 5, 10); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblExceptions, gbc); // Exception text field exceptionDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreExceptionChanged) return; ignoreExceptionChanged = true; Date exd = (Date) exceptionDate.getModel().getValue(); exceptionCalFrame.cal.set(new CalendarDate(exd)); ignoreExceptionChanged = false; } }); exceptionDate.setPreferredSize(new Dimension(80, 24)); exceptionDate.setEditor(new JSpinner.DateEditor(exceptionDate, sdf.toPattern())); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.insets = new Insets(5, 5, 5, 4); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(exceptionDate, gbc); // Exception Calendar Button setExceptionDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setExceptionDateB_actionPerformed(e); } }); setExceptionDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setExceptionDateB.setText(""); setExceptionDateB.setPreferredSize(new Dimension(24, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.insets = new Insets(5, 0, 5, 4); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setExceptionDateB, gbc); // Exception date add button addExceptionDate.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { addExceptionDate_actionPerformed(e); } }); addExceptionDate.setText("Add"); addExceptionDate.setPreferredSize(new Dimension(80, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.insets = new Insets(2, 36, 5, 2); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(addExceptionDate, gbc); // Exception List exceptionPane.setPreferredSize(new Dimension(136, 96)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.gridwidth = 4; gbc.gridheight = 4; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(exceptionPane, gbc); // Exception date remove button removeExceptionDate.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { removeExceptionDate_actionPerformed(e); } }); removeExceptionDate.setText("Remove"); removeExceptionDate.setPreferredSize(new Dimension(80, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 7; gbc.insets = new Insets(2, 36, 5, 2); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(removeExceptionDate, gbc); repeatRBGroup.add(noRepeatRB); repeatRBGroup.add(dailyRepeatRB); repeatRBGroup.add(weeklyRepeatRB); repeatRBGroup.add(monthlyRepeatRB); repeatRBGroup.add(yearlyRepeatRB); bottomPanel.add(buttonsPanel, BorderLayout.SOUTH); this.getContentPane().add(topPanel, BorderLayout.NORTH); this.getContentPane().add(bottomPanel, BorderLayout.SOUTH); // Do final things... startCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreStartChanged) return; startDate.getModel().setValue(startCalFrame.cal.get().getCalendar().getTime()); } }); endCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreEndChanged) return; endDate.getModel().setValue(endCalFrame.cal.get().getCalendar().getTime()); } }); exceptionCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreExceptionChanged) return; exceptionDate.getModel().setValue(exceptionCalFrame.cal.get().getCalendar().getTime()); } }); disableElements(); ((JSpinner.DateEditor) timeSpin.getEditor()).getFormat().applyPattern("HH:mm"); enableEndDateCB_actionPerformed(null); }