Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 Swing 应用程序中的面板需要一个关闭/开启指示器。
我的直觉反应是尝试使用 JCheckbox,并以某种方式禁用鼠标输入并仅通过我的程序更改复选框状态。但是单选按钮会更好看。
这是最好的方法(如果是这样,如何禁用鼠标输入而不使控件看起来被禁用),还是有更好的指示元素?
是的,为什么不呢。只需使用setEnabled()方法(JPanel 继承它,所以不用担心)。
setEnabled()
使用复选框,但将图标更改为如下圆形按钮(顺便说一句,这是一个复选框)