如何让jformattedtextfield上的边框在出错时变为红色? [英] How do I get the border on a jformattedtextfield to turn red on error?

查看:102
本文介绍了如何让jformattedtextfield上的边框在出错时变为红色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NetBeans Design GUI界面。我希望jFormattedTextField在出错时变为红色。我没有办法做到这一点。



提前致谢。



我尝试了什么:



我将字段的默认边框更改为Etched,在此之下,我添加了代码以打开highlite:

如果rm [1] {setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255,0,0),null));}

否则

{setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(153,153,153),null));};



除了愚蠢的编辑器第二次从null中添加最后一位。由于它是受保护的代码,因此无法更改。

I am using NetBeans Design GUI interface. I want a jFormattedTextField to turn red on error. I don't see a way to do it.

Thanks in advance.

What I have tried:

I changed the default border for the field to Etched, and under that, I added code to turn the highlite on:
if rm[1] {setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255, 0, 0), null));}
else
{setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(153, 153, 153), null));};

Except the stupid editor adds in the last bit from null on a second time. And since it is protected code, you can't change it.

推荐答案

根据文档:BorderFactory(Java Platform SE 7) [ ^ ],第二个字段是阴影颜色。
According to the documentation: BorderFactory (Java Platform SE 7 )[^], the second field is the shadow colour.


这篇关于如何让jformattedtextfield上的边框在出错时变为红色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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