java – Linux – Nimbus LookAndFeel:表格网格线未到来
作者:互联网
在我的java应用程序中,我使用的是NimBusLookAndFeel.我试图在表格中显示网格线.
以下代码在Windows上完全正常但在Linux上不能正常工作(表格网格线不会出现在linux中)
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
UIManager.put("Table.showGrid", true);
UIManager.put("Table.intercellSpacing", new Dimension (1,1));
以下是linux上的java版本详细信息
java version “1.6.0_12” Java(TM) SE Runtime Environment (build
1.6.0_12-b04) Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)
解决方法:
你必须在Nimbus UIDefaults之后过度活跃
try {// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if (info.getName().equals("Nimbus")) {
UIManager.setLookAndFeel(info.getClassName());
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
defaults.put("Table.gridColor", new Color (214,217,223));
defaults.put("Table.disabled", false);
defaults.put("Table.showGrid", true);
defaults.put("Table.intercellSpacing", new Dimension(1, 1));
break;
}
}
} catch (Exception e) {
//e.printStackTrace();
}
标签:java,linux,swing,jtable,nimbus 来源: https://codeday.me/bug/20190826/1731727.html