• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Open New Window

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22783
131
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
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.
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic