Search in sources :

Example 16 with JEditorPane

use of javax.swing.JEditorPane in project jdk8u_jdk by JetBrains.

the class bug7189299 method setup.

private static void setup() {
    /**
         * Note the input type is not restricted to "submit". Types "image",
         * "checkbox", "radio" have the same problem.
         */
    html = new JEditorPane("text/html", "<html><body><form action=\"http://localhost.cgi\">" + "<input type=submit name=submit value=\"submit\"/>" + "</form></body></html>");
    frame = new JFrame();
    frame.setLayout(new BorderLayout());
    frame.add(html, BorderLayout.CENTER);
    frame.setSize(200, 100);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
Also used : BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane)

Example 17 with JEditorPane

use of javax.swing.JEditorPane in project processdash by dtuma.

the class AboutDialog method getEditorPane.

private Component getEditorPane(String href) {
    try {
        String url = Browser.mapURL(href);
        JEditorPane editorPane = new JEditorPane(new URL(url));
        editorPane.setEditable(false);
        editorPane.addHyperlinkListener(this);
        editorPane.setAlignmentX(Component.CENTER_ALIGNMENT);
        return editorPane;
    } catch (IOException e) {
        e.printStackTrace();
        return new JLabel();
    }
}
Also used : JEditorPane(javax.swing.JEditorPane) JLabel(javax.swing.JLabel) IOException(java.io.IOException) URL(java.net.URL)

Example 18 with JEditorPane

use of javax.swing.JEditorPane in project cayenne by apache.

the class ErrorDebugDialog method init.

protected void init() {
    setResizable(false);
    Container pane = this.getContentPane();
    pane.setLayout(new BorderLayout());
    // info area
    JEditorPane infoText = new JEditorPane("text/html", infoHTML());
    infoText.setBackground(pane.getBackground());
    infoText.setEditable(false);
    // popup hyperlinks
    infoText.addHyperlinkListener(this);
    JPanel infoPanel = new JPanel();
    infoPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    infoPanel.add(infoText);
    pane.add(infoPanel, BorderLayout.NORTH);
    // exception area
    if (throwable != null) {
        exText.setEditable(false);
        exText.setLineWrap(true);
        exText.setWrapStyleWord(true);
        exText.setRows(16);
        exText.setColumns(40);
        JScrollPane exScroll = new JScrollPane(exText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        exPanel = new JPanel();
        exPanel.setLayout(new BorderLayout());
        exPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        exPanel.add(exScroll, BorderLayout.CENTER);
        // buttons
        showHide = new JButton("");
        showHide.addActionListener(this);
        if (isDetailed()) {
            showDetails();
        } else {
            hideDetails();
        }
    }
    close = new JButton("Close");
    close.addActionListener(this);
    JButton[] buttons = (showHide != null) ? new JButton[] { showHide, close } : new JButton[] { close };
    pane.add(PanelFactory.createButtonPanel(buttons), BorderLayout.SOUTH);
    // add a listener to clear static variables, not to produce garbage
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            instance = null;
        }
    });
    // prepare to display
    this.pack();
    this.centerWindow();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JEditorPane(javax.swing.JEditorPane) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter)

Example 19 with JEditorPane

use of javax.swing.JEditorPane in project suite by stupidsing.

the class EditorController method load.

private void load(String filename) {
    String text = FileUtil.read(filename);
    JEditorPane editor = view.getEditor();
    editor.setText(text);
    editor.setCaretPosition(0);
    editor.requestFocusInWindow();
    model.changeFilename(filename);
    model.changeIsModified(false);
}
Also used : JEditorPane(javax.swing.JEditorPane)

Example 20 with JEditorPane

use of javax.swing.JEditorPane in project suite by stupidsing.

the class EditorController method unixFilter.

public void unixFilter() {
    JFrame frame = view.getFrame();
    JEditorPane editor = view.getEditor();
    String command = // 
    JOptionPane.showInputDialog(// 
    frame, "Enter command:", "Unix Filter", JOptionPane.PLAIN_MESSAGE);
    try {
        Process process = Runtime.getRuntime().exec(command);
        try (OutputStream pos = process.getOutputStream();
            Writer writer = new OutputStreamWriter(pos, Constants.charset)) {
            writer.write(editor.getText());
        }
        process.waitFor();
        editor.setText(To.string(process.getInputStream()));
    } catch (IOException | InterruptedException ex) {
        Fail.t(ex);
    }
}
Also used : JFrame(javax.swing.JFrame) OutputStream(java.io.OutputStream) JEditorPane(javax.swing.JEditorPane) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

JEditorPane (javax.swing.JEditorPane)60 JScrollPane (javax.swing.JScrollPane)22 Dimension (java.awt.Dimension)12 JPanel (javax.swing.JPanel)12 IOException (java.io.IOException)11 JButton (javax.swing.JButton)11 JLabel (javax.swing.JLabel)11 JFrame (javax.swing.JFrame)10 GridBagLayout (java.awt.GridBagLayout)9 GridBagConstraints (java.awt.GridBagConstraints)8 JDialog (javax.swing.JDialog)7 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 BorderLayout (java.awt.BorderLayout)5 JTextField (javax.swing.JTextField)5 HyperlinkListener (javax.swing.event.HyperlinkListener)5 StyledEditorKit (javax.swing.text.StyledEditorKit)5 JCheckBox (javax.swing.JCheckBox)4 JSplitPane (javax.swing.JSplitPane)4 JTree (javax.swing.JTree)4 Component (java.awt.Component)3