Refine search
mavenTextField = new JTextField(15); mavenTextField.setMinimumSize(mavenTextField.getPreferredSize()); mavenLabel.setForeground(new Color(170, 170, 170)); mavenDesc.setForeground(new Color(170, 170, 170));
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(new JLabel("Name:")); nameField = new JTextField(System.getProperty("user.name", "yourname")); Dimension d = nameField.getPreferredSize(); nameField.setMaximumSize(new Dimension(120, d.height + 6)); p.add(nameField); p.add(new JLabel(" Message:")); messageField = new JTextField(); p.add(messageField); p.add(new JButton(new SendAction(true)));
public void mousePressed(MouseEvent e) { super.mousePressed(e); JTextField field = new JTextField("test"); Dimension d = field.getPreferredSize(); field.setBounds(e.getX(), e.getY(), d.width, d.height); add(field);
public static int getDefaultSpinnerHeight() { if (defaultSpinnerHeight == -1) { defaultSpinnerHeight = new JTextField().getPreferredSize().height; } return defaultSpinnerHeight; }
public void adjustWidthToMaximumValue() { final JTextField testTextField = new JTextField(Integer.toString(max)); final int width = testTextField.getPreferredSize().width; final int height = testTextField.getPreferredSize().height; textField.setPreferredSize(new Dimension(width, height)); textField.revalidate(); }
public static JTextField makeTextField() { JTextField textField = new JTextField(48); int prefHeight = textField.getPreferredSize().height; textField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prefHeight)); textField.setEditable(false); return textField; }
public static JTextField makeTextField() { JTextField textField = new JTextField(48); int prefHeight = textField.getPreferredSize().height; textField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prefHeight)); textField.setEditable(false); return textField; }
@Override public Dimension getPreferredSize() { Runtime.getRuntime().maxMemory(); Dimension size1 = getXEditorButton().getPreferredSize(); Dimension size2 = new JTextField(1).getPreferredSize(); int height = Math.max(size1.height, size2.height); return new Dimension(3 * height, height); }
menuBar.add(Box.createHorizontalGlue()); JTextField textField = new JTextField(10); textField.setMaximumSize( textField.getPreferredSize() ); menuBar.add(textField);
JTextField tf = new JTextField(10); Dimension d = tf.getPreferredSize(); tf.setBounds(x, y, d.width, d.height);
private JPanel createEolBytePanel() { JLabel label = new JLabel(JMeterUtils.getResString("eolbyte")); //$NON-NLS-1$ eolByte = new JTextField(3); // 3 columns size eolByte.setMaximumSize(new Dimension(eolByte.getPreferredSize())); label.setLabelFor(eolByte); JPanel eolBytePanel = new JPanel(new FlowLayout()); eolBytePanel.add(label); eolBytePanel.add(eolByte); return eolBytePanel; }
private JPanel createSoLingerOption() { JLabel label = new JLabel(JMeterUtils.getResString("solinger")); //$NON-NLS-1$ soLinger = new JTextField(5); // 5 columns size soLinger.setMaximumSize(new Dimension(soLinger.getPreferredSize())); label.setLabelFor(soLinger); JPanel soLingerPanel = new JPanel(new FlowLayout()); soLingerPanel.add(label); soLingerPanel.add(soLinger); return soLingerPanel; }
JTextField txt = new JTextField(10); // we add a new button //txt.setPreferredSize(dim); // don't hardcode a preferrd size of a component. txt.setMaximumSize(txt.getPreferredSize());
public AbstractTextFieldFilter(String id, String name, int width, boolean useDefault, String defaultValue) { super(); this.id = id; this.name = name; textField = new JTextField(); textField.setPreferredSize(new Dimension(width, textField.getPreferredSize().height)); textField.getDocument().addDocumentListener(new MyDocumentListener()); if (useDefault) { defaultTextField = new JTextField(); defaultTextField.setPreferredSize(new Dimension(width, defaultTextField.getPreferredSize().height)); setDefaultValue(defaultValue); } initialize(); }
private void initComponents() { setLayout(new GridBagLayout()); textField = new JTextField(); textField.getDocument().addDocumentListener(this); textField.addFocusListener(this); textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height)); add(textField, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); foreverCheckBox = new JCheckBox(); Mnemonics.setLocalizedText(foreverCheckBox, NbBundle.getMessage(PropertyEditorGaugeMaxValue.class, "LBL_MAX_VALUE_INDEFINITE")); // NOI18N foreverCheckBox.addActionListener(this); foreverCheckBox.addFocusListener(this); add(foreverCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0)); add(new JPanel(), new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); }
/** * Create a GUI panel containing the components related to the number of * seconds which should be executed. * * @return a GUI panel containing the loop count components */ private JPanel createLoopCountPanel() { JPanel loopPanel = new JPanel(new BorderLayout(5, 0)); // SECONDS LABEL JLabel secondsLabel = new JLabel(JMeterUtils.getResString("runtime_seconds")); // $NON-NLS-1$ loopPanel.add(secondsLabel, BorderLayout.WEST); JPanel loopSubPanel = new JPanel(new BorderLayout(5, 0)); // TEXT FIELD seconds = new JTextField("1", 5); // $NON-NLS-1$ secondsLabel.setLabelFor(seconds); loopSubPanel.add(seconds, BorderLayout.CENTER); loopPanel.add(loopSubPanel, BorderLayout.CENTER); loopPanel.add(Box.createHorizontalStrut(secondsLabel.getPreferredSize().width + seconds.getPreferredSize().width), BorderLayout.NORTH); return loopPanel; }
/** * Create a GUI panel containing the lockName * * @return a GUI panel containing the lock name components */ private JPanel createCriticalSectionPanel() { JPanel conditionPanel = new JPanel(new BorderLayout(5, 0)); // Condition LABEL JLabel conditionLabel = new JLabel( JMeterUtils.getResString("critical_section_controller_label")); // $NON-NLS-1$ conditionPanel.add(conditionLabel, BorderLayout.WEST); // TEXT FIELD tfLockName = new JTextField(""); // $NON-NLS-1$ conditionLabel.setLabelFor(tfLockName); conditionPanel.add(tfLockName, BorderLayout.CENTER); conditionPanel .add(Box.createHorizontalStrut(conditionLabel .getPreferredSize().width + tfLockName.getPreferredSize().width), BorderLayout.NORTH); return conditionPanel; } }
private void initContentPanel(java.util.List<String> labels) { textComponents = new HashMap<String, JTextField>(labels.size()); contentPanel.setLayout(new GridLayout(labels.size(), 2, 5, 5)); int width = 0; int height = 0; for (String l : labels) { JTextField field = new JTextField(); textComponents.put(l, field); final JLabel jlabel = new JLabel(l); contentPanel.add(jlabel); contentPanel.add(field); Dimension d = jlabel.getPreferredSize(); width = Math.max(width, (int) d.getWidth()); double h2 = (int) field.getPreferredSize().getHeight(); height += (int) Math.max(h2, d.getHeight()) + 5; } // Why is setting size explicitly neccessary? width = width*2 + 20; height += 20; contentPanel.setSize(width, height); contentPanel.setPreferredSize(new Dimension(width, height)); pack(); }
JTextField textField = new JTextField(2); textField.setSize( textField.getPreferredSize() ); textField.setLocation( mouseEvent.getPoint() ); panel.add( textField ); panel.repaint();
public JTextFieldTest() { this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String s = "It was an Abyssinian maid, and on her dulcimer she played,"; JTextField tf = new JTextField(s); tf.setFont(new Font("Serif", Font.PLAIN, 24)); tf.validate(); int h = tf.getPreferredSize().height; tf.getCaret().setDot(0); this.setPreferredSize(new Dimension(240, h)); this.add(tf); }