Results 1 to 6 of 6
Thread: Java DropDown Menu (JCombo Box)
- 11-05-2011, 11:50 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 79
- Rep Power
- 0
Java DropDown Menu (JCombo Box)
hey guys
Ok so I was wondering if it was possible to add items to a JCombo Box as the user creates new arrays:
Say you have this.
Now the user "does" an action, that should add an option to that menu. Is that possible?Java Code:mainMenu = JOptionPane.showInputDialog(null,"Choose an action", "Menu",//main menu JOptionPane.QUESTION_MESSAGE,null, new Object [] {"Manage Credit Cards","Manage Work","Manage Bank", "Save","Save as...", "Open", "Customize Program", "Exit"}, "");
I know how to change the names what you see, but can I add a new option?
If what you saw there were arrays, and I wanted the user to have the option to choose from a new array everytime he added one, is that possible?
(note: I am only using one method (public static void main (String [] args) )
thanksLast edited by jiffi; 11-05-2011 at 11:52 AM.
-
Re: Java DropDown Menu (JCombo Box)
Your best bet is to use an actual JComboBox, not a non-reachable one in the JOptionPane. Then use a DefaultComboBoxModel for your combobox's model. The JComboBox tutorial will show you the way.
- 11-05-2011, 12:57 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 79
- Rep Power
- 0
Re: Java DropDown Menu (JCombo Box)
Do I need different methods to do this? Because like I said, I only know how to work with the main method, which is quite a handicap at the time…
edit: Apparently, it does use different methods. Thanks anywaysLast edited by jiffi; 11-05-2011 at 01:07 PM.
-
Re: Java DropDown Menu (JCombo Box)
- 11-05-2011, 01:11 PM #5
Member
- Join Date
- Oct 2011
- Posts
- 79
- Rep Power
- 0
Re: Java DropDown Menu (JCombo Box)
I am kinda stuck with my school curriculum, learning java by yourself is not the easiest thing to do.
-
Re: Java DropDown Menu (JCombo Box)
Similar Threads
-
How to not display a value from dropdown which is populated from database using java
By smakkena in forum New To JavaReplies: 1Last Post: 08-12-2011, 05:55 AM -
dropdown menu getting overlapped issue
By jeev81 in forum Advanced JavaReplies: 0Last Post: 02-02-2011, 12:03 PM -
Fill a menu dynamically when menu is shown
By Java Tip in forum SWTReplies: 0Last Post: 07-07-2008, 04:47 PM -
React to menu action and checkbox menu
By Java Tip in forum javax.swingReplies: 0Last Post: 06-27-2008, 07:50 PM -
how to create Popup Menu with Sub Menu while right-clicking the JTree Node??
By Kabiraa in forum AWT / SwingReplies: 7Last Post: 05-09-2008, 07:54 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks