Java Code Examples for javax.swing.JFormattedTextField#setFont()
The following examples show how to use
javax.swing.JFormattedTextField#setFont() .
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: 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) ); }