Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open a Web Page inside a jDesktopPane

 
Olivier López
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody, im a new java programmer and in the university I am, I have to learn about the new caracteristics of java6 for the "Sun Certified Java Programmer (SCJP)" exam...

I want to make a java aplication that opens a web site inside a JDesktopPane, or another similar container like jPanel, or jEditorPane but it´s being a little difficult xD.

With this code i already opened a URL in the internet explorer:

public void inicia(){
try {
String url = jTextField1.getText();
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
}
desktop.browse(new URI(url));
} catch (IOException ex) {
Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
} catch (URISyntaxException ex) {
Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
}

}

This is what i have, but its not what i want... i want something like:

jDesktopPane1(url);

But i dont know how to show the website inside the jDesktopPane...

I had already read the post of this guy: http://www.coderanch.com/t/462717/Java-FX/java/Open-Web-pages-inside-JavaFX

but im not using java FX, im using java SE with netbeans...


I want something like this, just... "open a website"
https://jdic.dev.java.net/documentation/incubator/JDICplus/ws/TabbedBrowser.jnlp




Can someone give me a light please??
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A non-editable JEditorPane should work:
You can also listen for clicks on links using a HyperLinkListener:
Keep in mind that JEditorPane does not really support anything past HTML 3.2. I believe SwingX has a component with better HTML support.
 
Olivier López
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AWESOME¡¡¡¡¡¡

THANKS a LOOOOOT¡¡¡¡¡

It really works¡¡¡¡

I never expected a so fast and accurate answer...

Again... thanks a lot


By The Way... I have a doubt... The jEditorPane shows the website, but i cannot interact with it... i mean, if i open google and write something in the search bar, it doesnt make anything... the hyperlink listener you wrote is for that?

I changed the code like this:



But is not working, when i clic on a link in the displayed website, it doesnt make anything

 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, forms (which are used by Google and many, many other sites) are not supported by JEditorPane, only regular links.
 
Olivier López
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
xXxOlivierxXx Elric wrote: But is not working, when i clic on a link in the displayed website, it doesnt make anything



Yea xD, google was just an example, any hyperlink of any website works

It's my hyperlink listener code ok?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic