JMenu and JMenuItem
So, I have the following code:
JMenu debug = new JMenu("Debug");
debug.add(new Debug());
And then the Debug class is:
public class Debug extends JMenuItem {
public final String TEST_DEBUG = "Test";
public Debug() {
add(TEST_DEBUG, this);
}
}
After running the application I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
adding container's parent to itself
I know what it means, but I have no idea how I can make this right without
placing the container parent to itself? How would I pass the String to the
JMenu?
Any help is appreciated.
No comments:
Post a Comment