• Log in or sign up for an account here: https://www.sythe.org/login

Webbrowser?

Michael3455

Active Member
Joined
Sep 11, 2005
Sythe Gold
0
Messages
134
Hey, I was wondering if Java (using the swing GUI library) has a built in webbrowser control like that of vb.net? Or anyway at all to easily place a webbrowser inside of an application? I'm using Netbeans 5.0 and Matisse to make the GUI, if that helps of hinders.
 
Look up JDIC. If you know a little bit of java, this should help a lot.
 
Yeah, someone suggested JDIC to me on another forum, but thanks for posting (Completely forgot I posted it here). It works very nicely and is extremely simple to do.
 
There should be some sample code for implementing a web browser with Java, its definately possible. Check out the Sun.com Java tutorials, there should be a section in there with ALOT of sample code included.
 
Ok, I'll post this incase anyone else wants to see it.

It's a very MINIMAL webbrowser that BARELY works, but it demonstrates how to make one using JDIC.

Ok, first add a JTextField, JButton and a JTabbedPane. Make it look however you want, and then on the JButton ActionPreformed event, place this code.

Code:
 try {
    WebBrowser wb=new WebBrowser();
    
    wb.setURL(new URL(txtURL.getText()));
    browPane.add(wb);
    } catch(Exception ex) {
        
      JOptionPane.showMessageDialog(null,ex.getMessage());
}
    }

It's quick, dirty, and copied straight off of some website. Hey, I had no idea what to do so I needed a tutorial too. So, yes. I'm not taking any credit for this.


But, still, won't work on my comp just yet. I'm too lazy to figure out how to set the default browser :P
 
You can also use a JEditorPane to display HTML content. It's not very useful, though. JDIC is your best bet.
 
Runescape Gamblingrunescape gambling
Back
Top