JComboBox渲染
JComboBox 的渲染,直接放在上面给出提示。/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sunny_tec_feng;
import java.awt.Component;
import java.util.Vector;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
/** www.zzzyk.com
*
* @author adm
*/
public class ToolTipComboBox extends JComboBox {
public ToolTipComboBox(ComboBoxModel aModel) {
super(aModel);
render render1 = new render();
setRenderer(render1);
}
public ToolTipComboBox(Object[] items) {
super(items);
render render1 = new render();
setRenderer(render1);
}
public ToolTipComboBox(Vector<?> items) {
super(items);
render render1 = new render();
setRenderer(render1);
}
public ToolTipComboBox() {
render render1 = new render();
setRenderer(render1);
}
class render extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel listCellRendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
listCellRendererComponent.setToolTipText(String.valueOf(value));
return listCellRendererComponent;
}
}
}
补充:综合编程 , 其他综合 ,