用JList类就可以了.添加这个ListSelectionListener监听器,用这个setSelectionMode方法设置为多选形式,用这个getSelectedIndices()方法得到选中的索引数组,用这个getSelectedValues()方法得到选择的对象数组,返回的是Object类型.而且JList还可以添加其它控件在里面,也就是可以添加一个checkbox在里面.

解决方案 »

  1.   

    我想把jdk的版本控制得稍微低一些,所以不想用swing的东西,awt中能实现吗?
      

  2.   

    use java.awt.List
    constructor:
    List(int rows, boolean enableMultipleSelection)List l=new List(10,true); //10 rows, permit multiple selections
      

  3.   

    list.select(int i)可以使某个item选中,但是这种选中去是没有触发itemchangelistener事件的,怎么使其马上触发呢?
      

  4.   

    List.select will not trigger ItemEvent. It is used to initialize selection.If you want to use this method to trigger ItemEvent, the only way I can suggest is to generate a ItemEvent and post to event quene. But you have other choices, for example, you can call your eventhandler directly.
    ...
    List.select(i);
    //do something
    ...
      

  5.   

    谢谢大家的回答:)
    我觉得applet已经写好了,但是后来发现出现了新的问题:就是把applet放在网页上的时候,当网页窗体大小变化时,有些图像显示错乱了,这种情况有时有有时没有(刷新后就好了),令我十分头疼:(
      

  6.   

    假如在applet的两端加上<p></p>或是<center></center>等元素的时候,初始的ie窗口比applet长宽下的时候,这是键入链接,再双击ie最大化,applet中draw出来的东西和button,list等控件都会乱了。
      

  7.   

    把applet放在<center></center>中的时候,当ie的size变化的时候,applet中的控件是不是会出现错误显示?!