最近在模仿QQ的登录界面,QQ中输入账号的地方有以前登录过的QQ号列表,当鼠标移到某一项上时后面出现一个用于删除账号的小叉,同时该项背放大并突出显示,请问这种效果怎么做?
解决方案 »
- java有什么方法可以存储List<String>
- 无法访问网络位置%ALLUSERSPROFILE%\ 开始 菜单\程序\启动\。
- 帮忙写个注释
- 请教byte的基础问题
- 大家帮帮忙,,js代码调用JSP时,想使用STRUTS技术,这样的问题应该怎么解决,感谢
- java.sql.connection是不是线程安全的?我想整个应用中只创建一个connection
- 怎样可以使JFrame的最大化按钮失效?
- 请问java的二维数组中。我如何知道行数,和列数
- 请大家讨论一下数学功底与编程能力(美国的程序员)
- 关于java的事件问题,如何在程序中使一个button被click,从而引发这个button的事件处理代码????
- j2ee filter
- 什么是try1和try2 我怎么没听说过???
{
...
public Component getListCellRendererComponent(JList list, Object obj, int row, boolean sel, boolean hasFocus)
{
...
return this;
}
...
}JComboBox jcb = new JComboBox();
jcb.setRenderer(new MyComboRenderer());
另外请问一个问题,我想给每一个项添加一个鼠标进入事件,该怎么写???public class ComboBoxRenderer implements ListCellRenderer{
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
@Override
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
Font theFont = null;
Color theForeground = null;
Icon theIcon = null;
String theText = null;
JLabel render=(JLabel)defaultRenderer.getListCellRendererComponent(list, value,
index, isSelected, cellHasFocus);
if(value instanceof ComboBoxItem){
ComboBoxItem item=(ComboBoxItem)value;
theFont=item.getFont();
theForeground=item.getColor();
theIcon=item.getIconItem();
theText=item.getStrItem();
}else{
theFont=list.getFont();
theForeground=list.getForeground();
theText="";
theIcon=null;
}
if(!isSelected){
render.setForeground(Color.BLACK);
render.setPreferredSize(new Dimension(100,30));
}else{
render.setBackground(new Color(55,142,206));
render.setPreferredSize(new Dimension(100,80));
}
if(theIcon != null){
render.setIcon(theIcon);
}
render.setText(theText);
render.setFont(theFont);
return render;
}}