class Stars extends Frame{
    Choice one=new Choice();
    .... 
    one.addItem("需要的");
    ....
    add(one);
    ....
}
学的不好,只做参考.
     

解决方案 »

  1.   

    package com.surge.business;import javax.swing.*;
    import java.awt.*;
    import java.util.ArrayList;/**
     * <p>Title: 巨澜客户管理平台(实现旧系统开户管理)</p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2000-2004</p>
     * <p>Company: 深圳市巨澜信息技术有限公司</p>
     * @author 张翅飞 [e-mail:[email protected]]
     * @version 1.0
     */public class Frame extends JFrame
    {
      GridBagLayout gridBagLayout1 = new GridBagLayout();
      JComboBox box = new JComboBox();
      public static void main(String[] args)
      {
        Frame frame = new Frame();
        frame.setSize(800, 600);
        frame.show();
      }  public Frame()
      {
        try
        {
          jbInit();
        }
        catch (Exception ex)
        {
          ex.printStackTrace();
        }
      }  void jbInit() throws Exception
      {
        ArrayList list = new ArrayList();
        list.add("test1");
        list.add("test2");
        list.add("test3");
        list.add("test4");    for (int i = 0; i < list.size(); i++)
        {
          box.addItem((String)list.get(i));
        }    this.getContentPane().setLayout(gridBagLayout1);
        this.getContentPane().add(box, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));  }
    }