实现JComboBox 下拉菜单鼠标悬停提示功能

 1 
 2 JComboBox comboBoxRow= new JComboBox();
 3 
 4 comboBoxRow.setRenderer(new ListCellRenderer() {  
 5             private ListCellRenderer renderer = comboBoxRow.getRenderer();  
 6             public Component getListCellRendererComponent(JList list,  
 7             Object value, int index, boolean isSelected, boolean cellHasFocus) {  
 8                 Component component = renderer.getListCellRendererComponent(  
 9                         list, value, index, isSelected, cellHasFocus);  
10                 if (component instanceof JLabel) {  
11                     JLabel label = (JLabel) component;  
12                     label.setToolTipText(label.getText());  
13                 }  
14                 return component;  
15             }  
16         });


眼镜蛇

posted on 2014-07-30 16:47 眼镜蛇 阅读(433) 评论(0)  编辑  收藏 所属分类: AWT/SWING/SWT


只有注册用户登录后才能发表评论。


网站导航:
 
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

统计

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜