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:Main.java

public static void setEnabled(JTextField textField, boolean b) {
    textField.setEditable(b);/*from   w ww . j  a v a  2s .c o  m*/
    textField.setEnabled(b);
}

From source file:Main.java

public static JTextField createTextField(Dimension preferredSize, KeyAdapter keyListener, boolean enabled) {
    JTextField textField = new JTextField();
    textField.setPreferredSize(preferredSize);
    textField.addKeyListener(keyListener);
    textField.setEnabled(enabled);
    return textField;
}

From source file:OAT.ui.util.UiUtil.java

public static void triggerTextField(JTextField textField, JCheckBox checkBox) {
    if (checkBox.isSelected()) {
        textField.setDisabledTextColor(Color.LIGHT_GRAY);
    }//from   www . j a  v a  2 s.  c  o m

    textField.setEnabled(!checkBox.isSelected());
}

From source file:Main.java

protected void addFields(GridBagConstraints gbc) {
    JTextField field1 = new JTextField("0", 5);
    field1.setEnabled(false);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx++;/*from ww  w.  j  a va2 s .  c om*/
    add(field1, gbc);
    gbc.gridx++;
    gbc.insets = new Insets(0, 4, 0, 4);
    add(new JLabel("+"), gbc);
    JTextField field2 = new JTextField(5);
    gbc.gridx++;
    add(field2, gbc);
}

From source file:com.eviware.soapui.support.editor.inspectors.auth.ExpirationTimeChooser.java

private JTextField createTimeTextField(boolean enableManualTimeControls) {
    JTextField timeTextField = new JTextField(5);
    timeTextField.setName(TIME_FIELD_NAME);
    timeTextField.setHorizontalAlignment(JTextField.RIGHT);

    timeTextField.setEnabled(enableManualTimeControls);

    String manualAccessTokenExpirationTime = profile.getManualAccessTokenExpirationTime();
    if (manualAccessTokenExpirationTime == null) {
        timeTextField.setText("");
    } else {// w  ww.j a  va  2 s  .  c om
        timeTextField.setText(manualAccessTokenExpirationTime);
    }
    return timeTextField;
}

From source file:com.emental.mindraider.ui.dialogs.OpenConceptByTagJDialog.java

public OpenConceptByTagJDialog(String dialogTitle, String selectionLabel, String buttonLabel,
        boolean showCancel) {
    super(dialogTitle);

    JPanel framePanel = new JPanel();
    framePanel.setBorder(new EmptyBorder(5, 10, 0, 10));
    framePanel.setLayout(new BorderLayout());

    // NORTH panel
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BorderLayout());
    northPanel.add(new JLabel(selectionLabel), BorderLayout.NORTH);

    final JTextField tagLabel = new JTextField(TEXTFIELD_WIDTH);

    // data/*  ww  w .ja v a2 s.  c om*/
    tags = MindRaider.tagCustodian.getAllTags();
    ;
    if (tags == null) {
        tagLabel.setEnabled(false);
    }
    tagLabel.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                logger.debug("Openning selected tag...");
                openTagSearchDialog();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
            getListModel().clear();
            shownTags.clear();
            if (tagLabel.getText().length() > 0) {
                for (TagEntry tag : tags) {
                    if (tag.getTagLabel().toLowerCase().startsWith(tagLabel.getText().toLowerCase())) {
                        getListModel().addElement(tag.getTagLabel() + " (" + tag.getCardinality() + ")");
                        shownTags.add(tag);
                    }
                }
            } else {
                // show all tags
                for (TagEntry tag : tags) {
                    getListModel().addElement(tag.getTagLabel() + " (" + tag.getCardinality() + ")");
                    shownTags.add(tag);
                }
            }
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    northPanel.add(tagLabel, BorderLayout.SOUTH);
    framePanel.add(northPanel, BorderLayout.NORTH);

    // CENTER panel
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BorderLayout());
    centerPanel.add(new JLabel(Messages.getString("OpenConceptByTagJDialog.matchingTags")), BorderLayout.NORTH);

    defaultListModel = new DefaultListModel();
    list = new JList(defaultListModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    // list.addListSelectionListener(this);
    list.setVisibleRowCount(15);
    JScrollPane listScrollPane = new JScrollPane(list);
    centerPanel.add(listScrollPane, BorderLayout.SOUTH);
    framePanel.add(centerPanel, BorderLayout.CENTER);

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton openButton = new JButton(buttonLabel);
    southPanel.add(openButton);
    openButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            openTagSearchDialog();
        }
    });

    if (showCancel) {
        JButton cancelButton = new JButton(Messages.getString("OpenNotebookJDialog.cancel"));
        southPanel.add(cancelButton);
        cancelButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                OpenConceptByTagJDialog.this.dispose();
            }
        });
    }

    framePanel.add(southPanel, BorderLayout.SOUTH);

    getContentPane().add(framePanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:com.igormaznitsa.zxpspritecorrector.files.FileNameDialog.java

private void processZxFileType(final JTextField field, final char[] array, final int index) {
    if (array == null || array[index] == 0) {
        field.setEnabled(false);
    } else {/*from  w  w w.  java 2  s . co m*/
        field.setText(Character.toString(array[index]));
    }
}

From source file:cool.pandora.modeller.ui.jpanel.iiif.UploadBagFrame.java

private JPanel createComponents() {
    final Border border = new EmptyBorder(5, 5, 5, 5);

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();/*from  w ww.  ja va 2 s .  c  om*/
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("UploadBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Upload Resources " + "to:")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    final JPanel contentPane = new JPanel();
    final DefaultBag bag = bagView.getBag();

    if (bag != null) {
        map = bag.getInfo().getFieldMap();
    }

    final JLabel urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    final JTextField urlField = new JTextField("");
    final URI uri = IIIFObjectURI.getResourceContainerURI(map);
    try {
        urlField.setText(uri != null ? uri.toString() : null);
    } catch (Exception e) {
        log.error("Failed to set url label", e);
    }
    urlField.setEnabled(false);

    //only if bag is not null
    if (bag != null) {
        urlLabel.setEnabled(true);
    }

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:com.igormaznitsa.zxpspritecorrector.files.FileNameDialog.java

private void processFileName(final JTextField field, final String[] array, final int index) {
    if (array == null || array[index] == null) {
        field.setEnabled(false);
    } else {//from   w  w w . ja va2  s  .c o  m
        field.setText(array[index]);
    }
}

From source file:com.igormaznitsa.zxpspritecorrector.files.FileNameDialog.java

private void processZxFileName(final JTextField field, final String[] array, final int index) {
    if (array == null || array[index] == null) {
        field.setEnabled(false);
    } else {//w  w  w.  j a  va  2 s.c o  m
        field.setText(array[index]);
    }
}