Example usage for javax.swing JTextField setEnabled

List of usage examples for javax.swing JTextField setEnabled

Introduction

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

Prototype

@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.")
public void setEnabled(boolean enabled) 

Source Link

Document

Sets whether or not this component is enabled.

Usage

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  ww .  j a  va 2s .  c o  m
        });
        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 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());
            }/*w w  w . j a  va2  s.c o m*/
        });
        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;
}