我有一個小的問題,改變對象的外觀和感覺。在我的應用程序中,我有JTable和外觀和感覺
public class JavaCommander extends JFrame
而在這個類中我有JTable,它是用我自己的表模型構建的。一切工作正常,但正如我所說,當我想改變外觀和感覺時有一個問題。在菜單欄中,我有一個可用外觀和感覺的菜單。
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);
所以當我點擊其中一個按鈕時,它應該改變我的應用程序的外觀和感覺。但是,當我這樣做,一切都變了,但圍繞在表格元素電網丟失,所以我需要添加
table.setShowGrid(true);
是正常的行爲網格改變外觀和感覺後去失蹤?
Nimbus行爲嚴重,沒有在幾個地方清理自己身後,表網格線只是其中之一 - 準備更多的污垢:-( – kleopatra 2011-12-25 12:25:32