如题:最好给代码和注释。我要的是在同一列,不同行可以添加不同的JCOMBOBOX控件,当然了,你们也可以告诉我在同列不同行怎么添加不同的控件,
解决方案 »
- java虚拟机设计模式
- 想实现局域网内数据的监控功能!!
- GUI,为什么组件绘图绘制了两次
- 求代码-java从DB中读取数据生成TXT放于异地问题
- ClassCastException
- 如何将窗口程序最小化到任务栏?
- properties的问题
- 实现双向链表,用哪个集合比较好?map?list?tree ?????????????
- ServerSocket 和 Socket 相互发信息的问题
- 用Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");的情况下,可不可以用dbo的用户名和密码来操作自定义的数据库,要怎
- java基础知识。。。关于移位(不知道这样表达对不。。看题)
- String str = textfield1.getText(); 这里str值不为空啊?textfield框内可是空的
{
public CheckBoxRenderer()
{
setNameForAutoTest();
}
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column)
{
Component res = super.getTableCellRendererComponent(table,
value,
isSelected,
hasFocus,
row,
column);
//当前组件为JLabel类型,才可设置渲染器
if (res instanceof JLabel)
{
//当前鼠标选中此行
if (isSelected)
{
_checkBox.setSelected(true);
// setForeground(table.getSelectionForeground());
// setBackground(table.getSelectionBackground());
}
if (_showCheckBox && (Boolean) value)
{
_checkBox.setSelected(true);
// setForeground(table.getSelectionForeground());
// setBackground(table.getSelectionBackground());
}
//未选中的情况
else
{
_checkBox.setSelected(false);
// _checkBox.setBackground(UIManager.getColor("CheckBox.background"));
}
/* 设置表格的灰化状态 */
if (!IsmTable.this.isEnabled())
{
_checkBox.setOpaque(true);
_checkBox.setEnabled(false);
// setBackground(disablebackground);
}
else
{
_checkBox.setOpaque(false);
_checkBox.setEnabled(true);
// setBackground(Color.WHITE);
} _checkBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
return _checkBox;
}
return res;
}
//表格灰化背景色
//private Color disablebackground = new Color(238, 238, 238);
//复选框
private JCheckBox _checkBox = new JCheckBox();
}
可以指定一列,甚至一个单元格;
可以根据取得的数据类型绑定编辑器而且JComboBox类型的编辑器又在swing中有默认的提供,这个很简单。
虽说两者本质并无太大不同,但是既然涉及到了编辑,自然牵涉到保存数据的类型问题。你要哪种?