Example usage for javax.swing JEditorPane setEditable

List of usage examples for javax.swing JEditorPane setEditable

Introduction

In this page you can find the example usage for javax.swing JEditorPane setEditable.

Prototype

@BeanProperty(description = "specifies if the text can be edited")
public void setEditable(boolean b) 

Source Link

Document

Sets the specified boolean to indicate whether or not this TextComponent should be editable.

Usage

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("EditorPane Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    try {/* w  w w .  j a  va  2 s.c o m*/
        JEditorPane editorPane = new JEditorPane("http://www.java2s.com");
        editorPane.setEditable(false);
        URL url = editorPane.getPage();

        JScrollPane scrollPane = new JScrollPane(editorPane);
        frame.add(scrollPane);
    } catch (IOException e) {
        System.err.println("Unable to load: " + e);
    }

    frame.setSize(640, 480);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JEditorPane editor = new JEditorPane("text/html", "<H1>A!</H1><P><FONT COLOR=blue>blue</FONT></P>");
    editor.setEditable(false);
    JScrollPane pane = new JScrollPane(editor);
    JFrame f = new JFrame("HTML Demo");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(pane);/*from   w  ww  .  j  a v  a  2  s  . c  o  m*/
    f.setSize(800, 600);
    f.setVisible(true);
}

From source file:ActivatedHyperlinkListener.java

public static void main(String args[]) {
    JFrame frame = new JFrame("EditorPane Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    try {//from w w w . j a  va  2  s  . c om
        JEditorPane editorPane = new JEditorPane("http://www.google.com");
        editorPane.setEditable(false);

        HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(editorPane);
        editorPane.addHyperlinkListener(hyperlinkListener);
        JScrollPane scrollPane = new JScrollPane(editorPane);
        frame.add(scrollPane);
    } catch (IOException e) {
        System.err.println("Unable to load: " + e);
    }

    frame.setSize(640, 480);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("EditorPane Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    try {//from  ww w  .  j a va2 s.  com
        JEditorPane editorPane = new JEditorPane("http://www.java2s.com");
        editorPane.setEditable(false);

        HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(editorPane);
        editorPane.addHyperlinkListener(hyperlinkListener);

        JScrollPane scrollPane = new JScrollPane(editorPane);
        frame.add(scrollPane);
    } catch (IOException e) {
        System.err.println("Unable to load: " + e);
    }

    frame.setSize(640, 480);
    frame.setVisible(true);
}

From source file:FileTableHTML.java

public static void main(String[] args) throws IOException {
    // Get the name of the directory to display
    String dirname = (args.length > 0) ? args[0] : System.getProperty("user.home");

    // Create something to display it in.
    final JEditorPane editor = new JEditorPane();
    editor.setEditable(false); // we're browsing not editing
    editor.setContentType("text/html"); // must specify HTML text
    editor.setText(makeHTMLTable(dirname)); // specify the text to display

    // Set up the JEditorPane to handle clicks on hyperlinks
    editor.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            // Handle clicks; ignore mouseovers and other link-related events
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                // Get the HREF of the link and display it.
                editor.setText(makeHTMLTable(e.getDescription()));
            }//from   w  w  w. java  2s  .com
        }
    });

    // Put the JEditorPane in a scrolling window and display it.
    JFrame frame = new JFrame("FileTableHTML");
    frame.getContentPane().add(new JScrollPane(editor));
    frame.setSize(650, 500);
    frame.setVisible(true);
}

From source file:EditorPaneSample.java

public static void main(String args[]) throws IOException {
    JFrame frame = new JFrame("EditorPane Example");
    Container content = frame.getContentPane();

    JEditorPane editorPane = new JEditorPane("http://www.apress.com");
    editorPane.setEditable(false);

    HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(frame, editorPane);
    editorPane.addHyperlinkListener(hyperlinkListener);

    JScrollPane scrollPane = new JScrollPane(editorPane);
    content.add(scrollPane);// ww  w .j  a v a2  s. co  m

    frame.setSize(640, 480);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("EditorPane Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    try {/*from  ww  w  .j  a  v a  2  s.co  m*/
        JEditorPane editorPane = new JEditorPane(new URL("http://www.java2s.com"));
        editorPane.setEditable(false);

        HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(editorPane);
        editorPane.addHyperlinkListener(hyperlinkListener);

        JScrollPane scrollPane = new JScrollPane(editorPane);
        frame.add(scrollPane);
    } catch (IOException e) {
        System.err.println("Unable to load: " + e);
    }

    frame.setSize(640, 480);
    frame.setVisible(true);
}

From source file:LoadSync.java

public static void main(String args[]) {
    final String filename = "Test.html";
    JFrame frame = new JFrame("Loading/Saving Example");
    Container content = frame.getContentPane();

    final JEditorPane editorPane = new JEditorPane();
    editorPane.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(editorPane);
    content.add(scrollPane, BorderLayout.CENTER);

    editorPane.setEditorKit(new HTMLEditorKit());

    JPanel panel = new JPanel();

    // Setup actions
    Action loadAction = new AbstractAction() {
        {//from  w w  w. j a v  a2  s .  c o m
            putValue(Action.NAME, "Load");
        }

        public void actionPerformed(ActionEvent e) {
            doLoadCommand(editorPane, filename);
        }
    };
    JButton loadButton = new JButton(loadAction);
    panel.add(loadButton);

    content.add(panel, BorderLayout.SOUTH);

    frame.setSize(250, 150);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("JEditorPane Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JEditorPane editor = new JEditorPane("text/html",
            "<H3>Help</H3><center>www.java2s.com</center><li>One<li><i>Two</i><li><u>Three</u>");
    editor.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(editor);
    f.add(scrollPane, BorderLayout.CENTER);
    f.setSize(300, 200);/*from w ww. j  av  a2 s  .co  m*/
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JEditorPane Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = f.getContentPane();
    JEditorPane editor = new JEditorPane("text/html",
            "<H3>Help</H3><center><IMG src=file:///c:/a.jpg></center><li>One<li><i>Two</i><li><u>Three</u>");
    editor.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(editor);
    content.add(scrollPane, BorderLayout.CENTER);
    f.setSize(300, 200);//w  w w .  j  a va 2  s.  c  o  m
    f.setVisible(true);
}