• 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

Problem with JDialog and JOptionPane

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

need your support here. i tried everything i could, to get this work. but no success.


I have JFrame, which contains some menus on menu bar, one such menu is "Settings" which contains "Configuration" as JMenuItem, When clicking on that, i want to show a JDialog/JOptionPane/JFrame, where user can actually enter some values in text fields and click on "OK", these values will be used by JFrame accordingly.

Now the problem is:

1. If i am using JOptionPane's showInputDialog() method, then i am not able to set its Title Bar Icon (by default, it doesn't comes with any icon on its title bar as JFrame does.).

2. If i am using JOptionPane's showInputDialog() method, I am not able to put a JPanel inside it which contains properly formatted input fields.

3. If i am using JFrame, so that i can put any JPanel and any user input stuff, then , it comes with minimize and maximize buttons on top-right, which i dont want, since i am intension is to use it as a dialog for just getting input from the user.

4. secondly, if i use JFrame, then the new Jframe which comes up, can loose focus , when user clicks on main JFrame which contains Jmenu, i dont want user to actually able to access that main JFrame, untill he has provided any input which i am asking for (2-3 input fields) or unless he has explicitly clicked on "Close" button of that JFrame which is acting as a dialog. I am not getting any way to do it.

can someone please help.

Regards,
Akhil
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Akhil Jain:
2. If i am using JOptionPane's showInputDialog() method, I am not able to put a JPanel inside it which contains properly formatted input fields.


Use showConfirmDialog instead, with your JPanel as the second parameter (message) and JOptionPane.OK_CANCEL_OPTION as option type. Then check if the return value equals JOptionPane.OK_OPTION to see whether the user pressed OK, then get the values from the panel.
 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

I liked the idea. it worked great..

Thanks again.
 
What's that smell? I think this tiny ad may have stepped in something.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic