Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-27-2008, 05:55 PM
Member
 
Join Date: Mar 2008
Posts: 20
themburu is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 05-27-2008, 08:13 PM
Member
 
Join Date: Apr 2007
Location: USA
Posts: 50
derrickD is on a distinguished road
#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
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-28-2008, 12:55 PM
Member
 
Join Date: Mar 2008
Posts: 20
themburu is on a distinguished road
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, 02:00 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
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
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-28-2008, 03:31 PM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
orchid is on a distinguished road
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-29-2008, 03:10 PM
Member
 
Join Date: Mar 2008
Posts: 20
themburu is on a distinguished road
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
Sponsored Links
Reply


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

vB 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
Need Help with String Array crazydeo New To Java 1 05-13-2008 11:18 AM
netbeans 6.0 not show commpunent or show blank page fahimaamir NetBeans 1 01-26-2008 08:20 AM
String []Array Warren New To Java 4 12-01-2007 10: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 12:52 PM
How i add string array in vector susan New To Java 1 07-16-2007 07:44 AM


All times are GMT +3. The time now is 06:48 AM.


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