Java Code Examples for javax.swing.JFormattedTextField#setEditable()
The following examples show how to use
javax.swing.JFormattedTextField#setEditable() .
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: SkillInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 7 votes |
private SkillRankSpinnerEditor(SkillRankSpinnerModel model) { super(model); this.model = model; DefaultEditor editor = new DefaultEditor(spinner); NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.#")); //$NON-NLS-1$ formatter.setValueClass(Float.class); DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); JFormattedTextField ftf = editor.getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(factory); ftf.setHorizontalAlignment(SwingConstants.RIGHT); spinner.setEditor(editor); }
Example 2
Source File: GameInfoDialog.java From lizzie with GNU General Public License v3.0 | 6 votes |
private void initContentPanel() { GridLayout gridLayout = new GridLayout(4, 2, 4, 4); contentPanel.setLayout(gridLayout); // editable textFieldWhite = new JTextField(); textFieldBlack = new JTextField(); // read-only textFieldKomi = new JFormattedTextField(FORMAT_KOMI); textFieldHandicap = new JFormattedTextField(FORMAT_HANDICAP); textFieldKomi.setEditable(true); textFieldHandicap.setEditable(false); contentPanel.add(new JLabel("Black")); contentPanel.add(textFieldBlack); contentPanel.add(new JLabel("White")); contentPanel.add(textFieldWhite); contentPanel.add(new JLabel("Komi")); contentPanel.add(textFieldKomi); contentPanel.add(new JLabel("Handicap")); contentPanel.add(textFieldHandicap); dialogPane.add(contentPanel, BorderLayout.CENTER); }
Example 3
Source File: SkillInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private SkillRankSpinnerEditor(SkillRankSpinnerModel model) { super(model); this.model = model; DefaultEditor editor = new DefaultEditor(spinner); NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.#")); //$NON-NLS-1$ formatter.setValueClass(Float.class); DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); JFormattedTextField ftf = editor.getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(factory); ftf.setHorizontalAlignment(SwingConstants.RIGHT); spinner.setEditor(editor); }
Example 4
Source File: DateCellEditor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Constructs a new <code>DatePickerParameterComponent</code>. */ public DateCellEditor( final Class dateType ) { this.listeners = new EventListenerList(); this.dateType = dateType; if ( this.dateType.isArray() ) { this.dateType = this.dateType.getComponentType(); } setLayout( new BorderLayout() ); dateField = new JFormattedTextField(); dateField.setColumns( 20 ); dateField.setEditable( true ); pickDateButton = new EllipsisButton( new PickDateListener() ); add( dateField, BorderLayout.CENTER ); add( pickDateButton, BorderLayout.EAST ); }
Example 5
Source File: SwingNullableSpinner.java From atdl4j with MIT License | 6 votes |
private NumberEditorNull(JSpinner spinner, DecimalFormat format) { super(spinner); if (!(spinner.getModel() instanceof SpinnerNumberModelNull)) { return; } SpinnerNumberModelNull model = (SpinnerNumberModelNull) spinner.getModel(); NumberFormatter formatter = new NumberEditorFormatterNull(model, format); DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); JFormattedTextField ftf = getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(factory); ftf.setHorizontalAlignment(JTextField.RIGHT); try { String maxString = formatter.valueToString(model.getMinimum()); String minString = formatter.valueToString(model.getMaximum()); ftf.setColumns(Math.max(maxString.length(), minString.length())); } catch (ParseException e) { // TBD should throw a chained error here } }
Example 6
Source File: LHexaSpinner.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
HexaEditor (JSpinner spinner) { super(spinner); JFormattedTextField ftf = getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(new HexaFormatterFactory()); }
Example 7
Source File: LHexaSpinner.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
HexaEditor (JSpinner spinner) { super(spinner); JFormattedTextField ftf = getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(new HexaFormatterFactory()); }
Example 8
Source File: IsotopePeakScannerSetupDialog.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
@Override protected void addDialogComponents() { super.addDialogComponents(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); pnlChart = new EChartPanel(chart); pnlChart.setPreferredSize( new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3))); pnlPreview.add(pnlChart, BorderLayout.CENTER); // get components cmpAutoCarbon = (OptionalModuleComponent) this .getComponentForParameter(IsotopePeakScannerParameters.autoCarbonOpt); cmpAutoCarbonCbx = (JCheckBox) cmpAutoCarbon.getComponent(0); cmpPreview = (JCheckBox) this.getComponentForParameter(IsotopePeakScannerParameters.showPreview); cmpPreview.setSelected(false); // i want to have the checkbox below the pattern settings // but it should be disabled by default. Thats why it's hardcoded here. // get parameters pElement = parameterSet.getParameter(IsotopePeakScannerParameters.element); pMinIntensity = parameterSet.getParameter(IsotopePeakScannerParameters.minPatternIntensity); pCharge = parameterSet.getParameter(IsotopePeakScannerParameters.charge); pMergeWidth = parameterSet.getParameter(IsotopePeakScannerParameters.mergeWidth); pAutoCarbon = parameterSet.getParameter(IsotopePeakScannerParameters.autoCarbonOpt); autoCarbonParameters = pAutoCarbon.getEmbeddedParameters(); pMinC = autoCarbonParameters.getParameter(AutoCarbonParameters.minCarbon); pMaxC = autoCarbonParameters.getParameter(AutoCarbonParameters.maxCarbon); pMinSize = autoCarbonParameters.getParameter(AutoCarbonParameters.minPatternSize); // set up gui form = new NumberFormatter(NumberFormat.getInstance()); form.setValueClass(Integer.class); form.setFormat(new DecimalFormat("0")); form.setAllowsInvalid(true); form.setMinimum(minC); form.setMaximum(maxC); btnPrevPattern = new JButton("Previous"); btnPrevPattern.addActionListener(this); btnPrevPattern.setMinimumSize(btnPrevPattern.getPreferredSize()); btnPrevPattern.setEnabled(cmpAutoCarbonCbx.isSelected()); txtCurrentPatternIndex = new JFormattedTextField(form); txtCurrentPatternIndex.addActionListener(this); txtCurrentPatternIndex.setText(String.valueOf((minC + maxC) / 2)); txtCurrentPatternIndex.setPreferredSize(new Dimension(50, 25)); txtCurrentPatternIndex.setEditable(true); txtCurrentPatternIndex.setEnabled(cmpAutoCarbonCbx.isSelected()); btnNextPattern = new JButton("Next"); btnNextPattern.addActionListener(this); btnNextPattern.setPreferredSize(btnNextPattern.getMinimumSize()); btnNextPattern.setEnabled(cmpAutoCarbonCbx.isSelected()); chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance", new XYSeriesCollection(new XYSeries(""))); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.getXYPlot().setDomainGridlinePaint(Color.GRAY); chart.getXYPlot().setRangeGridlinePaint(Color.GRAY); pnlPreviewButtons.add(btnPrevPattern); pnlPreviewButtons.add(txtCurrentPatternIndex); pnlPreviewButtons.add(btnNextPattern); pack(); }
Example 9
Source File: BasicDatePickerUI.java From microba with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void installComponents() { field = new JFormattedTextField(createFormatterFactory()); field.setValue(peer.getDate()); field.setFocusLostBehavior(peer.getFocusLostBehavior()); field.setEditable(peer.isFieldEditable()); field.setToolTipText(peer.getToolTipText()); // button button = new JButton(); button.setFocusable(false); button.setMargin(new Insets(0, 0, 0, 0)); button.setToolTipText(peer.getToolTipText()); setSimpeLook(false); // calendar calendarPane = new CalendarPane(peer.getStyle()); calendarPane.setShowTodayButton(peer.isShowTodayButton()); calendarPane.setFocusLostBehavior(JFormattedTextField.REVERT); calendarPane.setFocusCycleRoot(true); calendarPane.setBorder(BorderFactory.createEmptyBorder(1, 3, 0, 3)); calendarPane.setStripTime(false); calendarPane.setLocale(peer.getLocale()); calendarPane.setZone(peer.getZone()); calendarPane.setFocusable(peer.isDropdownFocusable()); calendarPane.setColorOverrideMap(peer.getColorOverrideMap()); // popup popup = new JPopupMenu(); popup.setLayout(new BorderLayout()); popup.add(calendarPane, BorderLayout.CENTER); popup.setLightWeightPopupEnabled(true); // add peer.setLayout(new BorderLayout()); switch (peer.getPickerStyle()) { case DatePicker.PICKER_STYLE_FIELD_AND_BUTTON: peer.add(field, BorderLayout.CENTER); peer.add(button, BorderLayout.EAST); break; case DatePicker.PICKER_STYLE_BUTTON: peer.add(button, BorderLayout.EAST); break; } peer.revalidate(); peer.repaint(); componentListener = new ComponentListener(); button.addActionListener(componentListener); field.addPropertyChangeListener(componentListener); calendarPane.addPropertyChangeListener(componentListener); calendarPane.addCommitListener(componentListener); calendarPane.addActionListener(componentListener); peerDateChanged(peer.getDate()); }