就是在一个JComboBox下选的框的时候。每个值的前面加一个JCheckBox。选的时候可以打上勾。实现多选。

解决方案 »

  1.   

    多选怎么会是你这样说的实现?要么是在JList中添加JCheckBox,或者直接在JPanel中添加JCheckBox,JComboBox只能选择一个
      

  2.   

    JCheckBox打上勾,得到复选框里选中的
      

  3.   

    你说的应该是列表吧
    VC也没有这样的控件啊
    JList
      

  4.   

    贴你个例子
    /**
       @version 1.02 2004-08-24
       @author Cay Horstmann
    */import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.*;
    import javax.swing.*;/**
       This program displays the effects of various transformations.
    */
    public class TransformTest
    {  
       public static void main(String[] args)
       {  
          JFrame frame = new TransformTestFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
       }
    }/**
       This frame contains radio buttons to choose a transformations
       and a panel to display the effect of the chosen 
       transformation.
    */
    class TransformTestFrame extends JFrame
    {  
       public TransformTestFrame()
       {  
          setTitle("TransformTest");
          setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);      canvas = new TransformPanel();
          add(canvas, BorderLayout.CENTER);      JPanel buttonPanel = new JPanel();
          ButtonGroup group = new ButtonGroup();      JRadioButton rotateButton = new JRadioButton("Rotate", true);
          buttonPanel.add(rotateButton);
          group.add(rotateButton);
          rotateButton.addActionListener(new
             ActionListener()
             {
                public void actionPerformed(ActionEvent event)
                {
                   canvas.setRotate();
                }
             });      JRadioButton translateButton = new JRadioButton("Translate", false);
          buttonPanel.add(translateButton);
          group.add(translateButton);
          translateButton.addActionListener(new
             ActionListener()
             {
                public void actionPerformed(ActionEvent event)
                {
                   canvas.setTranslate();
                }
             });      JRadioButton scaleButton = new JRadioButton("Scale", false);
          buttonPanel.add(scaleButton);
          group.add(scaleButton);
          scaleButton.addActionListener(new
             ActionListener()
             {
                public void actionPerformed(ActionEvent event)
                {
                   canvas.setScale();
                }
             });      JRadioButton shearButton = new JRadioButton("Shear", false);
          buttonPanel.add(shearButton);
          group.add(shearButton);
          shearButton.addActionListener(new
             ActionListener()
             {
                public void actionPerformed(ActionEvent event)
                {
                   canvas.setShear();
                }
             });      add(buttonPanel, BorderLayout.NORTH);
       }   private TransformPanel canvas;
       private static final int DEFAULT_WIDTH = 300;
       private static final int DEFAULT_HEIGHT = 300;
    }/**
       This panel displays a square and its transformed image
       under a transformation.
    */
    class TransformPanel extends JPanel
    {  
       public TransformPanel()
       {  
          square = new Rectangle2D.Double(-50, -50, 100, 100);
          t = new AffineTransform();
          setRotate();
       }   public void paintComponent(Graphics g)
       {  
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D) g;
          g2.translate(getWidth() / 2, getHeight() / 2);
          g2.setPaint(Color.gray);
          g2.draw(square);
          g2.transform(t);
          // we don't use setTransform because we want to compose with the current translation
          g2.setPaint(Color.black);
          g2.draw(square);
       }   /**
          Set the transformation to a rotation.
       */
       public void setRotate()
       {  
          t.setToRotation(Math.toRadians(30));
          repaint();
       }   /**
          Set the transformation to a translation.
       */
       public void setTranslate()
       {  
          t.setToTranslation(20, 15);
          repaint();
       }   /**
          Set the transformation to a scale transformation.
       */
       public void setScale()
       {  
          t.setToScale(2.0, 1.5);
          repaint();
       }   /**
          Set the transformation to a shear transformation.
       */
       public void setShear()
       {  
          t.setToShear(-0.2, 0);
          repaint();
       }   private Rectangle2D square;
       private AffineTransform t;
    }
      

  5.   

    楼上误解了。diggywang(Miner Lover!) 老兄怎么联系啊
      

  6.   

    Sprite_bei() 把代码帖出来看看。我现在。能画出样子来。但实现复选触发方面有点问题
      

  7.   

    使用Renderer
    我的思路也是这样的。样子出来了。实现覆盖原来JCombox监视听的时候有点问题
      

  8.   

    呵呵,我还是想象不出来用JComboBox来实现多选...
      

  9.   

    关注下,最近也在找这个东西
    还是有用的,最常用的就是用在生成SQL条件中的IN (,,,,)部分
    Jlist虽然可以加上CheckBox,但是太占空间
      

  10.   

    搜索Tame Swing, 小鬼子N久之前就作出来了.