[jtable]设置复选框前景色与背景色
2013-06-27 10:13
309 查看
//表JComboBox数据
String[]status={"启用","禁用","停用"};
JComboBoxcom=newJComboBox(status);
JComboBoxRendererselect=newJComboBoxRenderer();
com.setRenderer(select);
//ListCellRenderer监听
classJComboBoxRendererextendsJLabelimplementsListCellRenderer{
publicJComboBoxRenderer(){
setOpaque(true);
}
publicComponentgetListCellRendererComponent(JListlist,
Objectvalue,
intindex,
booleanisSelected,
booleancellHasFocus){
setText(value.toString());
Colorbackground;
Colorforeground;
//checkifthiscellrepresentsthecurrentDnDdroplocation
JList.DropLocationdropLocation=list.getDropLocation();
if(dropLocation!=null
&&!dropLocation.isInsert()
&&dropLocation.getIndex()==index){
background=Color.BLUE;
foreground=Color.WHITE;
//checkifthiscellisselected
}elseif(isSelected){
background=Color.RED;
foreground=Color.WHITE;
//unselected,andnottheDnDdroplocation
}else{
background=Color.yellow;
foreground=Color.BLACK;
};
setBackground(background);
setForeground(foreground);
returnthis;
}
}
相关文章推荐
- Swing之JTable篇设置表格选中行的前景色和背景色
- QPalette类,主要用来设置控件背景色和前景色
- Python脚本实现单据体背景色及字段前景色设置
- 设置dos窗口的背景色与前景色
- Photoshop脚本 > 设置前景色和背景色
- 设置背景色和前景色
- C#中关于DataGridView行和列的背景色-前景色设置
- 控件的颜色设置(本景色,文本色,文本背景色)
- 控制台程序设置背景色和前景色
- 一个牛人写的“设置jtable单元格颜色,以及jtable中实现复选框”的程序,备忘
- 文档前景色和背景色设置
- Putty 设置前景色和背景色
- 给Swing的GUI组件设置前景色和背景色
- Enabled设置为False时,前景色和背景色也不改变的TextBox 并居中
- C#中关于DataGridView行和列的背景色-前景色设置
- 程序入口地址的直接定制表【 (1) 清屏(2) 设置前景色 (3) 设置背景色 (4) 向上滚动一行】
- MFC中可以设置字体颜色,背景色,前景色,是否透明
- linux 设置命令行属性,背景色,前景色等
- C# 读带复选框的excel,写excel并设置字体、边框、背景色
- MyEclipse设置当前行背景颜色、选中单词前景色、背景色