user2079483
user2079483

Reputation: 135

Why doesn't JToolBar appear?

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.

Upvotes: 0

Views: 124

Answers (1)

Radiodef
Radiodef

Reputation: 37875

return new JToolBar();

needs to be

return t1;

Upvotes: 2

Related Questions