JMenu ...Can't remember

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

JMenu ...Can't remember

 
0
  #1
Mar 17th, 2005
I can't seem to remember how you create subitems in the menu's. Does anyone know how?

Like this:

Format --> Color(then like a drop down)
*red
*blue
*green
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 780
Reputation: OurNation is an unknown quantity at this point 
Solved Threads: 9
OurNation's Avatar
OurNation OurNation is offline Offline
Master Poster

Re: JMenu ...Can't remember

 
0
  #2
Mar 17th, 2005
Heres an example of a couple different ones

  1. /*
  2.  * ChoiceTest
  3.  * Demonstrates the Choice Component
  4.  */
  5.  
  6. import java.awt.*;
  7.  
  8. public class ChoiceTest {
  9.  
  10. public ChoiceTest() {
  11. //Make the Choices
  12. Choice c1 = new Choice();
  13. c1.add("Soup");
  14. c1.add("Salad");
  15. Choice c2 = new Choice();
  16. c2.add("Java");
  17. c2.add("C++");
  18. c2.add("HTML");
  19. c2.add("JavaScript");
  20. c2.add("COBOL");
  21. c2.add("FORTRAN");
  22. Choice c3 = new Choice();
  23. c3.add("One");
  24. c3.add("Two");
  25. c3.add("Three");
  26. c3.setForeground(Color.red);
  27. c3.setBackground(Color.black);
  28. c3.setFont(new Font("Courier", Font.PLAIN, 16));
  29. Choice c4 = new Choice();
  30. c4.add("Not Enabled");
  31. c4.add("Nope");
  32. c4.setEnabled(false);
  33.  
  34. //Make the Frame and add the Choices to it
  35. ComponentTestFrame frame = new ComponentTestFrame("Choice Test");
  36. frame.add(c1);
  37. frame.add(c2);
  38. frame.add(c3);
  39. frame.add(c4);
  40. frame.setVisible(true);
  41. }
  42.  
  43. public static void main(String args[]) {
  44. ChoiceTest ct = new ChoiceTest();
  45. }
  46.  
  47. }
PETA People for the Eating of Tasty Animals.


FireFox
Hijack This
Ad-Aware
Hijack this tutorial
Microsoft AntiSpyware
CompUchat
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 10
Reputation: Meldroz is an unknown quantity at this point 
Solved Threads: 0
Meldroz Meldroz is offline Offline
Newbie Poster

Re: JMenu ...Can't remember

 
0
  #3
Mar 18th, 2005
I think you want something with swings since you mentioned JMenu.
here's a simple example:

JMenu menu = new JMenu("Color");

JMenuItem blueM = new JMenuItem("blue");

// and do this for the others and once done add them to your menu
//ex:

menu.add(blueM); // and so on hope this helps


good luck,
Mel
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: JMenu ...Can't remember

 
0
  #4
Mar 18th, 2005
Yes, I know how to create the Menu's and the Menu items, but how do you have menu items with subcategories...Look at this screenshot to see what I'm saying.
Attached Thumbnails
whatiwant.jpeg  
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 10
Reputation: Meldroz is an unknown quantity at this point 
Solved Threads: 0
Meldroz Meldroz is offline Offline
Newbie Poster

Re: JMenu ...Can't remember

 
0
  #5
Mar 23rd, 2005
Ho,

Well it depends you can create one of these and add them to your drop down menu object:

JRadioButtonMenuItem
JCheckBoxMenuItem

I'm sure there are others but these are the only two that i ever used. create these and add them to your MenuItem objects.
I don't know if that's what you wanted to hear, but that's all i got.:cry:

Mel
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: JMenu ...Can't remember

 
0
  #6
Mar 23rd, 2005
Thank you all for the help. I guess I was unclear on what I wanted. I figured out how to do this though. What you do, is simply add a JMenu, to a JMenu, and that makes it to were you can have subcategories.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC