Results 1 to 6 of 6
- 05-27-2008, 03:55 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 20
- Rep Power
- 0
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?
- 05-27-2008, 06:13 PM #2
Member
- Join Date
- Apr 2007
- Location
- USA
- Posts
- 50
- Rep Power
- 0
#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.
#2. JOption pane needs the parent as the first parameter. You have null.Java Code:String[] myArray = {"A","B","C"}; for (int i = 0; i < myArray.length; i++) { myChoiceList.add(myArray[i]); }
So, it should be :
with "myParentComponent()" being the name of the component that is calling the JOptionpaneJava Code:JOptionPane.showMessageDialog(myParentComponent(), "You have not selected details of what you want to know!", JOptionPane.WARNING_MESSAGE);
- 05-28-2008, 10:55 AM #3
Member
- Join Date
- Mar 2008
- Posts
- 20
- Rep Power
- 0
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
but it still didn't work!Java Code:JOptionPane.showMessageDialog(MyRequest, "You have not selected details of what you want to know!", JOptionPane.WARNING_MESSAGE);
- 05-28-2008, 12:00 PM #4
You may look at JOptionPane class....
eg.
showMessageDialog(null,"Message","Title",int constant);freedom exists in the world of ideas
- 05-28-2008, 01:31 PM #5
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.
- 05-29-2008, 01:10 PM #6
Member
- Join Date
- Mar 2008
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
How i add string array in vector
By susan in forum New To JavaReplies: 7Last Post: 02-12-2009, 01:32 PM -
Need Help with String Array
By crazydeo in forum New To JavaReplies: 1Last Post: 05-13-2008, 09:18 AM -
netbeans 6.0 not show commpunent or show blank page
By fahimaamir in forum NetBeansReplies: 1Last Post: 01-26-2008, 06:20 AM -
String []Array
By Warren in forum New To JavaReplies: 4Last Post: 12-01-2007, 08:03 AM -
I can't seem to pass the value of a string variable into a string array
By mathias in forum Java AppletsReplies: 1Last Post: 08-03-2007, 10:52 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks