请各位大大帮我解决下,急啊 就是实现象jbuilder在系统选择jar包时候,那个显示磁盘和文件夹的combo 最好里面也有图片的那种 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.Component;import javax.swing.*;public class Test { private JFrame frame = null; private JPanel pane = null; private JComboBox com = null; private String[] s = { "111111", "222222", "333333", "444444", "555555" }; public Test() { frame = new JFrame("Test"); pane = new JPanel(); com = new JComboBox(s); com.setRenderer(new IconLabel()); pane.add(com); frame.getContentPane().add(pane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 200); frame.setVisible(true); } public static void main(String[] args) { new Test(); }}class IconLabel extends JLabel implements ListCellRenderer { public IconLabel() { this.setOpaque(true); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) { this.setText(value.toString()); this.setIcon(new ImageIcon("images/mycomputer.png")); //这里可以根据index的值载入不同的Icon } if (isSelected) { this.setBackground(list.getSelectionBackground()); this.setForeground(list.getSelectionForeground()); } else { this.setBackground(list.getBackground()); this.setForeground(list.getForeground()); } return this; }} 就是象jb那样的,有路径的那种,就在combo中显示出来,可以只显示打开后的路径 不常用JBuilder,不清楚你说的是什么样子是否像Windwos地址栏那样前面是硬盘或目录的图标,后面是c:\xxx这样的路径?这个路径JComboBox是无法自动获取的,需要你自己写代码实现。 JAVA的内存分配问题,求简答。 如何由string类型的类名生成类的实例? 关于散点变化趋势的判断 用swing如何实现一款软件的多种语言的切换? request.getsession()的方法问题? 请问J2SE中有播放PCM语音的类吗? 了解 在BC4J 基础上进行应用程序开发的朋友 进来聊聊 关于java开发? 麻烦大家帮才鸟看个程序 关于多语言得问题 org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask 问题!!!!!!,请看看! 關於WindowAdapter--windowClosing的疑惑
import javax.swing.*;
public class Test {
private JFrame frame = null;
private JPanel pane = null;
private JComboBox com = null;
private String[] s = { "111111", "222222", "333333", "444444", "555555" };
public Test() {
frame = new JFrame("Test");
pane = new JPanel();
com = new JComboBox(s);
com.setRenderer(new IconLabel());
pane.add(com);
frame.getContentPane().add(pane);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
new Test();
}
}class IconLabel extends JLabel implements ListCellRenderer {
public IconLabel() {
this.setOpaque(true);
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value != null) {
this.setText(value.toString());
this.setIcon(new ImageIcon("images/mycomputer.png")); //这里可以根据index的值载入不同的Icon
}
if (isSelected) {
this.setBackground(list.getSelectionBackground());
this.setForeground(list.getSelectionForeground());
} else {
this.setBackground(list.getBackground());
this.setForeground(list.getForeground());
}
return this;
}
}
是否像Windwos地址栏那样前面是硬盘或目录的图标,后面是c:\xxx这样的路径?这个路径JComboBox是无法自动获取的,需要你自己写代码实现。