Java Code Examples for javax.swing.JFormattedTextField#setText()
The following examples show how to use
javax.swing.JFormattedTextField#setText() .
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: WebDriverConfigGui.java From jmeter-plugins-webdriver with Apache License 2.0 | 5 votes |
private void createManualProxy(JPanel panel, ButtonGroup group) { manualProxy = new JRadioButton("Manual proxy configuration"); group.add(manualProxy); panel.add(manualProxy); manualProxy.addItemListener(this); JPanel manualPanel = new VerticalPanel(); manualPanel.setBorder(BorderFactory.createEmptyBorder(0, PROXY_FIELD_INDENT, 0, 0)); httpProxyHost = new JTextField(); httpProxyPort = new JFormattedTextField(NUMBER_FORMAT); httpProxyPort.setText(String.valueOf(DEFAULT_PROXY_PORT)); manualPanel.add(createProxyHostAndPortPanel(httpProxyHost, httpProxyPort, "HTTP Proxy:")); useHttpSettingsForAllProtocols = new JCheckBox("Use HTTP proxy server for all protocols"); useHttpSettingsForAllProtocols.setSelected(true); useHttpSettingsForAllProtocols.setEnabled(false); useHttpSettingsForAllProtocols.addItemListener(this); manualPanel.add(useHttpSettingsForAllProtocols); httpsProxyHost = new JTextField(); httpsProxyPort = new JFormattedTextField(NUMBER_FORMAT); httpsProxyPort.setText(String.valueOf(DEFAULT_PROXY_PORT)); manualPanel.add(createProxyHostAndPortPanel(httpsProxyHost, httpsProxyPort, "SSL Proxy:")); ftpProxyHost = new JTextField(); ftpProxyPort = new JFormattedTextField(NUMBER_FORMAT); ftpProxyPort.setText(String.valueOf(DEFAULT_PROXY_PORT)); manualPanel.add(createProxyHostAndPortPanel(ftpProxyHost, ftpProxyPort, "FTP Proxy:")); socksProxyHost = new JTextField(); socksProxyPort = new JFormattedTextField(NUMBER_FORMAT); socksProxyPort.setText(String.valueOf(DEFAULT_PROXY_PORT)); manualPanel.add(createProxyHostAndPortPanel(socksProxyHost, socksProxyPort, "SOCKS Proxy:")); manualPanel.add(createNoProxyPanel()); panel.add(manualPanel); }
Example 2
Source File: SharedFunctions.java From zap-extensions with Apache License 2.0 | 5 votes |
public static JFormattedTextField createDateField(JPanel pnl, String str, String tip) { SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); JFormattedTextField txt = new JFormattedTextField(format); txt.setText(str); txt.setToolTipText(tip); pnl.add(txt); return txt; }
Example 3
Source File: SwingTextFieldWidget.java From atdl4j with MIT License | 5 votes |
@Override public List< ? extends Component> createBrickComponents() { List<Component> components = new ArrayList<Component>(); // tooltip String tooltip = control.getTooltip(); // label if ( control.getLabel() != null ) { label = new JLabel(); label.setName(getName()+"/label"); label.setText(control.getLabel()); if ( tooltip != null ) label.setToolTipText( tooltip ); } // textField textField = new JFormattedTextField(); textField.setName(getName()+"/text"); // init value if ( ControlHelper.getInitValue( control, getAtdl4jOptions() ) != null ) textField.setText( (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ) ); // tooltip if (tooltip != null) textField.setToolTipText(tooltip); if (label != null){ components.add( label); } components.add( textField); textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height)); return components; }
Example 4
Source File: ControlPanel.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 4 votes |
public SnifferControl() { super(); setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0)); _hostIpTextField = new JTextField(17); _hostIpTextField.setText(Resources.getLabel("sniffer.host.tooltip")); final FirstInputListener listener = new FirstInputListener(_hostIpTextField); _hostIpTextField.addMouseListener(listener); _hostIpTextField.addKeyListener(listener); _hostIpTextField.setToolTipText(Resources.getLabel("sniffer.host.tooltip")); add(_hostIpTextField); final JLabel protocolLabel = new JLabel(Resources.getLabel("protocol.label")); protocolLabel.setToolTipText(Resources.getLabel("protocol.desc")); add(protocolLabel); for (final Protocol type : Protocol.values()) { if (type == Protocol.OTHER) { continue; } final JCheckBox check = new JCheckBox(type.name(), type == Protocol.TCP); _packets.put(type, check); add(check); } final JLabel portLabel = new JLabel(Resources.getLabel("port.label")); portLabel.setToolTipText(Resources.getLabel("port.desc")); _allPortCheck = new JCheckBox(Resources.getLabel("all.port.label")); _allPortCheck.setToolTipText(Resources.getLabel("all.port.desc")); _allPortCheck.setSelected(false); add(_allPortCheck); _portTF = new JFormattedTextField(); _portTF.setText("80,443"); _portTF.setColumns(15); // _portTF.setMaximumSize(new Dimension(30, _portTF.getPreferredSize().height)); add(portLabel); add(_portTF); _portTF.setEnabled(true); _allPortCheck.addChangeListener(e -> _portTF.setEnabled(!_allPortCheck.isSelected())); _filterPacketLengthCheck = new JCheckBox(Resources.getLabel("filter.length")); _filterPacketLengthCheck.setToolTipText(Resources.getLabel("filter.length.desc")); _filterPacketLengthCheck.setSelected(false); add(_filterPacketLengthCheck); _filterLengthTF = new JFormattedTextField(new NumberFormatterFactory()); _filterLengthTF.setText("128"); _filterLengthTF.setColumns(5); add(_filterLengthTF); _filterPacketLengthCheck.addChangeListener(e -> _filterLengthTF.setEnabled(_filterPacketLengthCheck.isEnabled() && _filterPacketLengthCheck.isSelected())); _capturePeriod = new JFormattedTextField(new NumberFormatterFactory()); _capturePeriod.setText("0"); _capturePeriod.setColumns(5); add(new JLabel(Resources.getLabel("capture.period"))); add(_capturePeriod); _captureButton = new JButton(GO_IMG); _captureButton.setToolTipText(Resources.getLabel("capture.packet.start")); add(_captureButton); _captureButton.addActionListener(arg0 -> start()); }
Example 5
Source File: CellTypeTextFieldDefaultImpl.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
/** * Creates a {@link JFormattedTextField} for the specified cell. If a formatter is given, will * apply it to the field. Does not validate the model, so make sure this call works! * * @param model * @param rowIndex * @param columnIndex * @param cellClass * @param formatter * the formatter or <code>null</code> if none is required * @param hideUnavailableContentAssist * @return */ public CellTypeTextFieldDefaultImpl(final TablePanelModel model, final int rowIndex, final int columnIndex, final Class<? extends CellType> cellClass, AbstractFormatter formatter, boolean hideUnavailableContentAssist) { super(); final JFormattedTextField field = CellTypeImplHelper.createFormattedTextField(model, rowIndex, columnIndex); setLayout(new BorderLayout()); add(field, BorderLayout.CENTER); // otherwise 'null' would be restored Object value = model.getValueAt(rowIndex, columnIndex); String text = value != null ? String.valueOf(value) : ""; // specical handling when formatter is given if (formatter != null) { field.setFormatterFactory(new DefaultFormatterFactory(formatter)); } field.setText(text); // set syntax assist if available String syntaxHelp = model.getSyntaxHelpAt(rowIndex, columnIndex); if (syntaxHelp != null && !"".equals(syntaxHelp.trim())) { SwingTools.setPrompt(syntaxHelp, field); } // see if content assist is possible for this field, if so add it ImageIcon icon = SwingTools.createIcon("16/" + I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.action.content_assist.icon")); JButton contentAssistButton = new JButton(); contentAssistButton.setIcon(icon); if (field.isEnabled() && model.isContentAssistPossibleForCell(rowIndex, columnIndex)) { contentAssistButton.setToolTipText(I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.action.content_assist_enabled.tip")); CellTypeImplHelper.addContentAssist(model, rowIndex, columnIndex, field, contentAssistButton, cellClass); } else { contentAssistButton.setToolTipText(I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.action.content_assist_disabled.tip")); contentAssistButton.setEnabled(false); } if (contentAssistButton.isEnabled() || (!contentAssistButton.isEnabled() && !hideUnavailableContentAssist)) { add(contentAssistButton, BorderLayout.EAST); } // set size so panels don't grow larger when they get the chance setPreferredSize(new Dimension(300, 20)); setMinimumSize(new Dimension(100, 15)); setMaximumSize(new Dimension(1600, 30)); }
Example 6
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 7
Source File: SliderWithTextBox.java From opensim-gui 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. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { jCoordinateNameLabel = new javax.swing.JLabel(); jXSlider = new javax.swing.JSlider(); jFormattedTextField = new JFormattedTextField(formatter); jMinimumLabel = new javax.swing.JLabel(); jMaximumLabel = new javax.swing.JLabel(); jCoordinateNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jCoordinateNameLabel.setText("coordinate"); jCoordinateNameLabel.setToolTipText("Name"); jCoordinateNameLabel.setAlignmentX(1.0F); jCoordinateNameLabel.setMaximumSize(new java.awt.Dimension(100, 14)); jCoordinateNameLabel.setMinimumSize(new java.awt.Dimension(100, 14)); jCoordinateNameLabel.setPreferredSize(new java.awt.Dimension(100, 14)); setBorder(javax.swing.BorderFactory.createTitledBorder("Slider label")); setAlignmentY(0.0F); jXSlider.setMajorTickSpacing(20); jXSlider.setMinorTickSpacing(10); jXSlider.setToolTipText("Seek"); jXSlider.setAlignmentX(0.0F); jXSlider.setMinimumSize(new java.awt.Dimension(50, 25)); jXSlider.setPreferredSize(new java.awt.Dimension(50, 25)); jFormattedTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); jFormattedTextField.setText("-123.456"); jFormattedTextField.setToolTipText("Current value"); jFormattedTextField.setFont(new java.awt.Font("Tahoma", 0, 11)); jFormattedTextField.setMinimumSize(new java.awt.Dimension(55, 19)); jFormattedTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFormattedTextFieldActionPerformed(evt); } }); jMinimumLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jMinimumLabel.setText("-123"); jMinimumLabel.setToolTipText("Lower bound"); jMinimumLabel.setFocusable(false); jMinimumLabel.setIconTextGap(0); jMinimumLabel.setMaximumSize(new java.awt.Dimension(30, 25)); jMinimumLabel.setMinimumSize(new java.awt.Dimension(30, 25)); jMinimumLabel.setPreferredSize(new java.awt.Dimension(30, 25)); jMaximumLabel.setText("123"); jMaximumLabel.setToolTipText("Upper bound"); jMaximumLabel.setFocusable(false); jMaximumLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); jMaximumLabel.setIconTextGap(0); jMaximumLabel.setMaximumSize(new java.awt.Dimension(25, 25)); jMaximumLabel.setMinimumSize(new java.awt.Dimension(25, 25)); jMaximumLabel.setPreferredSize(new java.awt.Dimension(25, 25)); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(jFormattedTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 55, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jMinimumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jXSlider, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jMaximumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jMaximumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jFormattedTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jMinimumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jXSlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) ); }
Example 8
Source File: GroupPanel.java From quickfix-messenger with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void initComponents() { setLayout(new GridBagLayout()); layerUI = new FieldValidationLayerUI(getFrame()); groupLabel = new JLabel(getMember().toString()); groupLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); groupLabel.addMouseListener(new LinkMouseAdapter(this)); groupLabel.setToolTipText("Double-click to look-up in FIXwiki"); if (isRequired) { groupLabel.setForeground(Color.BLUE); } JPanel groupValuePanel = new JPanel(); groupValuePanel.setLayout(new BoxLayout(groupValuePanel, BoxLayout.X_AXIS)); groupTextField = new JFormattedTextField( NumberFormat.getIntegerInstance()); groupTextField.setFocusLostBehavior(JFormattedTextField.COMMIT); if (initialNoOfGroups > 0) { groupTextField.setText(String.valueOf(initialNoOfGroups)); } setButton = new JButton("Set"); setButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getFrame().displayMainPanel(); } }); groupValuePanel.add(new JLayer<JFormattedTextField>(groupTextField, layerUI)); groupValuePanel.add(setButton); groupPanels = new JPanel(); groupPanels.setLayout(new GridBagLayout()); loadMembers(); add(groupLabel, createGridBagConstraints()); add(groupValuePanel, createGridBagConstraints()); add(groupPanels, createGridBagConstraints()); }
Example 9
Source File: SwingTextFieldWidget.java From atdl4j with MIT License | 4 votes |
public void createWidget(JPanel parent) { // tooltip String tooltip = control.getTooltip(); // label if ( control.getLabel() != null ) { label = new JLabel(); label.setName(getName()+"/label"); label.setText(control.getLabel()); if ( tooltip != null ) label.setToolTipText( tooltip ); } // textField textField = new JFormattedTextField(); textField.setName(getName()+"/text"); // init value if ( ControlHelper.getInitValue( control, getAtdl4jOptions() ) != null ) textField.setText( (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ) ); // tooltip if (tooltip != null) textField.setToolTipText(tooltip); if (label != null){ wrapper = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.weightx = 1.0; c.weighty = 1.0; c.insets = new Insets(0, 0, 0, 0); wrapper.add( label, c); c.gridx = 1; c.gridy = 0; c.insets = new Insets(0, 0, 0, 0); wrapper.add( textField, c); parent.add(wrapper); } else { parent.add(textField); } textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height)); textField.revalidate(); }