本文介绍了不可编辑JTextField的Swing Nimbus更改样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法改变不可编辑的JTextField的样式?如果将TextField设置为editable = false,我们希望为它提供更灰色的背景.我想一种方法是

Is there a way to change the style of non editable JTextField? We would like to give the TextField a slightly more grayish background if it is set to editable = false. I guess one way would be

readonlyComponent.setBackground(Color.LIGHT_GRAY);

在每个组件上

,但这似乎容易出错且乏味.

on every component but this seems error prone and tedious.

我要实现的目标是:正常的JTextFiels应该按照灵气外观定义.只读字段,例如editable = false,应具有不同的背景色.禁用字段应按照nimbus LAF的定义显示.

What I want to achieve is this: Normal JTextFiels should appear as defined by the nimbus look and feel. Readonly fields, e.g. editable = false, should have a different background color. Disabled fields should appear as defined by the nimbus LAF.

我在 Nimbus样式列表中找不到条目

推荐答案