开发者

JMenu appears behind JTree when JTree has focus?

The JMenu works correctly when I click my mouse over it.

JMenu appears behind JTree when JTree has focus?

I click my mouse away and it disappears (normal). I then double click the only entry in my JTree.

Then when I click my JMenu it looks like this. It appears be开发者_StackOverflow社区hind the JTree???

JMenu appears behind JTree when JTree has focus?

When I resize the window it returns to normal. Until the JTree has focus again.

This is what my code looks like, I'm subclassing a jframe and this code is in the constructor

Container cp = getContentPane();

//1. menu
JMenuBar menu = new JMenuBar();
//...

cp.add(menu, BorderLayout.NORTH);

//2. split pane
JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
//...
{
    //3a. scrollpane (left)
    ScrollPane treeView = new ScrollPane();
    treeView.setMinimumSize(new Dimension(0,0));
    sp.add(treeView, JSplitPane.LEFT);
    {
        //3ai. treeview
        tree = new ObjectTree();
        treeView.add(tree);
    }

    //3b. scrollpane (right)
    ScrollPane tabView = new ScrollPane();
    tabView.setMinimumSize(new Dimension(0,0));
    sp.add(tabView, JSplitPane.RIGHT);
    {
       //3bi tabview
       ObjectTabPane view = new ObjectTabPane();
       tabView.add(view);
    }
}

cp.add(sp, BorderLayout.CENTER);
this.setSize(700, 500);


You're mixing Swing and AWT components. Don't do this, because it leads to the problem you're facing. Use a JScrollpane rather than a ScrollPane.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜