Java – make jcheckbox bigger?

I want to make the JTable JCheck@R_695_2419 @Larger (for touchscreen), but it doesn't change size

I tried

> setPrefferedSize > setSize

What should I do?

Solution

I suppose you mean you want a bigger check box If so, you need to create an image to represent the unselected and selected icons of the check box You can then use these icons to create renderers and editors Finally, you need to increase the height of each row in the table The code may be similar to:

Icon normal = new ImageIcon(...);
Icon selected = new ImageIcon(...);
JTable table = new JTable(...);
table.setRowHeight(...);

TableCellRenderer renderer = table.getDefaultRenderer(Boolean.class);
JCheck@R_695_2419@ check@R_695_2419@Renderer = (JCheck@R_695_2419@)renderer;
check@R_695_2419@Renderer.setIcon( normal );
check@R_695_2419@Renderer.setSelectedIcon( selected );

DefaultCellEditor editor = (DefaultCellEditor)table.getDefaultEditor(Boolean.class);
JCheck@R_695_2419@ check@R_695_2419@Editor = (JCheck@R_695_2419@)editor.getComponent();
check@R_695_2419@Editor.setIcon( normal );
check@R_695_2419@Editor.setSelectedIcon( selected );
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>