Hi,
I've decided to have my own custom UI of JToolBar
by
subclassing BasicToolBarUI, as part of my Swing
program.
It works great under OS X (10.6) and Windows (7), but when it comes to Linux, problem occurs:
If the swing component is
- Using
SystemLookAndFeel
(With Java LAF it is shown) - Using UI
BasicToolBarUI
(To simplify the problem. With this it already doesn't work) - running under Linux (Ubuntu 10.10)
the whole JToolBar
doesn't appear anymore.
Can anyone give a hand on this? How to make it appear again on Linux? Thank you in advance.
(I've done the custom UI in order to let user still able to move the toolbar to other edges of the window, but prevent it from going to floating state.)
Cheers,
Shuo
My SSCCE:
// Set the system look and feel:
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
// Create frame
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(200, 100));
// Create toolbar
JToolBar toolbar = new JToolBar(JToolBar.HORIZONTAL);
toolbar.add(new JButton("Foo"));
// With this line toolbar doesn't appear any more (only) on Linux.
toolbar.setUI(new BasicToolBarUI());
// Show UI
panel.add(toolbar);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);