List of usage examples for javax.swing JFormattedTextField JFormattedTextField
public JFormattedTextField(AbstractFormatterFactory factory)
JFormattedTextField
with the specified AbstractFormatterFactory
. From source file:FormatterFactoryDemo.java
public FormatterFactoryDemo() { super(new BorderLayout()); setUpFormats();//from ww w . ja v a 2s. c o m double payment = computePayment(amount, rate, numPeriods); //Create the labels. amountLabel = new JLabel(amountString); rateLabel = new JLabel(rateString); numPeriodsLabel = new JLabel(numPeriodsString); paymentLabel = new JLabel(paymentString); //Create the text fields and set them up. amountField = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(amountDisplayFormat), new NumberFormatter(amountDisplayFormat), new NumberFormatter(amountEditFormat))); amountField.setValue(new Double(amount)); amountField.setColumns(10); amountField.addPropertyChangeListener("value", this); NumberFormatter percentEditFormatter = new NumberFormatter(percentEditFormat) { public String valueToString(Object o) throws ParseException { Number number = (Number) o; if (number != null) { double d = number.doubleValue() * 100.0; number = new Double(d); } return super.valueToString(number); } public Object stringToValue(String s) throws ParseException { Number number = (Number) super.stringToValue(s); if (number != null) { double d = number.doubleValue() / 100.0; number = new Double(d); } return number; } }; rateField = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(percentDisplayFormat), new NumberFormatter(percentDisplayFormat), percentEditFormatter)); rateField.setValue(new Double(rate)); rateField.setColumns(10); rateField.addPropertyChangeListener("value", this); numPeriodsField = new JFormattedTextField(); numPeriodsField.setValue(new Integer(numPeriods)); numPeriodsField.setColumns(10); numPeriodsField.addPropertyChangeListener("value", this); paymentField = new JFormattedTextField(paymentFormat); paymentField.setValue(new Double(payment)); paymentField.setColumns(10); paymentField.setEditable(false); paymentField.setForeground(Color.red); //Tell accessibility tools about label/textfield pairs. amountLabel.setLabelFor(amountField); rateLabel.setLabelFor(rateField); numPeriodsLabel.setLabelFor(numPeriodsField); paymentLabel.setLabelFor(paymentField); //Lay out the labels in a panel. JPanel labelPane = new JPanel(new GridLayout(0, 1)); labelPane.add(amountLabel); labelPane.add(rateLabel); labelPane.add(numPeriodsLabel); labelPane.add(paymentLabel); //Layout the text fields in a panel. JPanel fieldPane = new JPanel(new GridLayout(0, 1)); fieldPane.add(amountField); fieldPane.add(rateField); fieldPane.add(numPeriodsField); fieldPane.add(paymentField); //Put the panels in this panel, labels on left, //text fields on right. setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); add(labelPane, BorderLayout.CENTER); add(fieldPane, BorderLayout.LINE_END); }
From source file:TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);/*w w w. j a v a2s . c o m*/ //Create a label to put messages during an action event. actionLabel = new JLabel("Type text and then Enter in a field."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildTransactionTable() { transactionModel = new TransactionTableModel(service); transactionTable = new JTable(transactionModel); transactionTable.setRowHeight((int) (transactionTable.getRowHeight() * 1.2)); transactionTable.getColumnModel().getColumn(TransactionTableModel.COL_END) .setCellEditor(new CustomCellEditor( new JFormattedTextField(new OptionalValueFormatter(new JodaLocalDateFormat())))); transactionTable.setDefaultEditor(LocalDate.class, new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat()))); transactionTable.setDefaultEditor(ReadablePeriod.class, new CustomCellEditor(new JFormattedTextField(new OptionalValueFormatter(new JodaPeriodFormat())))); transactionTable.setDefaultEditor(Double.class, new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance()))); transactionTable.setDefaultRenderer(LocalDate.class, new FormattedTableCellRenderer(new JodaLocalDateFormat())); transactionTable.setDefaultRenderer(ReadablePeriod.class, new FormattedTableCellRenderer(new JodaPeriodFormat())); transactionTable.setDefaultRenderer(Double.class, new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat())); transactionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); transactionTable.setAutoCreateRowSorter(true); transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$ transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$ transactionTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override/* w w w . j a v a 2s . c o m*/ public void actionPerformed(ActionEvent e) { int row = transactionTable.getSelectedRow(); if (row >= 0) { row = transactionTable.getRowSorter().convertRowIndexToModel(row); transactionModel.deleteRow(row); } } }); }
From source file:com.jgoodies.validation.tutorial.formatted.NumberExample.java
/** * Appends the demo rows to the given builder and returns the List of * formatted text fields.// www . j a v a 2 s . co m * * @param builder the builder used to add components to * @return the List of formatted text fields */ private List appendDemoRows(DefaultFormBuilder builder) { // The Formatter is choosen by the initial value. JFormattedTextField defaultNumberField = new JFormattedTextField(new Long(42)); // The Formatter is choosen by the given Format. JFormattedTextField noInitialValueField = new JFormattedTextField(NumberFormat.getIntegerInstance()); // Uses a custom NumberFormat. NumberFormat customFormat = NumberFormat.getIntegerInstance(); customFormat.setMinimumIntegerDigits(3); JFormattedTextField customFormatField = new JFormattedTextField(new NumberFormatter(customFormat)); // Uses a custom NumberFormatter that prints natural language strings. JFormattedTextField customFormatterField = new JFormattedTextField(new CustomNumberFormatter()); // Uses a custom FormatterFactory that used different formatters // for the display and while editing. DefaultFormatterFactory formatterFactory = new DefaultFormatterFactory(new NumberFormatter(), new CustomNumberFormatter()); JFormattedTextField formatterFactoryField = new JFormattedTextField(formatterFactory); // Wraps a NumberFormatter to map empty strings to null and vice versa. JFormattedTextField numberOrNullField = new JFormattedTextField(new EmptyNumberFormatter()); // Wraps a NumberFormatter to map empty strings to -1 and vice versa. Integer emptyValue = new Integer(-1); JFormattedTextField numberOrEmptyValueField = new JFormattedTextField(new EmptyNumberFormatter(emptyValue)); numberOrEmptyValueField.setValue(emptyValue); // Commits values on valid edit texts. DefaultFormatter formatter = new NumberFormatter(); formatter.setCommitsOnValidEdit(true); JFormattedTextField commitOnValidEditField = new JFormattedTextField(formatter); // Returns number values of type Integer NumberFormatter numberFormatter = new NumberFormatter(); numberFormatter.setValueClass(Integer.class); JFormattedTextField integerField = new JFormattedTextField(numberFormatter); Format displayFormat = new DisplayFormat(NumberFormat.getIntegerInstance()); Format typedDisplayFormat = new DisplayFormat(NumberFormat.getIntegerInstance(), true); List fields = new LinkedList(); fields.add(Utils.appendRow(builder, "Default", defaultNumberField, typedDisplayFormat)); fields.add(Utils.appendRow(builder, "No initial value", noInitialValueField, displayFormat)); fields.add(Utils.appendRow(builder, "Empty <-> null", numberOrNullField, displayFormat)); fields.add(Utils.appendRow(builder, "Empty <-> -1", numberOrEmptyValueField, displayFormat)); fields.add(Utils.appendRow(builder, "Custom format", customFormatField, displayFormat)); fields.add(Utils.appendRow(builder, "Custom formatter", customFormatterField, displayFormat)); fields.add(Utils.appendRow(builder, "Formatter factory", formatterFactoryField, displayFormat)); fields.add(Utils.appendRow(builder, "Commits on valid edit", commitOnValidEditField, displayFormat)); fields.add(Utils.appendRow(builder, "Integer Result", integerField, typedDisplayFormat)); return fields; }
From source file:com.googlecode.vfsjfilechooser2.accessories.connection.ConnectionDialog.java
private void initCenterPanelComponents() { // create the panel this.centerPanel = new JPanel(new GridBagLayout()); this.centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); // create the components this.hostnameLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.hostnameLabelText")); this.hostnameLabel.setForeground(Color.RED); this.hostnameTextField = new JTextField(25); this.portLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.portLabelText")); this.portTextField = new JFormattedTextField(NumberFormat.getInstance()); this.isPortTextFieldDirty = false; this.protocolLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.protocolLabelText")); this.protocolModel = new DefaultComboBoxModel(Protocol.values()); this.protocolList = new JComboBox(protocolModel); this.protocolList.setRenderer(new ProtocolRenderer()); this.usernameLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.usernameLabelText")); this.usernameTextField = new JTextField(20); this.passwordLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.passwordLabelText")); this.passwordTextField = new JPasswordField(12); this.defaultRemotePathLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.pathLabelText")); this.defaultRemotePathTextField = new JTextField(20); // Add the components to the panel makeGridPanel(new Component[] { hostnameLabel, hostnameTextField, portLabel, portTextField, protocolLabel, protocolList, usernameLabel, usernameTextField, passwordLabel, passwordTextField, defaultRemotePathLabel, defaultRemotePathTextField }); }
From source file:com.jgoodies.validation.tutorial.formatted.DateExample.java
/** * Appends the demo rows to the given builder and returns the List of * formatted text fields.//from w ww .j a va2 s. c o m * * @param builder the builder used to add components to * @return the List of formatted text fields */ private List appendDemoRows(DefaultFormBuilder builder) { // The Formatter is choosen by the initial value. JFormattedTextField defaultDateField = new JFormattedTextField(new Date()); // The Formatter is choosen by the given Format. JFormattedTextField noInitialValueField = new JFormattedTextField(DateFormat.getDateInstance()); // Uses a custom DateFormat. DateFormat customFormat = DateFormat.getDateInstance(DateFormat.SHORT); JFormattedTextField customFormatField = new JFormattedTextField(new DateFormatter(customFormat)); // Uses a RelativeDateFormat. DateFormat relativeFormat = new RelativeDateFormat(); JFormattedTextField relativeFormatField = new JFormattedTextField(new DateFormatter(relativeFormat)); // Uses a custom DateFormatter that allows relative input and // prints natural language strings. JFormattedTextField relativeFormatterField = new JFormattedTextField(new RelativeDateFormatter()); // Uses a custom FormatterFactory that used different formatters // for the display and while editing. DefaultFormatterFactory formatterFactory = new DefaultFormatterFactory( new RelativeDateFormatter(false, true), new RelativeDateFormatter(true, true)); JFormattedTextField relativeFactoryField = new JFormattedTextField(formatterFactory); // Wraps a DateFormatter to map empty strings to null and vice versa. JFormattedTextField numberOrNullField = new JFormattedTextField(new EmptyDateFormatter()); // Wraps a DateFormatter to map empty strings to -1 and vice versa. Date epoch = new Date(0); // January 1, 1970 JFormattedTextField numberOrEmptyValueField = new JFormattedTextField(new EmptyDateFormatter(epoch)); numberOrEmptyValueField.setValue(epoch); // Commits value on valid edit text DefaultFormatter formatter = new RelativeDateFormatter(); formatter.setCommitsOnValidEdit(true); JFormattedTextField commitOnValidEditField = new JFormattedTextField(formatter); // A date field as created by the BasicComponentFactory: // Uses relative date input, and maps empty strings to null. ValueModel dateHolder = new ValueHolder(); JFormattedTextField componentFactoryField = ExampleComponentFactory.createDateField(dateHolder); Format displayFormat = new DisplayFormat(DateFormat.getDateInstance()); List fields = new LinkedList(); fields.add(Utils.appendRow(builder, "Default", defaultDateField, displayFormat)); fields.add(Utils.appendRow(builder, "No initial value", noInitialValueField, displayFormat)); fields.add(Utils.appendRow(builder, "Empty <-> null", numberOrNullField, displayFormat)); fields.add(Utils.appendRow(builder, "Empty <-> epoch", numberOrEmptyValueField, displayFormat)); fields.add(Utils.appendRow(builder, "Short format", customFormatField, displayFormat)); fields.add(Utils.appendRow(builder, "Relative format", relativeFormatField, displayFormat)); fields.add(Utils.appendRow(builder, "Relative formatter", relativeFormatterField, displayFormat)); fields.add(Utils.appendRow(builder, "Relative factory", relativeFactoryField, displayFormat)); fields.add(Utils.appendRow(builder, "Commits on valid edit", commitOnValidEditField, displayFormat)); fields.add(Utils.appendRow(builder, "Relative, maps null", componentFactoryField, displayFormat)); return fields; }
From source file:com.streamhub.StreamHubLicenseGenerator.java
private static JPanel createMacAddressRow() { JPanel macAddressPanel = new JPanel(new FlowLayout()); Calendar yesterday = Calendar.getInstance(); yesterday.setTime(new Date()); yesterday.add(Calendar.DAY_OF_MONTH, -1); Calendar expiry = Calendar.getInstance(); expiry.setTime(yesterday.getTime()); expiry.add(Calendar.DAY_OF_MONTH, 60); JLabel macAddressLabel = new JLabel("MAC Address:"); JTextField macAddress = new JTextField(17); JLabel startDateLabel = new JLabel("Start Date"); final JFormattedTextField startDate = new JFormattedTextField(new SimpleDateFormat(DATE_FORMAT)); startDate.setValue(yesterday.getTime()); JLabel expiryDateLabel = new JLabel("Expiry Date"); final JFormattedTextField expiryDate = new JFormattedTextField(new SimpleDateFormat(DATE_FORMAT)); expiryDate.setValue(expiry.getTime()); startDate.addKeyListener(new KeyListener() { @Override/*from w w w.ja v a 2 s. c o m*/ public void keyTyped(KeyEvent arg0) { // Get the new date and change expiry to suit Date date = (Date) startDate.getValue(); Calendar tempCal = Calendar.getInstance(); tempCal.setTime(date); tempCal.add(Calendar.DAY_OF_MONTH, 60); expiryDate.setValue(tempCal.getTime()); } @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } }); JComboBox edition = new JComboBox(new String[] { "web", "enterprise" }); JLabel nameLabel = new JLabel("Name:"); JTextField name = new JTextField(15); JLabel numUsersLabel = new JLabel("Num. Users:"); JTextField numUsers = new JTextField(DEFAULT_NUM_USERS); macAddressPanel.add(macAddressLabel); macAddressPanel.add(macAddress); macAddressPanel.add(startDateLabel); macAddressPanel.add(startDate); macAddressPanel.add(expiryDateLabel); macAddressPanel.add(expiryDate); macAddressPanel.add(edition); macAddressPanel.add(nameLabel); macAddressPanel.add(name); macAddressPanel.add(numUsersLabel); macAddressPanel.add(numUsers); return macAddressPanel; }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildReconciliationTable() { reconciliationModel = new ReconciliationTableModel(service); reconciliationTable = new JTable(reconciliationModel); reconciliationTable.setRowHeight((int) (reconciliationTable.getRowHeight() * 1.2)); reconciliationTable.setDefaultEditor(LocalDate.class, new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat()))); reconciliationTable.setDefaultEditor(Double.class, new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance()))); reconciliationTable.setDefaultRenderer(LocalDate.class, new FormattedTableCellRenderer(new JodaLocalDateFormat())); reconciliationTable.setDefaultRenderer(Double.class, new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat())); reconciliationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$ reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$ reconciliationTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override//from w ww. j ava2s .co m public void actionPerformed(ActionEvent e) { int row = reconciliationTable.getSelectedRow(); if (row >= 0) { reconciliationModel.deleteRow(row); } } }); transactionTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int row = transactionTable.getSelectedRow(); if (row >= 0) { row = transactionTable.getRowSorter().convertRowIndexToModel(row); TransactionDefinition td = transactionModel.getTransactionForRow(row); if (td != null) { reconciliationModel.setCurrentTransactionId(td.getId()); } else { reconciliationModel.setCurrentTransactionId(-1); } } else { reconciliationModel.setCurrentTransactionId(-1); } } } }); }
From source file:TextInputDemo.java
protected JComponent createEntryFields() { JPanel panel = new JPanel(new SpringLayout()); String[] labelStrings = { "Street address: ", "City: ", "State: ", "Zip code: " }; JLabel[] labels = new JLabel[labelStrings.length]; JComponent[] fields = new JComponent[labelStrings.length]; int fieldNum = 0; //Create the text field and set it up. streetField = new JTextField(); streetField.setColumns(20);/*from w w w . j av a2 s. co m*/ fields[fieldNum++] = streetField; cityField = new JTextField(); cityField.setColumns(20); fields[fieldNum++] = cityField; String[] stateStrings = getStateStrings(); stateSpinner = new JSpinner(new SpinnerListModel(stateStrings)); fields[fieldNum++] = stateSpinner; zipField = new JFormattedTextField(createFormatter("#####")); fields[fieldNum++] = zipField; //Associate label/field pairs, add everything, //and lay it out. for (int i = 0; i < labelStrings.length; i++) { labels[i] = new JLabel(labelStrings[i], JLabel.TRAILING); labels[i].setLabelFor(fields[i]); panel.add(labels[i]); panel.add(fields[i]); //Add listeners to each field. JTextField tf = null; if (fields[i] instanceof JSpinner) { tf = getTextField((JSpinner) fields[i]); } else { tf = (JTextField) fields[i]; } tf.addActionListener(this); tf.addFocusListener(this); } SpringUtilities.makeCompactGrid(panel, labelStrings.length, 2, GAP, GAP, //init x,y GAP, GAP / 2);//xpad, ypad return panel; }
From source file:com.vgi.mafscaling.Rescale.java
private void createControlPanel(JPanel dataPanel) { JPanel cntlPanel = new JPanel(); GridBagConstraints gbl_ctrlPanel = new GridBagConstraints(); gbl_ctrlPanel.insets = insets3;/* w ww. jav a 2s . c o m*/ gbl_ctrlPanel.anchor = GridBagConstraints.PAGE_START; gbl_ctrlPanel.fill = GridBagConstraints.HORIZONTAL; gbl_ctrlPanel.weightx = 1.0; gbl_ctrlPanel.gridx = 0; gbl_ctrlPanel.gridy = 0; dataPanel.add(cntlPanel, gbl_ctrlPanel); GridBagLayout gbl_cntlPanel = new GridBagLayout(); gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_cntlPanel.rowHeights = new int[] { 0, 0 }; gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; gbl_cntlPanel.rowWeights = new double[] { 0 }; cntlPanel.setLayout(gbl_cntlPanel); NumberFormat doubleFmt = NumberFormat.getNumberInstance(); doubleFmt.setGroupingUsed(false); doubleFmt.setMaximumIntegerDigits(1); doubleFmt.setMinimumIntegerDigits(1); doubleFmt.setMaximumFractionDigits(3); doubleFmt.setMinimumFractionDigits(1); doubleFmt.setRoundingMode(RoundingMode.HALF_UP); NumberFormat scaleDoubleFmt = NumberFormat.getNumberInstance(); scaleDoubleFmt.setGroupingUsed(false); scaleDoubleFmt.setMaximumIntegerDigits(1); scaleDoubleFmt.setMinimumIntegerDigits(1); scaleDoubleFmt.setMaximumFractionDigits(8); scaleDoubleFmt.setMinimumFractionDigits(1); scaleDoubleFmt.setRoundingMode(RoundingMode.HALF_UP); GridBagConstraints gbc_cntlPanelLabel = new GridBagConstraints(); gbc_cntlPanelLabel.anchor = GridBagConstraints.EAST; gbc_cntlPanelLabel.insets = new Insets(2, 3, 2, 1); gbc_cntlPanelLabel.gridx = 0; gbc_cntlPanelLabel.gridy = 0; GridBagConstraints gbc_cntlPanelInput = new GridBagConstraints(); gbc_cntlPanelInput.anchor = GridBagConstraints.WEST; gbc_cntlPanelInput.insets = new Insets(2, 1, 2, 3); gbc_cntlPanelInput.gridx = 1; gbc_cntlPanelInput.gridy = 0; cntlPanel.add(new JLabel("New Max V"), gbc_cntlPanelLabel); newMaxVFmtTextBox = new JFormattedTextField(doubleFmt); newMaxVFmtTextBox.setColumns(7); newMaxVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == newMaxVFmtTextBox) updateNewMafScale(); } }); cntlPanel.add(newMaxVFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Min V"), gbc_cntlPanelLabel); minVFmtTextBox = new JFormattedTextField(doubleFmt); minVFmtTextBox.setColumns(7); minVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == minVFmtTextBox) updateNewMafScale(); } }); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(minVFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Max Unchanged"), gbc_cntlPanelLabel); maxVUnchangedFmtTextBox = new JFormattedTextField(doubleFmt); maxVUnchangedFmtTextBox.setColumns(7); maxVUnchangedFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == maxVUnchangedFmtTextBox) updateNewMafScale(); } }); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(maxVUnchangedFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Mode deltaV"), gbc_cntlPanelLabel); modeDeltaVFmtTextBox = new JFormattedTextField(scaleDoubleFmt); modeDeltaVFmtTextBox.setColumns(7); modeDeltaVFmtTextBox.setEditable(false); modeDeltaVFmtTextBox.setBackground(new Color(210, 210, 210)); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(modeDeltaVFmtTextBox, gbc_cntlPanelInput); }