• Post Reply Bookmark Topic Watch Topic
  • New Topic

opening link in new window

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using this code, i added like this to my panel:

so now i've an active hyperlink that, when clicked, displays an html page; but what i want is that it opens in a new (browser) window
how is that possible?

TiA
 
Campbell Ritchie
Marshal
Posts: 52574
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting a JDesktopPane inside your JFrame and JInternalFrames (I think) inside that.

Try extending JFrame to URLFrameSe whether either of those suggestions works.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when running InternalFrameDemo, i noticed internal frames do appear in my new window, but cant surpass, in size, parent's size, so i'm stuck with original small size
 
Campbell Ritchie
Marshal
Posts: 52574
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid that is normal behaviour for internal frames. Have you tired the suggestion about new JFrames?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm afraid not: i dont get this:
Try extending JFrame to URLFrame
...
JFrame myURLFrame = new URLFrame();
myURLFrame.setBounds(50, 50, 200, 200);
myUrlFrame.setVisible(true);
 
Campbell Ritchie
Marshal
Posts: 52574
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a new class which extends JFrame and displays whatever you want to display your URL.
In the first instance try something very simple like this:- This should show a new Frame with some sort of text from the HyperlinkEvent as its title, whenever the Hyperlink is activated.

Then add editor panes to that Frame which will display the HTML downloaded. Be sure the URLFrame class has a getURLEditorPane() method which allows other classes access to its editor pane. Then you can say


BTW: What you have in the hyperlinkUpdate method is too much. Create a new method somewhere, and call that.

I have never tried that particular code. Please see whether it works.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW: What you have in the hyperlinkUpdate method is too much. Create a new method somewhere, and call that.

i totally agree with you: i also like short methods; what happened was i copy/paste from sun docs and then didnt refactor.

as to my actual issue, i wanna thank you for your interest and help

thinking better, what i really need isnt a panel to display my web, but a really web browser window to show up: in a plain web, i see a link, click it and a web page displays in browser; here, i already have my hyperlink, so i want a web page to open when i click my link (i have no idea at all how to achieve it, but, to be sincere, i dont needed it that baddly )
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> so i want a web page to open when i click my link

maybe this is all you need
(simulated a JLabel/mouseListener for your hyperlink)

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael: bingo!
thanks a lot, because by myself i'd never get it working

here�s a (very little) improvement (any sugestions are welcome)


i'll see if using jEditorPane instead i dont need the mouse events for the changes in mouse
 
Campbell Ritchie
Marshal
Posts: 52574
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Michael, and well done Miguel.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here are both working versions (i tend to prefer a label, though)

[ May 13, 2007: Message edited by: miguel lisboa ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!