문제

I have a Java project which has a functional JMenu. I'm trying to add a toolbar to it but it doesn't appear. I do get something I can drag which creates a blank window if I click around just under the menu bar.

protected JToolBar createToolBar(){
    JToolBar t1;
    t1 = new JToolBar();

    JButton test;
    test = new JButton("text here");
    t1.add(test);

    return new JToolBar(); 
}

This code might also be relevant.

protected Container createContentPane(){
    // Create the content-pane
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // Create the toolbar
    JToolBar jt = createToolBar();
    contentPane.add(jt, BorderLayout.PAGE_START);           

    return contentPane;
}

I would appreciate any help.

도움이 되었습니까?

해결책

return new JToolBar();

needs to be

return t1;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top