javaswingjtoolbar

How to create Full Screen width jtoolbar


I created full screen jform using netbeans in java. I need to create Full Screen width sized jtoolbar. How I do this?

this code I use for create full screen size jform / jform resize

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0, 0, screenSize.width, screenSize.height);

Solution

  • Use JToolBar inherithed method Component::setBounds.

    Place ToolBar at TOP:

    toolBar.setBounds(0, 0, screenSize.width, yourDesiredHeight);
    

    Place ToolBar at BOTTOM:

    toolBar.setBounds(0, screensize.height - yourDesiredHeight, screenSize.width, yourDesiredHeight);