本文介绍了使JCheckbox更大..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使JTable中的JCheckboxes更大(对于触摸屏),但是它不会改变大小.
i want to make my JCheckboxes in a JTable bigger (for Touchscreen), but it doesn't change the size.
我尝试过
- setPrefferedSize
- setSize
我该怎么办?..
推荐答案
我假设您的意思是您想要一个更大的复选框.如果是这样,则需要创建图像以表示复选框的未选择和已选择图标.然后,您可以使用这些图标创建渲染器和编辑器.最后,您需要增加表格中每一行的高度.该代码可能类似于:
I assume you mean you want a bigger check box. If so then you need to create images to represent the unselected and selected icons of the check box. Then you can create a renderer and editor using these icons. Finally you would need to increase the height of each row in the table. The code might look something like:
Icon normal = new ImageIcon(...);
Icon selected = new ImageIcon(...);
JTable table = new JTable(...);
table.setRowHeight(...);
TableCellRenderer renderer = table.getDefaultRenderer(Boolean.class);
JCheckBox checkBoxRenderer = (JCheckBox)renderer;
checkBoxRenderer.setIcon( normal );
checkBoxRenderer.setSelectedIcon( selected );
DefaultCellEditor editor = (DefaultCellEditor)table.getDefaultEditor(Boolean.class);
JCheckBox checkBoxEditor = (JCheckBox)editor.getComponent();
checkBoxEditor.setIcon( normal );
checkBoxEditor.setSelectedIcon( selected );
这篇关于使JCheckbox更大..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!