• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JFileChooser showing twice

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got an aplication with a JPanel in it, and I also have outside this panel a JFileChooser, when I click a button on the JPanel I call the JFileChooser, but after I click "OK" it appears again, why? my code for opening the JFileChooser is this:

Contenido is my JPanel
The JFileChooser code is this:


Thanks
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you added it to the JPanel. Don't add it to the JPanel, when you show an open dialog it will pop up in it's own frame, it shouldn't be added to anything.
 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I don't add it I get this:

and a lot more of stuff...
the line giving the problem is this:


And if I add it, it works, any clue why this is happening???

Ok, I've done a little mor of investinagtion, and I've found that it opens twice becaus it enters twices to de case "add" on the actionPerformed function I've got for doing actions when menu options are pressed. I don't know what's happening, it only enters once to the other opciotns.
[ November 17, 2005: Message edited by: Emili Calonge ]
 
Marshal
Posts: 80871
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never tried this before, but you appear to be opening the JFileChooser in front of itself.
When you write showAnythingDialog(this.BuscadorFicheros), then the AnythingDialog opens infront of BuscadorFicheros.
BUT BuscadorFicheros isn't there for it to open in front of.
Try putting a different component as the argument for showOpenDialog, and see whether that helps.
CR
 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried, this.Buscador_Ficheros, null, this, but the same thing happens, it opens twice, I really think the problem comes form the menu selection calling actionPrformed twice, but I don't now wahy this would happen, in the other menu options it only calls actionperformed once, I'm really confused, and I'm really stressed because I need this by tomorrow...
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try replacing

with


So the JFileChoser will be created but not added to JPanel.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic