更改文本字段AWT的边框颜色 [英] Changing Border Color of AWT TextField

查看:302
本文介绍了更改文本字段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.

这篇关于更改文本字段AWT的边框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆