Example usage for javax.swing JTextField setText

List of usage examples for javax.swing JTextField setText

Introduction

In this page you can find the example usage for javax.swing JTextField setText.

Prototype

@BeanProperty(bound = false, description = "the text of this component")
public void setText(String t) 

Source Link

Document

Sets the text of this TextComponent to the specified text.

Usage

From source file:verdandi.ui.settings.DefaultSettingsPanel.java

private JPanel getPersistenceSettingsPanel() {
    JPanel res = new JPanel(new GridBagLayout());
    res.setBorder(BorderFactory.createTitledBorder(RC.getString("settingseditor.persistence.title")));

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.gridy = 0;//from w  w  w .  jav a2 s.c om
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.WEST;

    PersistenceConfigurationDescription pdc = conf.getPersistenceConfigurationDescription();
    if (pdc == null) {
        return res;
    }

    for (String key : pdc.getOrderedKeys()) {
        c.weightx = 0.1;
        c.gridx = 0;
        c.fill = GridBagConstraints.NONE;
        JLabel lbl = new JLabel(pdc.get(key).getName());
        lbl.setToolTipText(pdc.get(key).getDescription());
        res.add(lbl, c);
        c.gridx = 1;
        c.weightx = 1.0;
        c.fill = GridBagConstraints.HORIZONTAL;
        JTextField txt = new JTextField(20);
        txt.setText(conf.getString(pdc.get(key).getConfigKey()));
        res.add(txt, c);
        persistenceFields.put(pdc.get(key).getConfigKey(), txt);
        c.gridy++;
    }

    return res;
}

From source file:visolate.Visolate.java

private JPanel getInitialXPanel() {
    if (myInitialXPanel == null) {
        myInitialXPanel = new JPanel();
        myInitialXPanel.setLayout(new BorderLayout());
        myInitialXPanel.add(new JLabel("X"), BorderLayout.WEST);
        myInitialXPanel.setToolTipText("Left side is at this coordinate (mm or inch)");
        myInitialXPanel.setEnabled(gCodeWriter.getIsAbsolute());
        final JTextField field = new JTextField(NumberFormat.getInstance().format(gCodeWriter.getXOffset()));
        myInitialXPanel.add(field, BorderLayout.CENTER);
        myInitialXPanel.addPropertyChangeListener("enabled", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                field.setEnabled(myInitialXPanel.isEnabled());
            }/* w w  w .  j a va2s . c o  m*/
        });
        field.setEnabled(myInitialXPanel.isEnabled());
        field.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                try {
                    gCodeWriter.setXOffset(NumberFormat.getInstance().parse(field.getText()).doubleValue());
                } catch (ParseException e) {
                }
                field.setText(NumberFormat.getInstance().format(gCodeWriter.getXOffset()));
            }
        });
    }
    return myInitialXPanel;
}

From source file:visolate.Visolate.java

private JPanel getInitialYPanel() {
    if (myInitialYPanel == null) {
        myInitialYPanel = new JPanel();
        myInitialYPanel.setLayout(new BorderLayout());
        myInitialYPanel.add(new JLabel("Y"), BorderLayout.WEST);
        myInitialYPanel.setToolTipText("Upper side is at this coordinates (mm or inch)");
        myInitialYPanel.setEnabled(gCodeWriter.getIsAbsolute());
        final JTextField field = new JTextField(NumberFormat.getInstance().format(gCodeWriter.getYOffset()));
        myInitialYPanel.add(field, BorderLayout.CENTER);
        myInitialYPanel.addPropertyChangeListener("enabled", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                field.setEnabled(myInitialYPanel.isEnabled());
            }/*from w w  w.ja v  a 2s .c om*/
        });
        field.setEnabled(myInitialYPanel.isEnabled());
        field.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                try {
                    gCodeWriter.setYOffset(NumberFormat.getInstance().parse(field.getText()).doubleValue());
                } catch (ParseException e) {
                }
                field.setText(NumberFormat.getInstance().format(gCodeWriter.getYOffset()));
            }
        });
    }
    return myInitialYPanel;
}

From source file:visolate.Visolate.java

private Component getZDownMovementPanel() {
    if (myZDownMovementPanel == null) {
        myZDownMovementPanel = new JPanel();
        myZDownMovementPanel.setLayout(new BorderLayout());
        myZDownMovementPanel.add(new JLabel("travel clearance"), BorderLayout.WEST);
        myZDownMovementPanel.setToolTipText(
                "When not cutting, lift the cutter to this above origin, in mm or inch. Decimals in native language (point or comma).");
        final JTextField field = new JTextField(NumberFormat.getInstance().format(gCodeWriter.getZClearance()));
        myZDownMovementPanel.add(field, BorderLayout.CENTER);
        field.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                try {
                    gCodeWriter.setZClearance(NumberFormat.getInstance().parse(field.getText()).doubleValue());
                } catch (ParseException e) {
                }//from   ww  w  . j  a v a2  s . c o  m
                field.setText(NumberFormat.getInstance().format(gCodeWriter.getZClearance()));
            }
        });
    }
    return myZDownMovementPanel;
}

From source file:visolate.Visolate.java

private JPanel getMillingSpeedPanel() {
    if (myMillingSpeedPanel == null) {
        myMillingSpeedPanel = new JPanel();
        myMillingSpeedPanel.setLayout(new BorderLayout());
        myMillingSpeedPanel.add(new JLabel("cutting feedrate"), BorderLayout.WEST);
        myMillingSpeedPanel.setToolTipText("Feedrate during cutting in mm or inch per minute.");
        final JTextField field = new JTextField(
                NumberFormat.getInstance().format(gCodeWriter.getMillingFeedrate()));
        myMillingSpeedPanel.add(field, BorderLayout.CENTER);
        field.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                try {
                    gCodeWriter.setMillingFeedrate(
                            NumberFormat.getInstance().parse(field.getText()).doubleValue());
                } catch (ParseException e) {
                }//from w  w  w.  ja  va  2  s. c o m
                field.setText(NumberFormat.getInstance().format(gCodeWriter.getMillingFeedrate()));
            }
        });
    }
    return myMillingSpeedPanel;
}

From source file:visolate.Visolate.java

private JPanel getPlungeSpeedPanel() {
    if (myPlungeSpeedPanel == null) {
        myPlungeSpeedPanel = new JPanel();
        myPlungeSpeedPanel.setLayout(new BorderLayout());
        myPlungeSpeedPanel.add(new JLabel("plunge feedrate"), BorderLayout.WEST);
        myPlungeSpeedPanel// w  w  w.j a  v a2s. c  om
                .setToolTipText("Feedrate when moving vertically into the workpiece in mm or inch per minute.");
        final JTextField field = new JTextField(
                NumberFormat.getInstance().format(gCodeWriter.getPlungeFeedrate()));
        myPlungeSpeedPanel.add(field, BorderLayout.CENTER);
        field.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                try {
                    gCodeWriter
                            .setPlungeFeedrate(NumberFormat.getInstance().parse(field.getText()).doubleValue());
                } catch (ParseException e) {
                }
                field.setText(NumberFormat.getInstance().format(gCodeWriter.getPlungeFeedrate()));
            }
        });
    }
    return myPlungeSpeedPanel;
}

From source file:visolate.Visolate.java

private JPanel getZCuttingHeightPanel() {
    if (myZCuttingHeightPanel == null) {
        myZCuttingHeightPanel = new JPanel();
        myZCuttingHeightPanel.setLayout(new BorderLayout());
        myZCuttingHeightPanel.add(new JLabel("cutting height"), BorderLayout.WEST);
        myZCuttingHeightPanel.setToolTipText(
                "When cutting, the head should have this z-coordinate, in mm or inch. Likely a negative value, decimals in native language (point or comma)");
        myZCuttingHeightPanel.setEnabled(gCodeWriter.getIsAbsolute());
        final JTextField field = new JTextField(
                NumberFormat.getInstance().format(gCodeWriter.getZCuttingHeight()));
        myZCuttingHeightPanel.add(field, BorderLayout.CENTER);
        myZCuttingHeightPanel.addPropertyChangeListener("enabled", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                field.setEnabled(myZCuttingHeightPanel.isEnabled());
            }/*from w ww  .  ja  v a 2 s  .  com*/
        });
        field.setEnabled(myZCuttingHeightPanel.isEnabled());
        field.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                try {
                    gCodeWriter
                            .setZCuttingHeight(NumberFormat.getInstance().parse(field.getText()).doubleValue());
                } catch (ParseException e) {
                }
                field.setText(NumberFormat.getInstance().format(gCodeWriter.getZCuttingHeight()));
            }
        });
    }
    return myZCuttingHeightPanel;
}