JComboBox()
Creates a JComboBox with a default data model. The default data model is an empty list of objects. Use addItem to add items. By default the first item in the data model becomes selected.
Creates a JComboBox with a default data model. The default data model is an empty list of objects. Use addItem to add items. By default the first item in the data model becomes selected.
解决方案 »
- 关于输入5句话然后将它逆序输出问题~~~
- 为什么我点击标签,背景颜色不变化啊?请大吓帮忙碌!
- 本人刚学JAVA 要做个小项目 求解答这个语句
- 问个java网络方面的问题
- 对于浮点数中用科学计数法中带有的e怎么去掉啊
- Java里是怎么样实现打印报表的呢,这里这么多高人,没有愿意指点一下吗,都问了好几天了。。。
- 高分求救:如何在一个应用里建立多个数据库连接?
- 我是初学者,请问如何在DOS下设置classpath
- 如何将Srting类型的字符窜转换成byte[]类型的数组呢?
- 请问各位怎样设置JDK1.3中的CLASSPATH,还有JAVA怎样和ORACLE数据库连上.......
- ★★★★★★★★★分页标签是否只能针对ResultSet分页?★★★★★★★★★★
- java爱好者
implements ListCellRenderer {
. . .
public ComboBoxRenderer() {
setOpaque(true);
setHorizontalAlignment(CENTER);
setVerticalAlignment(CENTER);
} /*
* This method finds the image and text corresponding
* to the selected value and returns the label, set up
* to display the text and image.
*/
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
//Get the selected index. (The index param isn't
//always valid, so just use the value.)
int selectedIndex = ((Integer)value).intValue(); if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
} //Set the icon and text. If icon was null, say so.
ImageIcon icon = images[selectedIndex];
String pet = petStrings[selectedIndex];
setIcon(icon);
if (icon != null) {
setText(pet);
setFont(list.getFont());
} else {
setUhOhText(pet + " (no image available)",
list.getFont());
} return this;
}
. . .
}你把JPanel改为JTextField再改改