• 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

Reg: Jframe

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79475
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply. I have many other components in that frame like Panes
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can have panes and all components in Dialog too...
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
they were both centered on the screen so the second larger one just covered up the first one
 
reply
    Bookmark Topic Watch Topic
  • New Topic