The Artima Developer Community
Sponsored Link

Java Answers Forum
how to add or link an html page from a button in a JFrame

1 reply on 1 page. Most recent reply: May 17, 2006 2:28 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
rashi bahal

Posts: 1
Nickname: rashibahal
Registered: May, 2006

how to add or link an html page from a button in a JFrame Posted: May 9, 2006 3:25 AM
Reply to this message Reply
Advertisement
please send a reply on rashi.bahal@gmail.com


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: how to add or link an html page from a button in a JFrame Posted: May 17, 2006 2:28 AM
Reply to this message Reply
I got this from the Java Developer's Almanac 1.4
Mayby it helps.
Didn't try it out yet.

Hyperlink events are fired by a JEditorPane when the user clicks on a hyperlink.
    try {
        String url = "http://java.sun.com";
        JEditorPane editorPane = new JEditorPane(url);
        editorPane.setEditable(false);
        editorPane.addHyperlinkListener(new MyHyperlinkListener());
    } catch (IOException e) {
    }
    
    class MyHyperlinkListener implements HyperlinkListener {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane pane = (JEditorPane)evt.getSource();
                try {
                    // Show the new page in the editor pane.
                    pane.setPage(evt.getURL());
                } catch (IOException e) {
                }
            }
        }
    }

Flat View: This topic has 1 reply on 1 page
Topic: Garbage collection algorithm Previous Topic   Next Topic Topic: Drawing a Tree

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use