[英]Remove cell editor border in JTable (Windows LaF)
After creating the table you can try something like: 创建表后,您可以尝试如下操作:
DefaultCellEditor editor = (DefaultCellEditor)table.getDefaultEditor(Object.class);
JTextField textField = (JTextField)editor.getComponent();
textField.setBorder( null );
Edit: 编辑:
The above approach won't work because the JTable uses a GenericEditor
which is an inner class of the table that extend the DefaultCellEditor and adds extra functionality for the table. 上面的方法行不通,因为JTable使用
GenericEditor
,它是表的内部类,扩展了DefaultCellEditor并为表添加了额外的功能。
One piece of functionality added is to manager the Border: "red" for errors and "black" for valid data. 添加的一项功能是管理边界:“红色”表示错误,“黑色”表示有效数据。 So the border is continually being reset by the editor.
因此,边框不断被编辑器重置。
Or the other approach would be something like: 否则另一种方法可能是:
JTextField textField = new JTextField();
textField.setBorder( null );
DefaultCellEditor editor = new DefaultCellEditor( textField );
table.setDefaultEditor(Object.class, editor):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.