Example usage for javax.swing JEditorPane setEnabled

List of usage examples for javax.swing JEditorPane setEnabled

Introduction

In this page you can find the example usage for javax.swing JEditorPane 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:EditorDropTarget3.java

public static void main(String[] args) {
    try {//from  ww w .  ja  v  a2 s .  co  m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    final JFrame f = new JFrame("JEditor Pane Drop Target Example 3");

    final JEditorPane pane = new JEditorPane();

    // Add a drop target to the JEditorPane
    EditorDropTarget3 target = new EditorDropTarget3(pane);

    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });

    JPanel panel = new JPanel();
    final JCheckBox editable = new JCheckBox("Editable");
    editable.setSelected(true);
    panel.add(editable);
    editable.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editable.isSelected());
        }
    });

    final JCheckBox enabled = new JCheckBox("Enabled");
    enabled.setSelected(true);
    panel.add(enabled);
    enabled.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEnabled(enabled.isSelected());
        }
    });

    f.getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER);
    f.getContentPane().add(panel, BorderLayout.SOUTH);
    f.setSize(500, 400);
    f.setVisible(true);
}

From source file:EditorDropTarget4.java

public static void main(String[] args) {
    try {/*w ww.  j a va2 s . c o m*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    final JFrame f = new JFrame("JEditor Pane Drop Target Example 4");

    // Create an editor with autoscrolling support
    final JEditorPane pane = new AutoScrollingEditorPane();

    // Add a drop target to the JEditorPane
    EditorDropTarget4 target = new EditorDropTarget4(pane);

    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });

    JPanel panel = new JPanel();
    final JCheckBox editable = new JCheckBox("Editable");
    editable.setSelected(true);
    panel.add(editable);
    editable.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editable.isSelected());
        }
    });

    final JCheckBox enabled = new JCheckBox("Enabled");
    enabled.setSelected(true);
    panel.add(enabled);
    enabled.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEnabled(enabled.isSelected());
        }
    });

    f.getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER);
    f.getContentPane().add(panel, BorderLayout.SOUTH);
    f.setSize(500, 400);
    f.setVisible(true);
}

From source file:net.sf.texprinter.utils.UIUtils.java

/**
 * Format an editor to act as a label. I decided to replace all the
 * occurrences of multiline JLabel's to JEditorPane's instead, so I
 * want them to look exactly like ordinary JLabels.
 * //from  w  w w . ja v  a  2 s  . com
 * @param editor The editor to be formatted as a label.
 */
public static void formatEditorPaneAsLabel(JEditorPane editor) {

    // disable it
    editor.setEnabled(false);

    // make it read only
    editor.setEditable(false);

    // transparent
    editor.setOpaque(false);

    // set the disabled color as black
    editor.setDisabledTextColor(Color.BLACK);
}