Question

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.

Was it helpful?

Solution

return new JToolBar();

needs to be

return t1;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top