Domanda

I need to create the JMenu which should have:

  1. The submenu items
  2. The checkbox.

Like this:

JMenu with checkbox

Is there any easy way to create it or I have to learn the core first merge the JCheckBoxMenuItem and JMenu classes?

PS: Yes, I know that I can try it myself and I'll create it after ~2 days of coding. I've just asked for the easy way or the turnkey solution.

È stato utile?

Soluzione

You can associate an icon with any menu. The easiest way to do this might be to just use a regular MenuItem and set its icon to either a checked or unchecked checkbox whenever it is clicked. You might put that logic in a subclass of JMenu and use that class.

http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top