Example usage for javax.swing JEditorPane JEditorPane

List of usage examples for javax.swing JEditorPane JEditorPane

Introduction

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

Prototype

public JEditorPane(String url) throws IOException 

Source Link

Document

Creates a JEditorPane based on a string containing a URL specification.

Usage

From source file:mondrian.gui.Workbench.java

private void aboutMenuItemActionPerformed(ActionEvent evt) {
    try {/*from ww w . j av a 2 s  . c o m*/
        JEditorPane jEditorPane = new JEditorPane(
                myClassLoader.getResource(getResourceConverter().getGUIReference("version")).toString());
        jEditorPane.setEditable(false);
        JScrollPane jScrollPane = new JScrollPane(jEditorPane);
        JPanel jPanel = new JPanel();
        jPanel.setLayout(new java.awt.BorderLayout());
        jPanel.add(jScrollPane, java.awt.BorderLayout.CENTER);

        JInternalFrame jf = new JInternalFrame();
        jf.setTitle("About");
        jf.getContentPane().add(jPanel);

        Dimension screenSize = this.getSize();
        int aboutW = 400;
        int aboutH = 300;
        int width = (screenSize.width / 2) - (aboutW / 2);
        int height = (screenSize.height / 2) - (aboutH / 2) - 100;
        jf.setBounds(width, height, aboutW, aboutH);
        jf.setClosable(true);

        desktopPane.add(jf);

        jf.setVisible(true);
        jf.show();
    } catch (Exception ex) {
        LOGGER.error("aboutMenuItemActionPerformed", ex);
    }
}

From source file:org.apache.commons.jelly.demos.HomepageBuilder.java

void showPage() {

    //open new window
    JFrame frame = new JFrame("Your Homepage");

    //add html pane
    try {/*from w w w .j a  va2 s . com*/

        URL url = resolveURL("demopage.html");
        JEditorPane htmlPane = new JEditorPane(url);
        htmlPane.setEditable(false);
        frame.setContentPane(new JScrollPane(htmlPane));

    } catch (Exception ioe) {
        System.err.println("Error displaying page");
    }

    frame.pack();
    frame.setSize(500, 500);
    frame.setVisible(true);

}

From source file:org.apache.tika.gui.TikaGUI.java

private void addWelcomeCard(JPanel panel, String name) {
    try {//  w  w w  .  ja  va 2 s  .  com
        JEditorPane editor = new JEditorPane(TikaGUI.class.getResource("welcome.html"));
        editor.setContentType("text/html");
        editor.setEditable(false);
        editor.setBackground(Color.WHITE);
        editor.setTransferHandler(new ParsingTransferHandler(editor.getTransferHandler(), this));
        panel.add(new JScrollPane(editor), name);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.apache.tika.gui.TikaGUI.java

private void textDialog(String title, URL resource) {
    try {//from  w w w .ja  va  2 s . co  m
        JDialog dialog = new JDialog(this, title);
        JEditorPane editor = new JEditorPane(resource);
        editor.setContentType("text/html");
        editor.setEditable(false);
        editor.setBackground(Color.WHITE);
        editor.setPreferredSize(new Dimension(400, 250));
        editor.addHyperlinkListener(this);
        dialog.add(editor);
        dialog.pack();
        dialog.setVisible(true);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.ayound.js.debug.ui.DebugMainFrame.java

private void initAction() {
    actionOpen = new AbstractAction(Messages.getString("DebugMainFrame.Open")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser(); // 
            fileDialog.setFileFilter(new FileFilter() {

                @Override//from w  w  w .  j av a 2 s .  c o  m
                public boolean accept(File f) {
                    String fileName = f.getName().toLowerCase();
                    if (fileName.endsWith(".htm") //$NON-NLS-1$
                            || fileName.endsWith(".html") //$NON-NLS-1$
                            || fileName.endsWith(".js") || f.isDirectory()) { //$NON-NLS-1$
                        return true;
                    } else {
                        return false;
                    }

                }

                @Override
                public String getDescription() {
                    return ".htm,.html,.js"; //$NON-NLS-1$
                }
            });
            int result = fileDialog.showOpenDialog(DebugMainFrame.this);
            if (result == JFileChooser.APPROVE_OPTION) {
                openHtmlFile(fileDialog.getSelectedFile());
            }

        }
    };
    actionClose = new AbstractAction(Messages.getString("DebugMainFrame.Close")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            int index = mainPane.getSelectedIndex();
            if (index > -1) {
                mainPane.remove(index);
            }
        }
    };
    actionExit = new AbstractAction(Messages.getString("DebugMainFrame.Exit")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    };
    ImageIcon startIcon = new ImageIcon(DebugMainFrame.class.getResource("icons/launch_run.gif")); //$NON-NLS-1$
    actionDebugStart = new AbstractAction(Messages.getString("DebugMainFrame.Start"), startIcon) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            startDebug();
        }
    };
    ImageIcon endIcon = new ImageIcon(DebugMainFrame.class.getResource("icons/terminate_co.gif")); //$NON-NLS-1$
    actionDebugEnd = new AbstractAction(Messages.getString("DebugMainFrame.End"), endIcon) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            endDebug();
        }
    };
    actionDebugEnd.setEnabled(false);
    actionHelp = new AbstractAction(Messages.getString("DebugMainFrame.Content")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            String locale = DebugMainFrame.this.getLocale().toString();
            String helpPath = "help/index_" + locale + ".html";
            File testFile = new File(new File(getBaseDir()), helpPath); //$NON-NLS-1$
            final String url = "file:///" + testFile.getAbsolutePath().replace('\\', '/'); //$NON-NLS-1$

            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    try {
                        // TODO Auto-generated method stub
                        JFrame someWindow = new JFrame();
                        JEditorPane htmlPane = new JEditorPane(url);
                        htmlPane.setEditable(false);
                        someWindow.setSize(800, 600);
                        someWindow.setExtendedState(JFrame.MAXIMIZED_BOTH);
                        someWindow.setVisible(true);
                        someWindow.add(new JScrollPane(htmlPane));
                    } catch (IOException ioe) {
                        System.err.println(Messages.getString("DebugMainFrame.ErrorDisplay") + url); //$NON-NLS-1$
                    }
                }
            });

        }
    };
    actionAbout = new AbstractAction(Messages.getString("DebugMainFrame.About")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(DebugMainFrame.this,
                    Messages.getString("DebugMainFrame.AboutContent"), //$NON-NLS-1$
                    Messages.getString("DebugMainFrame.ApplicationName"), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
        }
    };
    actionLanguageChinese = new AbstractAction("Chinese") {

        public void actionPerformed(ActionEvent e) {
            DebugUIUtil.updateUI(Locale.SIMPLIFIED_CHINESE);
        }
    };
    actionLanguageEnglish = new AbstractAction("English") {

        public void actionPerformed(ActionEvent e) {
            DebugUIUtil.updateUI(Locale.ENGLISH);
        }
    };
}