更改文本字段AWT的边框颜色
问题描述:
在AWT应用程序,我需要设置文本字段的边框颜色。
In AWT application I need to set border color of TextField.
在JTextField的,我知道,我们做可以做以下
In JTextField, I know that we do can do the following
JTextField tf = new JTextField();
tf.setBorder(BorderFactory.createLineBorder(Color.decode("#2C6791")));
但是setBorder()方法未在AWT的TextField availiable。有没有解决方法这个问题?
But setBorder() method is not availiable in awt TextField. Is there any workaround for this problem?
答
在AWT 文本字段
不支持的边界,因为你已经找到。你可以通过将文本字段面板内模拟一个边界
这仅仅比文本框和改变面板的背景颜色稍大。
The AWT TextField
does not support borders, as you've found. You could emulate a border by putting the text field inside a Panel
that's just slightly larger than the textfield and changing the background color of the panel.