Java Code Examples for javax.swing.JSpinner#setEditor()
The following examples show how to use
javax.swing.JSpinner#setEditor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComboBoxSearchField.java From sc2gears with Apache License 2.0 | 6 votes |
/** * Creates a new ComboBoxSearchField. * @param id id of the search field * @param valueVector vector of values to add to the combo box (null values are not allowed!) */ public ComboBoxSearchField( final Id id, final Vector< Object > valueVector, final boolean showMinOccurence ) { super( id ); comboBox = new JComboBox<>( valueVector ); comboBox.setRenderer( new BaseLabelListCellRenderer< Object >() { @Override public Icon getIcon( final Object value ) { return ComboBoxSearchField.this.getIcon( value ); } } ); comboBox.setPreferredSize( new Dimension( 100, comboBox.getMinimumSize().height ) ); uiComponent.add( comboBox ); if ( showMinOccurence ) { minOccurrenceSpinner = new JSpinner( new SpinnerNumberModel( 1, 1, 999, 1 ) ); uiComponent.add( new JLabel( Language.getText( "module.repSearch.tab.filters.name.minOccurrenceText" ) ) ); minOccurrenceSpinner.setEditor( new JSpinner.NumberEditor( minOccurrenceSpinner ) ); minOccurrenceSpinner.setMaximumSize( new Dimension( 50, minOccurrenceSpinner.getPreferredSize().height ) ); uiComponent.add( minOccurrenceSpinner ); } }
Example 2
Source File: JSpinField.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
/** * JSpinField constructor with given minimum and maximum vaues and initial * value 0. */ public JSpinField(int min, int max) { super(); setName("JSpinField"); this.min = min; if (max < min) max = min; this.max = max; value = 0; if (value < min) value = min; if (value > max) value = max; darkGreen = new Color(0, 150, 0); setLayout(new BorderLayout()); textField = new JTextField(); textField.addCaretListener(this); textField.addActionListener(this); textField.setHorizontalAlignment(SwingConstants.RIGHT); textField.setBorder(BorderFactory.createEmptyBorder()); textField.setText(Integer.toString(value)); textField.addFocusListener(this); spinner = new JSpinner() { private static final long serialVersionUID = -6287709243342021172L; private JTextField textField = new JTextField(); public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); return new Dimension(size.width, textField.getPreferredSize().height); } }; spinner.setEditor(textField); spinner.addChangeListener(this); // spinner.setSize(spinner.getWidth(), textField.getHeight()); add(spinner, BorderLayout.CENTER); }
Example 3
Source File: JSpinnerJavaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
private JSpinner createNumberSpinner(Calendar calendar) { int currentYear = calendar.get(Calendar.YEAR); SpinnerModel yearModel = new SpinnerNumberModel(currentYear, currentYear - 100, currentYear + 100, 1); JSpinner numberSpinner = new JSpinner(yearModel); numberSpinner.setEditor(new JSpinner.NumberEditor(numberSpinner, "#")); numberSpinner.setName("number-spinner"); return numberSpinner; }
Example 4
Source File: JSpinnerJavaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
private JSpinner createDateSpinner(Calendar calendar) { Date initDate = calendar.getTime(); calendar.add(Calendar.YEAR, -100); Date earliestDate = calendar.getTime(); calendar.add(Calendar.YEAR, 200); Date latestDate = calendar.getTime(); SpinnerDateModel spinnerDateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR); JSpinner dateSpinner = new JSpinner(spinnerDateModel); dateSpinner.setEditor(new JSpinner.DateEditor(dateSpinner, "MM/yyyy")); dateSpinner.setName("date-spinner"); return dateSpinner; }
Example 5
Source File: JMonthChooser.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
/** * JMonthChooser constructor with month spinner parameter. * * @param hasSpinner * true, if the month chooser should have a spinner component */ public JMonthChooser(boolean hasSpinner) { super(); setName("JMonthChooser"); this.hasSpinner = hasSpinner; setLayout(new BorderLayout()); comboBox = new JComboBox(); comboBox.addItemListener(this); // comboBox.addPopupMenuListener(this); locale = Locale.getDefault(); initNames(); if (hasSpinner) { spinner = new JSpinner() { private static final long serialVersionUID = 1L; private JTextField textField = new JTextField(); public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); return new Dimension(size.width, textField .getPreferredSize().height); } }; spinner.addChangeListener(this); spinner.setEditor(comboBox); comboBox.setBorder(new EmptyBorder(0, 0, 0, 0)); updateUI(); add(spinner, BorderLayout.WEST); } else { add(comboBox, BorderLayout.WEST); } initialized = true; setMonth(Calendar.getInstance().get(Calendar.MONTH)); }
Example 6
Source File: PlanManager.java From cropplanning with GNU General Public License v3.0 | 5 votes |
@Override protected void buildContentsPanel() { cmboPlanList = new JComboBox(); cmboPlanList.setEditable(true); cmboPlanList.addActionListener(this); spnYear = new JSpinner(); SpinnerDateModel spnMod = new SpinnerDateModel(); spnMod.setCalendarField( Calendar.YEAR ); spnYear.setModel( spnMod ); spnYear.setEditor( new JSpinner.DateEditor( spnYear, "yyyy" ) ); spnYear.setPreferredSize( new Dimension( 70, spnYear.getPreferredSize().height )); tfldDesc = new JTextField( 20 ); JPanel jplCont = new JPanel( new MigLayout( "gapy 0px!, insets 2px", "[align right][]") ); jplCont.add( new JLabel( "Plan:" ) ); jplCont.add( cmboPlanList, "wrap" ); jplCont.add( new JLabel( "Year:" ) ); jplCont.add( spnYear, "wrap" ); jplCont.add( new JLabel( "Description:" ) ); jplCont.add( tfldDesc, "wrap" ); jplCont.setBorder( BorderFactory.createEmptyBorder( 10, 10, 0, 10)); contentsPanelBuilt = true; add( jplCont ); }
Example 7
Source File: ComparePanel.java From mvisc with GNU General Public License v3.0 | 5 votes |
public ComparePanel() { dateSpinner = new JSpinner( new SpinnerDateModel() ); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(dateSpinner, "dd.MM.yyyy"); dateSpinner.setEditor(dateEditor); dateSpinner.setValue(new Date()); timeSpinner = new JSpinner( new SpinnerDateModel() ); JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss"); timeSpinner.setEditor(timeEditor); timeSpinner.setValue(new Date()); }
Example 8
Source File: ArrayInspector.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Creates the GUI. */ protected void createGUI() { setSize(400, 300); setContentPane(new JPanel(new BorderLayout())); scrollpane = new JScrollPane(tables[0]); if(tables.length>1) { // create spinner SpinnerModel model = new SpinnerNumberModel(0, 0, tables.length-1, 1); spinner = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner); editor.getTextField().setFont(tables[0].getFont()); spinner.setEditor(editor); spinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { int i = ((Integer) spinner.getValue()).intValue(); scrollpane.setViewportView(tables[i]); } }); Dimension dim = spinner.getMinimumSize(); spinner.setMaximumSize(dim); getContentPane().add(scrollpane, BorderLayout.CENTER); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); toolbar.add(new JLabel(" index ")); //$NON-NLS-1$ toolbar.add(spinner); toolbar.add(Box.createHorizontalGlue()); getContentPane().add(toolbar, BorderLayout.NORTH); } else { scrollpane.createHorizontalScrollBar(); getContentPane().add(scrollpane, BorderLayout.CENTER); } }
Example 9
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 5 votes |
private void addSpeedMultiplier(JToolBar mainToolBar, Insets margin) { SpinnerNumberModel numberModel = new SpinnerModel(Simulation.DEFAULT_REAL_TIME_FACTOR, Simulation.MIN_REAL_TIME_FACTOR, Simulation.MAX_REAL_TIME_FACTOR, 1); spinner = new JSpinner(numberModel); // show up to 6 decimal places JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor(spinner,"0.######"); spinner.setEditor(numberEditor); // make sure spinner TextField is no wider than 9 digits int diff = ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField().getPreferredSize().width - getPixelWidthOfString_ForFont("9", spinner.getFont()) * 9; Dimension dim = spinner.getPreferredSize(); dim.width -= diff; spinner.setPreferredSize(dim); spinner.addChangeListener(new ChangeListener() { @Override public void stateChanged( ChangeEvent e ) { Double val = (Double)((JSpinner)e.getSource()).getValue(); if (MathUtils.near(val, sim.getSimulation().getRealTimeFactor())) return; NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); DecimalFormat df = (DecimalFormat)nf; df.applyPattern("0.######"); KeywordIndex kw = InputAgent.formatArgs("RealTimeFactor", df.format(val)); InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw)); controlStartResume.requestFocusInWindow(); } }); spinner.setToolTipText(formatToolTip("Speed Multiplier (< and > keys)", "Target ratio of simulation time to wall clock time when Real Time mode is selected.")); spinner.setEnabled(false); mainToolBar.add( spinner ); }
Example 10
Source File: ArrayPanel.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Creates the GUI. */ protected void createGUI() { this.removeAll(); // remove old elements Paco: be careful with this. If you use the ArrayPanel as a normal JPanel // and have added another component, it will be lost! this.setPreferredSize(new Dimension(400, 300)); this.setLayout(new BorderLayout()); scrollpane = new JScrollPane(tables[0]); if(tables.length>1) { // create spinner SpinnerModel model = new SpinnerNumberModel(0, 0, tables.length-1, 1); spinner = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner); editor.getTextField().setFont(tables[0].indexRenderer.getFont()); spinner.setEditor(editor); spinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { int i = ((Integer) spinner.getValue()).intValue(); scrollpane.setViewportView(tables[i]); } }); Dimension dim = spinner.getMinimumSize(); spinner.setMaximumSize(dim); add(scrollpane, BorderLayout.CENTER); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); toolbar.add(new JLabel(" index ")); //$NON-NLS-1$ toolbar.add(spinner); toolbar.add(Box.createHorizontalGlue()); add(toolbar, BorderLayout.NORTH); } else { scrollpane.createHorizontalScrollBar(); add(scrollpane, BorderLayout.CENTER); } this.validate(); // refresh the display }
Example 11
Source File: IOStatPostParser.java From nmonvisualizer with Apache License 2.0 | 5 votes |
protected void addComponents(JPanel content, GridBagConstraints labelConstraints, GridBagConstraints fieldConstraints) { date = new JSpinner(new SpinnerDateModel(new Date(TimeHelper.today()), null, null, Calendar.DAY_OF_WEEK)); date.setEditor(new DateEditor(date, "MMM dd yyyy")); JLabel dateLabel = new JLabel("Date:"); dateLabel.setFont(Styles.LABEL); dateLabel.setHorizontalAlignment(SwingConstants.TRAILING); content.add(dateLabel, labelConstraints); content.add(date, fieldConstraints); }
Example 12
Source File: ManualDownloadBuilder.java From raccoon4 with Apache License 2.0 | 5 votes |
public ManualDownloadBuilder() { ActionLocalizer al = Messages.getLocalizer(); packId = new JTextField(25); packId.setMargin(new Insets(2, 2, 2, 2)); versionCode = new JSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1)); versionCode.setEditor(new JSpinner.NumberEditor(versionCode, "#")); offerType = new JSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1)); paid = new JRadioButton(al.localize("paid_app")); free = new JRadioButton(al.localize("free_app")); }
Example 13
Source File: RepositoryLoginDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected void init( final boolean loginForPublish ) { setTitle( Messages.getInstance().getString( "RepositoryLoginDialog.Title" ) ); this.loginForPublish = loginForPublish; urlModel = new DefaultComboBoxModel(); urlCombo = new JComboBox( urlModel ); userField = new JTextField( 25 ); userPasswordField = new JPasswordField(); final SpinnerNumberModel spinnerModel = new SpinnerNumberModel(); spinnerModel.setMinimum( 0 ); spinnerModel.setMaximum( 99999 ); timeoutField = new JSpinner( spinnerModel ); timeoutField.setEditor( new JSpinner.NumberEditor( timeoutField, "#####" ) ); rememberSettings = new JCheckBox( Messages.getInstance().getString( "RepositoryLoginDialog.RememberTheseSettings" ), true ); urlCombo.setEditable( true ); urlCombo.addActionListener( new URLChangeHandler() ); userField.setAction( getConfirmAction() ); userPasswordField.setAction( getConfirmAction() ); super.init(); }
Example 14
Source File: CalendarSpinner.java From Astrosoft with GNU General Public License v2.0 | 4 votes |
private void createSpinner(){ SpinnerModel model = new SpinnerDateModel(); spinner = new JSpinner(model); spinner.setPreferredSize(spinnerSize); editor = new JSpinner.DateEditor(spinner, dateFormat); spinner.setEditor(editor); spinner.addChangeListener(new ChangeListener(){ public void stateChanged(ChangeEvent e) { selectionChanged(e); } }); }
Example 15
Source File: PreferencesDialog.java From gpx-animator with Apache License 2.0 | 4 votes |
public PreferencesDialog(final JFrame owner) { super(owner, true); final ResourceBundle resourceBundle = Preferences.getResourceBundle(); setTitle(resourceBundle.getString("ui.dialog.preferences.title")); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); final FileSelector tileCachePathSelector = new FileSelector(DIRECTORIES_ONLY) { private static final long serialVersionUID = 7372002778979993241L; @Override protected Type configure(final JFileChooser outputFileChooser) { return Type.OPEN; } }; tileCachePathSelector.setToolTipText(resourceBundle.getString("ui.dialog.preferences.cachepath.tooltip")); final JSpinner tileCacheTimeLimitSpinner = new JSpinner(); tileCacheTimeLimitSpinner.setToolTipText(resourceBundle.getString("ui.dialog.preferences.cachetimelimit.tooltip")); tileCacheTimeLimitSpinner.setModel(new DurationSpinnerModel()); tileCacheTimeLimitSpinner.setEditor(new DurationEditor(tileCacheTimeLimitSpinner)); final JPanel trackColorPanel = new JPanel(new BorderLayout()); final JCheckBox trackColorRandom = new JCheckBox(resourceBundle.getString("ui.dialog.preferences.track.color.random")); final ColorSelector trackColorSelector = new ColorSelector(); trackColorRandom.setSelected(Preferences.getTrackColorRandom()); trackColorSelector.setColor(Preferences.getTrackColorDefault()); trackColorSelector.setEnabled(!Preferences.getTrackColorRandom()); trackColorRandom.addActionListener((event) -> trackColorSelector.setEnabled(!trackColorRandom.isSelected())); trackColorPanel.add(trackColorRandom, BorderLayout.LINE_START); trackColorPanel.add(trackColorSelector, BorderLayout.CENTER); final JButton cancelButton = new JButton(resourceBundle.getString("ui.dialog.preferences.button.cancel")); cancelButton.addActionListener(e -> SwingUtilities.invokeLater(() -> { setVisible(false); dispose(); })); final JButton saveButton = new JButton(resourceBundle.getString("ui.dialog.preferences.button.save")); saveButton.addActionListener(e -> SwingUtilities.invokeLater(() -> { Preferences.setTileCacheDir(tileCachePathSelector.getFilename()); Preferences.setTileCacheTimeLimit((Long) tileCacheTimeLimitSpinner.getValue()); Preferences.setTrackColorRandom(trackColorRandom.isSelected()); Preferences.setTrackColorDefault(trackColorSelector.getColor()); setVisible(false); dispose(); })); setContentPane(FormBuilder.create() .padding(new EmptyBorder(20, 20, 20, 20)) .columns("right:p, 5dlu, fill:[200dlu, pref]") //NON-NLS .rows("p, 5dlu, p, 5dlu, p, 5dlu, p, 5dlu, p, 5dlu, p, 10dlu, p") //NON-NLS .addSeparator(resourceBundle.getString("ui.dialog.preferences.cache.separator")).xyw(1, 1, 3) .add(resourceBundle.getString("ui.dialog.preferences.cachepath.label")).xy(1, 3) .add(tileCachePathSelector).xy(3, 3) .add(resourceBundle.getString("ui.dialog.preferences.cachetimelimit.label")).xy(1, 5) .add(tileCacheTimeLimitSpinner).xy(3, 5) .addSeparator(resourceBundle.getString("ui.dialog.preferences.track")).xyw(1, 7, 3) .add(resourceBundle.getString("ui.dialog.preferences.track.color")).xy(1, 9) .add(trackColorPanel).xy(3, 9) .addSeparator("").xyw(1, 11, 3) .addBar(cancelButton, saveButton).xyw(1, 13, 3, CellConstraints.RIGHT, CellConstraints.FILL) .build()); tileCachePathSelector.setFilename(Preferences.getTileCacheDir()); tileCacheTimeLimitSpinner.setValue(Preferences.getTileCacheTimeLimit()); pack(); setLocationRelativeTo(owner); }
Example 16
Source File: MetadataPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private JPanel createSettingsPanel(BindingContext bindingContext) { final JLabel datasetLabel = new JLabel("Dataset: "); final JComboBox<MetadataElement> datasetBox = new JComboBox<>(); datasetBox.setRenderer(new ProductNodeListCellRenderer()); JLabel recordLabel = new JLabel("Record: "); recordValueField = new JTextField(7); recordSlider = new JSlider(SwingConstants.HORIZONTAL, 1, 1, 1); recordSlider.setPaintTrack(true); recordSlider.setPaintTicks(true); recordSlider.setPaintLabels(true); configureSilderLabels(recordSlider); JLabel numRecordsLabel = new JLabel("Records / Plot: "); numRecSpinnerModel = new SpinnerNumberModel(1, 1, 1, 1); JSpinner numRecordsSpinner = new JSpinner(numRecSpinnerModel); numRecordsSpinner.setEditor(new JSpinner.NumberEditor(numRecordsSpinner, "#")); final JLabel xFieldLabel = new JLabel("X Field: "); final JComboBox<MetadataAttribute> xFieldBox = new JComboBox<>(); xFieldBox.setRenderer(new ProductNodeListCellRenderer()); final JLabel y1FieldLabel = new JLabel("Y Field: "); final JComboBox<MetadataAttribute> y1FieldBox = new JComboBox<>(); y1FieldBox.setRenderer(new ProductNodeListCellRenderer()); final JLabel y2FieldLabel = new JLabel("Y2 Field: "); final JComboBox<MetadataAttribute> y2FieldBox = new JComboBox<>(); y2FieldBox.setRenderer(new ProductNodeListCellRenderer()); bindingContext.bind(PROP_NAME_METADATA_ELEMENT, datasetBox); bindingContext.bind(PROP_NAME_RECORD_START_INDEX, recordValueField); bindingContext.bind(PROP_NAME_RECORD_START_INDEX, new SliderAdapter(recordSlider)); bindingContext.bind(PROP_NAME_RECORDS_PER_PLOT, numRecordsSpinner); bindingContext.bind(PROP_NAME_FIELD_X, xFieldBox); bindingContext.bind(PROP_NAME_FIELD_Y1, y1FieldBox); bindingContext.bind(PROP_NAME_FIELD_Y2, y2FieldBox); TableLayout layout = new TableLayout(3); JPanel plotSettingsPanel = new JPanel(layout); layout.setTableWeightX(0.0); layout.setTableAnchor(TableLayout.Anchor.NORTHWEST); layout.setTableFill(TableLayout.Fill.HORIZONTAL); layout.setTablePadding(4, 4); layout.setCellWeightX(0, 1, 1.0); layout.setCellColspan(0, 1, 2); plotSettingsPanel.add(datasetLabel); plotSettingsPanel.add(datasetBox); layout.setCellWeightX(1, 1, 0.2); layout.setCellWeightX(1, 2, 0.8); plotSettingsPanel.add(recordLabel); plotSettingsPanel.add(recordValueField); plotSettingsPanel.add(recordSlider); layout.setCellWeightX(2, 1, 1.0); layout.setCellColspan(2, 1, 2); plotSettingsPanel.add(numRecordsLabel); plotSettingsPanel.add(numRecordsSpinner); layout.setCellWeightX(3, 1, 1.0); layout.setCellColspan(3, 1, 2); plotSettingsPanel.add(xFieldLabel); plotSettingsPanel.add(xFieldBox); layout.setCellWeightX(4, 1, 1.0); layout.setCellColspan(4, 1, 2); plotSettingsPanel.add(y1FieldLabel); plotSettingsPanel.add(y1FieldBox); layout.setCellWeightX(5, 1, 1.0); layout.setCellColspan(5, 1, 2); plotSettingsPanel.add(y2FieldLabel); plotSettingsPanel.add(y2FieldBox); updateSettings(); updateUiState(); return plotSettingsPanel; }
Example 17
Source File: ProxyLogic.java From raccoon4 with Apache License 2.0 | 4 votes |
@Override protected JPanel assemble() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); username = new JTextField(20); username.setMargin(new Insets(2, 2, 2, 2)); password = new JPasswordField(20); password.setMargin(new Insets(2, 2, 2, 2)); server = new JTextField(20); server.setMargin(new Insets(2, 2, 2, 2)); port = new JSpinner(new SpinnerNumberModel(3218, 1, 65535, 1)); port.setEditor(new JSpinner.NumberEditor(port, "#")); HyperTextPane about = new HyperTextPane( Messages.getString("ProxyLogic.about")).withWidth(500) .withTransparency(); username.addActionListener(this); password.addActionListener(this); username.addCaretListener(this); password.addCaretListener(this); server.addCaretListener(this); GridBagConstraints gbc = new GridBagConstraints(); JPanel container = new JPanel(); container.setLayout(new GridBagLayout()); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets.left = 5; gbc.insets.bottom = 3; container.add(new JLabel(Messages.getString("ProxyLogic.server")), gbc); gbc.gridx = 1; gbc.gridy = 0; container.add(server, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets.left = 5; gbc.insets.bottom = 3; container.add(new JLabel(Messages.getString("ProxyLogic.port")), gbc); gbc.gridx = 1; gbc.gridy = 1; container.add(port, gbc); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets.left = 5; gbc.insets.bottom = 3; container.add(new JLabel(Messages.getString("ProxyLogic.username")), gbc); gbc.gridx = 1; gbc.gridy = 2; container.add(username, gbc); gbc.gridx = 0; gbc.gridy = 3; container.add(new JLabel(Messages.getString("ProxyLogic.password")), gbc); gbc.gridx = 1; gbc.gridy = 3; container.add(password, gbc); panel.add(about); panel.add(Box.createVerticalStrut(20)); panel.add(container); panel.add(Box.createVerticalStrut(20)); return panel; }
Example 18
Source File: MainWindow.java From Creatures with GNU General Public License v2.0 | 4 votes |
private void initUI(WorldView view) { JPanel rightContainer = new JPanel(); rightContainer.setLayout(new BoxLayout(rightContainer, BoxLayout.PAGE_AXIS)); textLabel = new JLabel("Creatures"); textLabel.setAlignmentX(Component.LEFT_ALIGNMENT); speedLabel = new JLabel("Speed"); speedLabel.setAlignmentX(Component.LEFT_ALIGNMENT); speedSlider = new JSlider(0, 15, 1); speedSlider.setAlignmentX(Component.LEFT_ALIGNMENT); speedSlider.setMajorTickSpacing(5); speedSlider.setMinorTickSpacing(1); speedSlider.setSnapToTicks(true); speedSlider.setPaintLabels(true); speedSlider.setPaintTicks(true); speedSlider.addChangeListener(this); JPanel maxFoodContainer = new JPanel(); maxFoodContainer.setLayout(new FlowLayout(FlowLayout.LEFT)); maxFoodContainer.setAlignmentX(Component.LEFT_ALIGNMENT); maxFoodLabel = new JLabel("Max Food"); SpinnerModel maxFoodSpinnerModel = new SpinnerNumberModel(WorldModel.maxFoodAmount, 0, 100000, 1); maxFoodSpinner = new JSpinner(maxFoodSpinnerModel); maxFoodSpinner.setEditor(new JSpinner.NumberEditor(maxFoodSpinner, "#")); maxFoodSpinner.addChangeListener(this); maxFoodContainer.add(maxFoodLabel); maxFoodContainer.add(maxFoodSpinner); rightContainer.add(textLabel); rightContainer.add(Box.createVerticalStrut(10)); rightContainer.add(speedLabel); rightContainer.add(speedSlider); rightContainer.add(maxFoodContainer); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, view, rightContainer); splitPane.setResizeWeight(0.8); add(splitPane); menuBar = new JMenuBar(); fileMenu = new JMenu("File"); exportStatisticsItem = new JMenuItem("Export Statistics"); exportStatisticsItem.addActionListener(this); closeItem = new JMenuItem("Close"); closeItem.addActionListener(this); fileMenu.add(exportStatisticsItem); fileMenu.addSeparator(); fileMenu.add(closeItem); worldMenu = new JMenu("Creation"); createWorldItem = new JMenuItem("Create World"); createWorldItem.addActionListener(this); worldMenu.add(createWorldItem); worldMenu.addSeparator(); createCreatureItem = new JMenuItem("Create Creature"); createCreatureItem.addActionListener(this); worldMenu.add(createCreatureItem); createCreaturesItem = new JMenuItem("Create Creatures"); createCreaturesItem.addActionListener(this); worldMenu.add(createCreaturesItem); statisticsMenu = new JMenu("Statistics"); showStatisticsItem = new JMenuItem("Show Statistics"); showStatisticsItem.addActionListener(this); statisticsMenu.add(showStatisticsItem); menuBar.add(fileMenu); menuBar.add(worldMenu); menuBar.add(statisticsMenu); setJMenuBar(menuBar); }
Example 19
Source File: CustomizerMocha.java From netbeans with Apache License 2.0 | 4 votes |
/** * 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() { mochaDirLabel = new JLabel(); mochaDirTextField = new JTextField(); mochaDirBrowseButton = new JButton(); mochaDirInfoLabel = new JLabel(); timeoutLabel = new JLabel(); timeoutInfoLabel = new JLabel(); timeoutSpinner = new JSpinner(); autowatchCheckBox = new JCheckBox(); Mnemonics.setLocalizedText(mochaDirLabel, NbBundle.getMessage(CustomizerMocha.class, "CustomizerMocha.mochaDirLabel.text")); // NOI18N Mnemonics.setLocalizedText(mochaDirBrowseButton, NbBundle.getMessage(CustomizerMocha.class, "CustomizerMocha.mochaDirBrowseButton.text")); // NOI18N mochaDirBrowseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mochaDirBrowseButtonActionPerformed(evt); } }); Mnemonics.setLocalizedText(mochaDirInfoLabel, NbBundle.getMessage(CustomizerMocha.class, "CustomizerMocha.mochaDirInfoLabel.text")); // NOI18N timeoutLabel.setLabelFor(timeoutSpinner); Mnemonics.setLocalizedText(timeoutLabel, NbBundle.getMessage(CustomizerMocha.class, "CustomizerMocha.timeoutLabel.text")); // NOI18N Mnemonics.setLocalizedText(timeoutInfoLabel, NbBundle.getMessage(CustomizerMocha.class, "CustomizerMocha.timeoutInfoLabel.text")); // NOI18N timeoutSpinner.setEditor(new JSpinner.NumberEditor(timeoutSpinner, "#")); Mnemonics.setLocalizedText(autowatchCheckBox, NbBundle.getMessage(CustomizerMocha.class, "CustomizerMocha.autowatchCheckBox.text")); // NOI18N GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(mochaDirLabel) .addComponent(timeoutLabel)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(mochaDirTextField, GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(mochaDirBrowseButton) .addContainerGap()) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(mochaDirInfoLabel) .addComponent(timeoutInfoLabel) .addComponent(timeoutSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE)))) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(autowatchCheckBox) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(mochaDirLabel) .addComponent(mochaDirTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(mochaDirBrowseButton)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(mochaDirInfoLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(timeoutLabel) .addComponent(timeoutSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(timeoutInfoLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(autowatchCheckBox) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }
Example 20
Source File: NodeJsCustomizerPanel.java From netbeans with Apache License 2.0 | 4 votes |
/** * 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() { nodeBbuttonGroup = new ButtonGroup(); enabledCheckBox = new JCheckBox(); configureNodeButton = new JButton(); defaultNodeRadioButton = new JRadioButton(); customNodeRadioButton = new JRadioButton(); nodePathPanel = new JPanel(); debugPortLabel = new JLabel(); debugPortSpinner = new JSpinner(); localDebugInfoLabel = new JLabel(); syncCheckBox = new JCheckBox(); Mnemonics.setLocalizedText(enabledCheckBox, NbBundle.getMessage(NodeJsCustomizerPanel.class, "NodeJsCustomizerPanel.enabledCheckBox.text")); // NOI18N Mnemonics.setLocalizedText(configureNodeButton, NbBundle.getMessage(NodeJsCustomizerPanel.class, "NodeJsCustomizerPanel.configureNodeButton.text")); // NOI18N configureNodeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { configureNodeButtonActionPerformed(evt); } }); nodeBbuttonGroup.add(defaultNodeRadioButton); Mnemonics.setLocalizedText(defaultNodeRadioButton, NbBundle.getMessage(NodeJsCustomizerPanel.class, "NodeJsCustomizerPanel.defaultNodeRadioButton.text")); // NOI18N nodeBbuttonGroup.add(customNodeRadioButton); Mnemonics.setLocalizedText(customNodeRadioButton, NbBundle.getMessage(NodeJsCustomizerPanel.class, "NodeJsCustomizerPanel.customNodeRadioButton.text")); // NOI18N nodePathPanel.setLayout(new BorderLayout()); debugPortLabel.setLabelFor(debugPortSpinner); Mnemonics.setLocalizedText(debugPortLabel, NbBundle.getMessage(NodeJsCustomizerPanel.class, "NodeJsCustomizerPanel.debugPortLabel.text")); // NOI18N debugPortSpinner.setEditor(new JSpinner.NumberEditor(debugPortSpinner, "#")); Mnemonics.setLocalizedText(localDebugInfoLabel, NbBundle.getMessage(NodeJsCustomizerPanel.class, "NodeJsCustomizerPanel.localDebugInfoLabel.text")); // NOI18N Mnemonics.setLocalizedText(syncCheckBox, NbBundle.getMessage(NodeJsCustomizerPanel.class, "NodeJsCustomizerPanel.syncCheckBox.text")); // NOI18N GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(21, 21, 21) .addComponent(nodePathPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(defaultNodeRadioButton) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(configureNodeButton)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(localDebugInfoLabel) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(enabledCheckBox) .addComponent(customNodeRadioButton) .addGroup(layout.createSequentialGroup() .addComponent(debugPortLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(debugPortSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(syncCheckBox)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(enabledCheckBox) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(defaultNodeRadioButton) .addComponent(configureNodeButton)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(customNodeRadioButton) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(nodePathPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(debugPortLabel) .addComponent(debugPortSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(localDebugInfoLabel) .addGap(18, 18, 18) .addComponent(syncCheckBox)) ); }