Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open New Window

 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I want to open a new window on the click of a button("finish").
At the same moment I want to close my parent window from where the swing application opened initially and now open the new one.

Please suggest me the way by which I can do the same.

Thanks
Kushagra
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oldFrame.setVisible(false) will hide your existing UI, whereas newFrame.setVisible(true) will show your new frame. Of course you have to build your new frame first. But since you already have built your old frame, that shouldn't be a problem.

Since you mentioned hiding the original frame, I presumed you do not want modal dialog windows.
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to close the main window is the oldFrame.setVisible(false); will close it or make it invisible. Also I want to know that oldFrame and newFrame are objects of which class.

Actually my browse button is on Web page which will then open my swing application.
As my application will have to refresh the web application so I want to open the new web page instead of new one. Is it possible to do the same as you suggest.

Thanks
Kushagra
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oldFrame and newFrame would be instances of JFrame. Check the API to find out what exactly setVisible(false) means.

Actually my browse button is on Web page which will then open my swing application.
As my application will have to refresh the web application so I want to open the new web page instead of new one. Is it possible to do the same as you suggest.

Please tell the details.
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Actually my requirement is to open a fresh new IE instance on the click of a button independently.

Thanks
Kushagra
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which button? Is it a button on an HTML page which is being displayed in IE?
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No this button is on swing window and on click on whcih I want to open a new webpage let say "www.google.com"

Thanks
Kushagra
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question comes up many times.
Search this forum for opening URLs from Swing applications.

Please note that opening a URL and opening IE(like you mentioned in your previous post) are two different things.
While opening URLs the "preferred system browser" setting is considered and it might not be IE.
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya you are right.

I want to open the prefered browser on click of the button and want to close previously open browser that initially open my swing application.

Thanks
Kushagra
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That last part is going to be a problem, since your Swing application knows nothing about how it was started, and therefore does not know about the IE window. And closing just any IE window will not do; even if there is just one active window, there is no guarantee that that is the window that opened your app - the user could have closed it manually and opened another window. Or he could have used that window to open a different page.

Note that if your Swing application is in fact a JApplet, then you can do what you want. Use getAppletContext().showDocument(...) to do just that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic