aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Java opening both windows in program when I only want one? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java opening both windows in program when I only want one?" Watch "Java opening both windows in program when I only want one?" New topic
Author

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

John Corkrend
Ranch Hand

Joined: Oct 27, 2012
Posts: 51

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.







Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
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

Joined: Oct 27, 2012
Posts: 51

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

Joined: Oct 27, 2012
Posts: 51

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java opening both windows in program when I only want one?
 
Similar Threads
Need to add a getclickCount()
Why does one if statement work but not another?
Double buffering / drawChars / flickering
Help With Repaint Method
createImage() is null