I have small problem with changing look and feel of an object. In my app I have
public class JavaCommander extends JFrame
and in this class I have JTable that is constructed with my own table model. Everything works fine, but as I said there is a problem when I want to change look and feel. In menu bar I have a menu with available look and feels.
menuBar=new JMenuBar();
JMenu lookMenu=new JMenu("Look and Feel");
UIManager.LookAndFeelInfo[] info= UIManager.getInstalledLookAndFeels();
ButtonGroup group=new ButtonGroup();
for (int i=0;i<info.length;++i)
{
JRadioButtonMenuItem but=new JRadioButtonMenuItem(info[i].getClassName());
but.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try {
UIManager.setLookAndFeel(e.getActionCommand());
SwingUtilities.updateComponentTreeUI(JavaCommander.this);
table.setShowGrid(true);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (InstantiationException e1) {
e1.printStackTrace();
} catch (IllegalAccessException e1) {
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
e1.printStackTrace();
}
}
});
lookMenu.add(but);
group.add(but);
}
menuBar.add(lookMenu);
so when I click on one of the buttons it should change look and feel of my application. But when I do it everything changes but the grid around elements in table is missing so I needed to add
table.setShowGrid(true);
is it normal behavior that grid goes missing after changing look and feel?