JFrame and JMenuBar [message #1014623] |
Tue, 26 February 2013 02:12  |
Eclipse User |
|
|
|
Hi all,
I've created a simple JFrame class which should get it's menu bar from another class.
Something like this:
// ...
public class MclViewerFrame extends JFrame {
// ...
private MainMenuBar mainMenuBar = null;
// ...
this.mainMenuBar = new MainMenuBar(this);
// WindowBuilder doesn't work with this line
this.setJMenuBar(this.mainMenuBar);
And the MainMenuBar class looks like this:
// ...
public class MainMenuBar extends JMenuBar {
// ...
When I compile this stuff, it works as it should. But when I start the design view of the WindowBuilder, I get the error message
java.lang.ClassCastException: javax.swing.JPanel cannot be cast to javax.swing.JMenuBar
Deleting the line "this.setJMenuBar(this.mainMenuBar);" makes the WindowBuilder work, but of course without the menu bar.
Where's my flaw? Should I build the menu bar with a factory class or something like that?
Thanks for comments!
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06639 seconds