Swing JTextField如何删除边框? [英] Swing JTextField how to remove the border?
本文介绍了Swing JTextField如何删除边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无论如何要删除 JTextField
中的边框?
Is there anyway to remove a border in a JTextField
?
txt = new JTextField();
txt.setBorder(null); // <-- this has no effect.
我真的希望它看起来像 JLabel
- 但我仍然需要它是 JTextField
因为我希望人们能够突出显示它。
I would really want it to look like a JLabel
- but I still need it to be a JTextField
because I want people to be able highlight it.
推荐答案
从你以前的答案问题你知道一些PL& Fs可能会破坏边界。
From an answer to your previous question you know that some PL&Fs may clobber the border.
显而易见的解决方案是覆盖 setBorder
PL& F正在调用的方法,并放弃更改。
The obvious solution is to therefore override the setBorder
method that the PL&F is calling, and discard the change.
JTextField text = new JTextField() {
@Override public void setBorder(Border border) {
// No!
}
};
这篇关于Swing JTextField如何删除边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文