无论如何要删除一个边框JTextField?
txt = new JTextField();
txt.setBorder(null); // <-- this has no effect.
Run Code Online (Sandbox Code Playgroud)
我真的希望它看起来像JLabel- 但我仍然需要它成为一个JTextField因为我希望人们能够突出它.
代码是这样的:
JTextField txt = new JTextField();
txt.setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.red));
Run Code Online (Sandbox Code Playgroud)
但是文本字段忽略了我的调用setBorder.没有任何改变.
我要替换它JLabel(例如)
JLabel txt = new JLabel();
txt.setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.red));
Run Code Online (Sandbox Code Playgroud)
我会看到红色边框.
谁能告诉我为什么?或者甚至更好地向我解释如何添加边框JTextField?