个人以为在第一个类中应该添加一个方法 获取isSelected()的返回值
这样在第二个类中就可以调用了
不知道楼主以为如何

解决方案 »

  1.   

    你为什么一定要用inner class ?
    不妨试一下做成一个单独的adapter.
    For example:
    package org.gift2u.test;import javax.swing.*;
    import java.awt.*;
    import javax.swing.DefaultComboBoxModel;
    import java.awt.event.*;
    public class Testcombobox extends JFrame {
      JComboBox jComboBox1 = new JComboBox();
      DefaultComboBoxModel model = new DefaultComboBoxModel();
      JPanel jPanel1 = new JPanel();
      FlowLayout flowLayout1 = new FlowLayout();
      JButton jButton1 = new JButton();
      public Testcombobox() {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      private void jbInit() throws Exception {
        jComboBox1.setModel(model);
        model.addElement("gift1");
          model.addElement("gift2");
            model.addElement("gift3");
        jPanel1.setLayout(flowLayout1);
        jButton1.setText("jButton1");
        jButton1.addActionListener(new Testcombobox_jButton1_actionAdapter(this));
        this.getContentPane().add(jComboBox1, BorderLayout.NORTH);
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(jButton1, null);
      }
      public static void main(String[] args) {
        new Testcombobox().show();
      }  void jButton1_actionPerformed(ActionEvent e) {
          jButton1.setText(""+this.jComboBox1.getSelectedIndex()); ;
      }
    }class Testcombobox_jButton1_actionAdapter implements java.awt.event.ActionListener {
      Testcombobox adaptee;  Testcombobox_jButton1_actionAdapter(Testcombobox adaptee) {
        this.adaptee = adaptee;
      }
      public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
      }
    }