Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-03-2006, 05:16 AM   PM User | #1
brad211987
Regular Coder

 
brad211987's Avatar
 
Join Date: Sep 2005
Location: Ohio
Posts: 631
Thanks: 10
Thanked 50 Times in 50 Posts
brad211987 is an unknown quantity at this point
(Java) inputDialog problem

When I use JOptionPane.showInputDialog() the input dialog pops up behind any other windows on the screen at the time. Anyone know how to fix that? Not a huge problem but its irritating.
brad211987 is offline   Reply With Quote
Old 04-03-2006, 07:03 AM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
It should automatically focus itself. Can you post your code please?
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 04-03-2006, 06:23 PM   PM User | #3
brad211987
Regular Coder

 
brad211987's Avatar
 
Join Date: Sep 2005
Location: Ohio
Posts: 631
Thanks: 10
Thanked 50 Times in 50 Posts
brad211987 is an unknown quantity at this point
Code:
        String list[] = {"100","400","900","1600"};
        String value = null;

        while(value == null)
        {
            value = (String)JOptionPane.showInputDialog(null,"How many cells do you want?",
                "John Conway's Game Of Life",JOptionPane.INFORMATION_MESSAGE,null,list,list[1]);
                
            if (value == null)
                JOptionPane.showMessageDialog(null,"You must choose a number.",
                    "ERROR",JOptionPane.ERROR_MESSAGE);
        }
This is the section of code that the input dialog is in. Do you think that it could possibly have something to do with the IDE? I had this problem when programming in highschool as well.
brad211987 is offline   Reply With Quote
Old 04-03-2006, 06:43 PM   PM User | #4
brad211987
Regular Coder

 
brad211987's Avatar
 
Join Date: Sep 2005
Location: Ohio
Posts: 631
Thanks: 10
Thanked 50 Times in 50 Posts
brad211987 is an unknown quantity at this point
I downloaded another IDE and ran it with that and sure enough, the dialog pops up right in front.
brad211987 is offline   Reply With Quote
Old 04-03-2006, 10:00 PM   PM User | #5
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Hmm why are you type casting the inputDialog box? The input given is a string by default. No need to type cast it.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 04-05-2006, 06:06 PM   PM User | #6
brad211987
Regular Coder

 
brad211987's Avatar
 
Join Date: Sep 2005
Location: Ohio
Posts: 631
Thanks: 10
Thanked 50 Times in 50 Posts
brad211987 is an unknown quantity at this point
When I don't cast the inputdialog i get:

incompatible types - found java.lang.Object but expected java.lang.String


Still trying to figure that one out because I have never seen a showInputDialog() method that returns an object. Type casting is a remedy for now but still looking for why it needs it. Maybe it has something to do with using a list in the dialog.
brad211987 is offline   Reply With Quote
Old 04-05-2006, 07:01 PM   PM User | #7
brad211987
Regular Coder

 
brad211987's Avatar
 
Join Date: Sep 2005
Location: Ohio
Posts: 631
Thanks: 10
Thanked 50 Times in 50 Posts
brad211987 is an unknown quantity at this point
Code:
static Object 	showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue)
I was wrong, I finally got the docs to load up on this slow college net and found that it does in fact return an object. Thanks for reminding me to look that one up though, I had forgotten about that issue and now I get it.
brad211987 is offline   Reply With Quote
Old 06-22-2006, 07:54 AM   PM User | #8
Katy Vlady
New to the CF scene

 
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Katy Vlady is an unknown quantity at this point
I need to create an InputDialog using JOptionPane with two input fields an a large information message. How can I do this? Or may be it's better to create a JDialog?
Katy Vlady is offline   Reply With Quote
Old 06-22-2006, 09:27 AM   PM User | #9
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Sounds like you will be using a JFrame or JPanel. Have you worked with either of these yet? The input won't be hard once you get the actual window working.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:08 AM.


Advertisement
Log in to turn off these ads.