This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Open a Web Page inside a jDesktopPane

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: https://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??
 
Sheriff
Posts: 22667
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22667
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic