跪求列表组件:希望这个组件能像Windows文件浏览器一样能够实现大图标、小图标、列表、详细信息等功能,最好有监听在图标上的单击、双击、右击。用基本组件来实现的方法也可以,谢谢了!E-mail:[email protected],请发邮件给我,谢谢了!如果我搞到了,有需要的请发邮件给我,我会转发给你的!
有希望要这个组件的同行记得顶呀,让这个帖子别沉了。

解决方案 »

  1.   

    图表什么的我不会,用list组件可以实现列表的基本功能
    我把list支持的事件列一下以供参考  action  focus  item  key  mouse  mousemotion
    希望能给你有帮助
      

  2.   

    那你有没有已经实现的代码?可不可以发到我邮箱?
    [email protected]
      

  3.   

    我本来已经放弃了的.....因为在排版方面我一直解决不了...你看看吧,希望对你有帮助.不过在用之前,请复制一个png图片文件到C:/a.png作为图标.从楼下开始放.
      

  4.   

    import javax.swing.*;import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    public class Chooser extends JPanel implements ItemListener,ActionListener
    {
    protected String add="C:";
    protected JComboBox jcb;
    public Chooser()
    {
    String[] disks={"C:/","D:/","E:/","F:/"};
    jcb=new JComboBox(disks);
    jcb.setEditable(true);
    this.setLayout(new BorderLayout());
    JLabel jl=new JLabel("地址");
    JButton jb=new JButton("转到");
    jb.addActionListener(this);
    this.add(jl,BorderLayout.WEST);
    this.add(jcb,BorderLayout.CENTER);
    this.add(jb,BorderLayout.EAST);
    jcb.addItemListener(this);

    }
    public void setAddress(String add)
    {
    this.add=add;
    jcb.getEditor().setItem(add);
    }
    public String getAddress()
    {
    return add;
    } public void itemStateChanged(ItemEvent e) 
    {
    add=(String)jcb.getModel().getSelectedItem();
    MainFrame.hi.setData(add);
    }
    public void actionPerformed(ActionEvent e) {
    MainFrame.hi.setData(add);
    }
    }
      

  5.   

    HList.java:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.net.URI;
    import java.net.URISyntaxException;public class HList extends JPanel implements ActionListener
    {
    File f;
    String path=null;
    Vector v=new Vector();
    int showStyle=FileItem.BIG_ICON;
    public HList()
    {
    setData("C:/");
    }
    public void setData(String path)
    {
    f=new File(path);
    MainFrame.ci.setAddress(path);
    this.path=path;
    this.removeAll();
    this.validate();
    this.repaint();
    File[] temp=f.listFiles();
    for(int i=0;i<temp.length;i++)
    {
    FileItem temp2=new FileItem(temp[i].getName(),showStyle,temp[i].getAbsolutePath());
    temp2.addActionListener(this);
    this.add(temp2);
    }
    this.setSize(400,400);

    }
    public void setStyle(int type)
    {
    showStyle=type;
    setData(path);
    }
    public void actionPerformed(ActionEvent e) 
    {
    File f2=new File(((FileItem)e.getSource()).abp);
    if(f2.isDirectory())
    {
    this.setData(f2.getAbsolutePath());
    }
    else
    {
    try {
    Desktop.getDesktop().browse(new URI(f2.getAbsolutePath().replace('\\', '/')));
    } catch (Exception e1) {
    e1.printStackTrace();
    }
    }
    }
    }class FileItem extends JButton
    {
    public static int BIG_ICON=1;
    public static int LIST_ICON=2;
    public String abp=null;
    public FileItem(String name,int listType,String abp)
    {
    this.abp=abp;
    this.setContentAreaFilled(false);
    if(name.length()>8){
    this.setText(name.substring(0,8));
    this.setToolTipText(name);
    }
    else this.setText(name);
    //this.setIcon(new ImageIcon(type+listType+".png"));//
    this.setIcon(new ImageIcon("C:/a.png"));//测试用.实际写的时候,你得准备很多图片
    this.setVerticalTextPosition(JLabel.CENTER);
    this.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    }

    }
      

  6.   

    这是“hoverlees(好棒)”发给我的短消息,公布如下(希望对你有好处):郁闷啊,帖子不能连续回复三次,最后一个文件我私邮给你吧.希望对你有点帮助.注意,HList.java里用了JDK1.6的Desktop类,如果你是1.5,把那儿去掉就是.import javax.swing.*;import java.awt.*;public class MainFrame extends JFrame
    {
    protected Chooser c;
    protected HList h;
    public static Chooser ci=null;
    public static HList hi=null;
    public MainFrame()
    {
    super("试试.呵呵."); 
    c=new Chooser();
    ci=c;
    h=new HList();
    hi=h;
    JScrollPane jsp=new JScrollPane();
    jsp.setViewportView(h);
    this.getContentPane().setLayout(new BorderLayout());
    this.setSize(Toolkit.getDefaultToolkit().getScreenSize());
    this.getContentPane().add(c,BorderLayout.NORTH);
    this.getContentPane().add(jsp,BorderLayout.CENTER);
    this.setDefaultCloseOperation(3);
    this.setVisible(true);
    }
    public static void main(String[] args)
    {
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) 
    {
    e.printStackTrace();
    }
    new MainFrame();
    }
    }