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

Heres an example of a couple different ones

/*
 * ChoiceTest
 * Demonstrates the Choice Component
 */

import java.awt.*;

public class ChoiceTest {

  public ChoiceTest() {
    //Make the Choices
    Choice c1 = new Choice();
    c1.add("Soup");
    c1.add("Salad");
    Choice c2 = new Choice();
    c2.add("Java");
    c2.add("C++");
    c2.add("HTML");
    c2.add("JavaScript");
    c2.add("COBOL");
    c2.add("FORTRAN");
    Choice c3 = new Choice();
    c3.add("One");
    c3.add("Two");
    c3.add("Three");
    c3.setForeground(Color.red);
    c3.setBackground(Color.black);
    c3.setFont(new Font("Courier", Font.PLAIN, 16));
    Choice c4 = new Choice();
    c4.add("Not Enabled");
    c4.add("Nope");
    c4.setEnabled(false);
    
    //Make the Frame and add the Choices to it
    ComponentTestFrame frame = new ComponentTestFrame("Choice Test");
    frame.add(c1);
    frame.add(c2);
    frame.add(c3);
    frame.add(c4);
    frame.setVisible(true);
  }

  public static void main(String args[]) {
    ChoiceTest ct = new ChoiceTest();
  }

}

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

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.