Adblock breaks this site

Webbrowser?

Discussion in 'Programming General' started by Michael3455, Nov 8, 2007.

  1. Michael3455

    Michael3455 Active Member

    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0
    Webbrowser?

    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.
     
  2. katcho

    katcho Active Member
    Banned

    Joined:
    May 27, 2005
    Posts:
    174
    Referrals:
    0
    Sythe Gold:
    0
    Webbrowser?

    Look up JDIC. If you know a little bit of java, this should help a lot.
     
  3. Michael3455

    Michael3455 Active Member

    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0
    Webbrowser?

    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.
     
  4. crashcourse

    crashcourse Active Member

    Joined:
    Nov 18, 2007
    Posts:
    236
    Referrals:
    0
    Sythe Gold:
    0
    Webbrowser?

    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.
     
  5. Michael3455

    Michael3455 Active Member

    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0
    Webbrowser?

    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
     
  6. x⁹

    x⁹ Guest

    Referrals:
    1
    Webbrowser?

    You can also use a JEditorPane to display HTML content. It's not very useful, though. JDIC is your best bet.
     
  7. timk777

    timk777 Active Member

    Joined:
    Feb 19, 2007
    Posts:
    156
    Referrals:
    0
    Sythe Gold:
    0
    Webbrowser?

< New timer | [Source] Skull Timer >


 
 
Adblock breaks this site