File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Problem with JDialog and JOptionPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with JDialog and JOptionPane" Watch "Problem with JDialog and JOptionPane" New topic
Author

Problem with JDialog and JOptionPane

Akhil Jain
Ranch Hand

Joined: Oct 14, 2004
Posts: 74
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


-------------------------------<br />you can't move ahead, unless you try for it.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Akhil Jain
Ranch Hand

Joined: Oct 14, 2004
Posts: 74
Thanks,

I liked the idea. it worked great..

Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JDialog and JOptionPane
 
Similar Threads
Swing is my Nemesis
JOptionPane showInputDialog : own textfield or combobox
Setting icon/image on Title of JOptionPane.showConfirmDialog
Gathering input data
Dialog box using Netbeans