简体   繁体   English

在Java中,我仅对单个JComponent(及其子级)使用不同的LookAndFeel

[英]In Java I use a different LookAndFeel for just a single JComponent (and its children)

In Java I use 在Java中,我使用

UIManager.setLookAndFeel(
                    UIManager.getSystemLookAndFeelClassName()

to get the System Look and Feel 获得系统外观

However I am using a JTable and having problem on Windows with the Windows LAF and OSX with the OSX LAF, all the problem look to be solved if I just use the 但是我使用的是JTable,而Windows在Windows LAF和OSX在OSX LAF上都存在问题,如果我仅使用

UIManager.getCrossPlatformLookAndFeelClassName();

Is it possible to just have my JTable and the JScrollPane it is wrapped in use the Cross Platform Look and Feel without it affecting anything else or not. 是否可以让我的JTable和JScrollPane使用跨平台外观进行包装而不会影响其他任何东西。

And if so is this a really bad idea ? 如果是这样,这真的是个坏主意吗?

The problems I am seeing are 我看到的问题是

Windows, Column Header rendering almost indistinguisable from regular table cells Windows,列标题渲染几乎与常规表格单元格难以区分

OSX, Cell background colour same as panel background OSX,单元格背景色与面板背景相同

OSX, No grid lines between table cells. OSX,表格单元格之间没有网格线。

The LAF of a component is determined at the time the component is created. 在创建组件时确定组件的LAF。

So you can try something like: 因此,您可以尝试以下操作:

  1. set temporary LAF 设置临时LAF
  2. create components and add them to the frame. 创建组件并将其添加到框架。
  3. restore the LAF 恢复LAF

And if so is this a really bad idea ? 如果是这样,这真的是个坏主意吗?

Not sure if there are an hidden problems. 不知道是否存在隐藏的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM