• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reg: Jframe

 
arup majumder
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two frames and when I click login button in 1st frame second frame opens. After closing 2nd frame if I click first frame button again it overwrites the old 2nd frame. I cannot use exit_on_close as I dont want to stop the execution. I also tried with hide_on_close and dispose_on_close. None of it worked. Can any body tell me how to create new frame on clicking the button every time.
 
Campbell Ritchie
Marshal
Posts: 52590
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Why are you opening a second frame? Wouldn’t a dialogue be better?
 
arup majumder
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply. I have many other components in that frame like Panes
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have panes and all components in Dialog too...
 
Randall Twede
Ranch Hand
Posts: 4520
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you don't tell enough for me to know why you have to do this, but here is an idea. make an ArrayList of JFrames. have an int variable that gets incremented each time you open a new frame. store the frames in the ArrayList. i'm more used to using arrays. if it was an array it would look something like this:
myFrames[count] = new JFrame();
i guess with ArrayList you don't need a int variable. maybe just:
myFrames.add(new JFrame);
or something. i have a lot of studying to do to relearn all this.
anyway, just a thought.
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a rare application that needs more than one JFrame. Other windows should be JDialogs, as already suggested.
 
Randall Twede
Ranch Hand
Posts: 4520
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i wrote one once. the second frame was larger than the first one and hid the first one until it was closed but i agree it is unusual.
 
arup majumder
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all of your suggesions. I am new to Swing. Any way I found the solution. As I said I have a panes in it. I used pane.removeAll at the start of the function. So when ever this Function is called. 2nd frame get started from first. When I started to code it I was not knowing that JDialog works without any Container. Any way thanks to all of you for sharing your knowledge.
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randall Twede wrote:i wrote one once. the second frame was larger than the first one and hid the first one until it was closed ...

Or minimized, or moved, or Alt-Tabbed out of the way?
 
Randall Twede
Ranch Hand
Posts: 4520
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
they were both centered on the screen so the second larger one just covered up the first one
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!