Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-27-2008, 04:55 PM
Member
 
Join Date: Mar 2008
Posts: 20
Rep Power: 0
themburu is on a distinguished road
Default String array for Choice, JOptionPane doesn't show
1.Is there a way that you can make the choicelist use a string array, the thing is that I want the contents of the choice list to change to suite what is selected in my checkboxes, I find the lengthy addItem awkward and hard to replace in this case.

2.I also wanted to show a message dialog, I imported the necessary class import javax.swing.JOptionPane;

but when i used it in my code it gave an error

JOptionPane.showMessageDialog(null, "You have not selected details of what you want to know!", JOptionPane.WARNING_MESSAGE);

How do you show the message dialog?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-27-2008, 07:13 PM
Member
 
Join Date: Apr 2007
Location: USA
Posts: 50
Rep Power: 0
derrickD is on a distinguished road
Default
#1. The answer is yes. Make your StringArray then just use a loop to add the items, you do not have to do any tedious work of addItem then.
Code:
String[] myArray = {"A","B","C"};
for (int i = 0; i < myArray.length; i++) {
			
myChoiceList.add(myArray[i]);
}
#2. JOption pane needs the parent as the first parameter. You have null.
So, it should be :
Code:
JOptionPane.showMessageDialog(myParentComponent(), "You have not selected details of what you want to know!", JOptionPane.WARNING_MESSAGE);
with "myParentComponent()" being the name of the component that is calling the JOptionpane
__________________
Registry Cleaner Reviews
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-28-2008, 11:55 AM
Member
 
Join Date: Mar 2008
Posts: 20
Rep Power: 0
themburu is on a distinguished road
Default I had tried the myParentComponent() which is MyRequest
I Will try the loop,

but for the JOptionPane I had tried that i.e myParentComponent(), Actually the name of the applet is MyRequest so I had
Code:
JOptionPane.showMessageDialog(MyRequest, "You have not selected details of what you want to know!", JOptionPane.WARNING_MESSAGE);
but it still didn't work!
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-28-2008, 01:00 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 540
Rep Power: 3
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Default
You may look at JOptionPane class....

eg.

showMessageDialog(null,"Message","Title",int constant);
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-28-2008, 02:31 PM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
Rep Power: 0
orchid is on a distinguished road
Default
Isn't there a subcomponent for your applet, like a JFrame or a JPanel?? That is the component you should put in there, the component that actually has the button on it or whatever it is that makes the JOption pane popup. You do not list the applet, you list a Component. Please look at the Java API for JOptionPane and that should help out.
__________________
Java Fusion L.L.C.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-29-2008, 02:10 PM
Member
 
Join Date: Mar 2008
Posts: 20
Rep Power: 0
themburu is on a distinguished road
Default It works Thanx/Asante!
Men it work fine, Thanks, Asante is thanks in kiswahili.

Actually since the applet is itself acontainer you have to included all the parts of the JOptionPane, ie

showMessageDialog(null,"Message","Title",int constant);

Again Asante.
__________________
The dream of being a legend has just begun!
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How i add string array in vector susan New To Java 7 02-12-2009 02:32 PM
Need Help with String Array crazydeo New To Java 1 05-13-2008 10:18 AM
netbeans 6.0 not show commpunent or show blank page fahimaamir NetBeans 1 01-26-2008 07:20 AM
String []Array Warren New To Java 4 12-01-2007 09:03 AM
I can't seem to pass the value of a string variable into a string array mathias Java Applets 1 08-03-2007 11:52 AM


All times are GMT +2. The time now is 03:02 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org