Examples of XHTMLPanel


Examples of org.xhtmlrenderer.simple.XHTMLPanel

                deferredChangePage(curFrom);
            }
        });

        // Create a JPanel subclass to render the page
        xpanel = new XHTMLPanel();
        xpanel.addDocumentListener(new DefaultDocumentListener() {
            public void documentLoaded() {
                frame.setCursor(Cursor.getDefaultCursor());
            }
        });
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

            frame.setExtendedState(JFrame.NORMAL);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    html = new XHTMLPanel();
                    scroll = new FSScrollPane(html);
                    frame.getContentPane().add(scroll);
                    frame.pack();
                    frame.setSize(1024, 768);
                    frame.setVisible(true);
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

        super.frameInit();
       
        setTitle("CSS Quoting Example");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
       
        XHTMLPanel xr = new XHTMLPanel();
        try {
            xr.setDocument(XMLUtil.documentFromString(DOCUMENT));
        } catch (Exception e) {
            throw new ExceptionInInitializerError(e);
        }
       
        add(xr);
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

    private void run(String[] args) {
        loadAndCheckArgs(args);

        // Create a JPanel subclass to render the page
        XHTMLPanel panel = new XHTMLPanel();

        // Set the XHTML document to render. We use the simplest form
        // of the API call, which uses a File reference. There
        // are a variety of overloads for setDocument().
        try {
            panel.setDocument(new File(fileName));
        } catch (Exception e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }

        // Put our panel in a scrolling pane. You can use
        // a regular JScrollPane here, or our FSScrollPane.
        // FSScrollPane is already set up to move the correct
        // amount when scrolling 1 line or 1 page
        FSScrollPane scroll = new FSScrollPane(panel);

        JFrame frame = new JFrame("Flying Saucer: " + panel.getDocumentTitle());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(scroll);
        frame.pack();
        frame.setSize(1024, 768);
        frame.setVisible(true);
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

    private void launchGUI() {
        final JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Create a JPanel subclass to render the page
        final XHTMLPanel panel = new XHTMLPanel();
        final Dimension orgSize = panel.getSize();

        // we'll add a listener to note the preferred size as calculated by the render engine
        panel.addDocumentListener(new DefaultDocumentListener() {
            public void documentLoaded() {
                frame.setTitle("Flying Saucer: " + panel.getDocumentTitle());

                final Dimension dim = panel.getPreferredSize();
                XRLog.general("Preferred size" + dim);
            }
        });

        frame.getContentPane().add(panel);

        // Set the XHTML document to render. We use the simplest form
        // of the API call, which uses a File reference. There
        // are a variety of overloads for setDocument().
        try {
            panel.setDocument(new File(fileName));
        } catch (Exception e) {
            XRLog.general(Level.WARNING, "Could not load XHTML document " + fileName, e);
            messageAndExit("Failed to load document", -1);
        }

        // No-op as regards size, but has side-effect of making the window and components "displayable". This is
        // necessary for the doDocumentLayout() below to work correctly. Alternately you could setVisible(true), but
        // then the document would be visible before the resize was completed.
        frame.pack();

        // Here we set an artificially large size for the document to let the render engine
        // figure out what the document needs based on content.
        //
        // Note that if the document itself has no fixed width, text will not automatically break and will
        // likely run out and extend the document width as far as necessary to accomodate the longest line of text
        // you could either set a max width in a document box, or you can set it here.
        //
        // The document height will be calculated automatically based on content. We use an artificially large size
        // here to not constrain the layout algorithm.
        panel.setSize(targetWidth, 10000);
        panel.doDocumentLayout(panel.getGraphics());
        panel.setSize(orgSize);
        frame.pack();
        frame.setVisible(true);
    }
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

    private void run(String[] args) {
        loadAndCheckArgs(args);

        // Create a JPanel subclass to render the page
        XHTMLPanel panel = new XHTMLPanel();
        panel.setInteractive(false);
        panel.getSharedContext().setPrint(true);
        panel.setBackground(Color.LIGHT_GRAY);
        panel.setCenteredPagedView(true);

        // Set the XHTML document to render. We use the simplest form
        // of the API call, which uses a File reference. There
        // are a variety of overloads for setDocument().
        try {
            panel.setDocument(new File(fileName));
        } catch (Exception e) {
            e.printStackTrace();
        }

        // Put our panel in a scrolling pane. You can use
        // a regular JScrollPane here, or our FSScrollPane.
        // FSScrollPane is already set up to move the correct
        // amount when scrolling 1 line or 1 page
        FSScrollPane scroll = new FSScrollPane(panel);

        JFrame frame = new JFrame("Flying Saucer: " + panel.getDocumentTitle());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(scroll, BorderLayout.CENTER);
        frame.pack();
        frame.setSize(1024, 768);
        frame.setVisible(true);
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

        JScrollPane scrPane = new JScrollPane(codeEditor);
        split.setBottomComponent(scrPane);


        JTabbedPane tabs = new JTabbedPane();
        final XHTMLPanel xhtmlPanel = new XHTMLPanel();
        tabs.addTab("HTML", new FSScrollPane(xhtmlPanel));

        final FSPagePanel pdfPanel = new FSPagePanel();
        tabs.addTab("PDF", new JScrollPane(pdfPanel));
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new BorderLayout());
        mainPanel.add(new JLabel("Use mouse to select/highlight text"), BorderLayout.NORTH);
        mainPanel.setMinimumSize(new Dimension(300,300));
        mainPanel.setPreferredSize(new Dimension(700,500));
        XHTMLPanel xhtmlPanel = new XHTMLPanel();

        // selection highlight in FS uses the textArea.selectionForeground and textArea.selectionBackground properties in
        // the UIManager
        //UIManager.put("TextArea.selectionBackground", Color.BLACK);
        //UIManager.put("TextArea.selectionForeground", Color.GREEN);
        try {
           xhtmlPanel.setDocument("http://www.w3.org/MarkUp/");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        // install a selection highlighter no the panel
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

    private void run(String[] args) {
        loadAndCheckArgs(args);

        // Create a JPanel subclass to render the page
        final XHTMLPanel panel = setupPanel();

        // Set the XHTML document to render. We use the simplest form
        // of the API call, which uses a File reference. There
        // are a variety of overloads for setDocument().
        try {
            panel.setDocument(new File(fileName));
        } catch (Exception e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }

        // Put our panel in a scrolling pane. You can use
        // a regular JScrollPane here, or our FSScrollPane.
        // FSScrollPane is already set up to move the correct
        // amount when scrolling 1 line or 1 page
        FSScrollPane scroll = new FSScrollPane(panel);

        JFrame frame = new JFrame("Flying Saucer: " + panel.getDocumentTitle());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(scroll, BorderLayout.CENTER);
        frame.getContentPane().add(new JButton(new AbstractAction() {
            public void actionPerformed(ActionEvent event) {
                System.out.println("\n\n\nRELOAD\n\n\n");
                panel.setDocument(panel.getDocument(), panel.getSharedContext().getBaseURL());
            }
        }), BorderLayout.NORTH);
        frame.pack();
        frame.setSize(1024, 768);
        frame.setVisible(true);
View Full Code Here

Examples of org.xhtmlrenderer.simple.XHTMLPanel

        frame.setSize(1024, 768);
        frame.setVisible(true);
    }

    private XHTMLPanel setupPanel() {
        XHTMLPanel panel = new XHTMLPanel();
        DelegatingReplacedElementFactory delegatingFactory = new DelegatingReplacedElementFactory();
        delegatingFactory.addReplacer(new SwingImageReplacer());
        panel.getSharedContext().setReplacedElementFactory(delegatingFactory);
        return panel;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.