• 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

Java opening both windows in program when I only want one?

 
Ranch Hand
Posts: 51
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my program where you simply move a shape around on screen. In the if section I have added an if statement where if you hit the "/" key it opens a new window with a blank text area. The problem is that it opens at the start of the program, and I only want it to open when you hit the slash key. Another problem is that when you close the Text window it closes the main window too, which I don't want it to. I have it in two separate classes because I believe it will be simpler to keep a new window in a new class.

And I know you will ask why do I want to add this new window, what is its functionality in the program. The reason is I am just trying to experiment with this, and would like to know how. I realize it's not practical to open separate windows but I would like to do it anyway. I am thinking maybe later I might add more functionality to this window, something like commands for a game.







 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The problem is that it opens at the start of the program



That is because you create the window at the start of the program. What do you think the following statement does?

 
John Corkrend
Ranch Hand
Posts: 51
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok that fixed it, I see how it created the window when the program started. Now another thing I want to ask is why does it close both windows when I only want to close the text one? Is there a way where I can close one window and still leave the other one open?
 
John Corkrend
Ranch Hand
Posts: 51
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Corkrend wrote:Ok that fixed it, I see how it created the window when the program started. Now another thing I want to ask is why does it close both windows when I only want to close the text one? Is there a way where I can close one window and still leave the other one open?



Ok I just tried some new things out with text window, and found that if I do instead of it works as I want it to. Leaving one window open while closing the other.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic