I am trying to add a JToolbar to a JDesktopPane in Netbeans. However, when I add the JToolbar to the JDesktopPane, and I maximize the JDesktopPane on runtime, the JToolbar remains the same size. JToolbar is not resizing along with the other components.
Asked
Active
Viewed 191 times
1 Answers
0
You can simply add ComponentListener to the JDesktopPane
:
jDesktopPane1.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
Dimension desktopSize = jDesktopPane1.getSize();
int dWidth = (int) desktopSize.getWidth();
int dHeight = (int) desktopSize.getHeight();
jToolBar1.setSize(dWidth, jToolBar1.getHeight());
}
}

Akhilesh Dhar Dubey
- 2,152
- 2
- 25
- 39