java吧 关注:1,296,496贴子:12,833,582
  • 2回复贴,共1

问题求助!!!!

只看楼主收藏回复

public class LoadPanel extends JPanel {
    private JTextField dictionaryTextField;     // text field for dictionary
    private JTextField documentTextField;         // text field for document
    private JButton loadButton;                    // the load button
    private JLabel dictionaryLabel;     // label for dictionary text field
    private JLabel documentLabel;         // label for document text field
   
    /** Creates a new LoadPanel with empty text fields.
    */
    public LoadPanel() {
        dictionaryLabel = new JLabel("Dictionary:", JLabel.RIGHT);
        add(dictionaryLabel);
        dictionaryTextField = new JTextField("",12);
        add(dictionaryTextField);
        documentLabel = new JLabel("Document:", JLabel.RIGHT);
        add(documentLabel);
        documentTextField = new JTextField("",12);
        add(documentTextField);
        loadButton = new JButton("Load");
        add(loadButton);
    }   
   
然后这个是另外一个文件:
public class SpellCheckerView extends JFrame {
   
    private SpellChecker sc;    // the spell checker
    // the panel for loading dictionary and documents
    private LoadPanel loadPanel;   
    // the panel for displaying results and user errors
    private OutputPanel outputPanel;
    // the panel for correcting errors in the document
    private CorrectionPanel correctionPanel;
    // the panel for saving a corrected document
    private SavePanel savePanel;
   
   
    public SpellCheckerView(SpellChecker sc) {
        this.sc = sc;
        setTitle("Spell Checker");
        setBounds(250,50,700,700);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container c = getContentPane();
        addLoadPanel(c);
        //addButtons(c);
    }
   
   
    public void addLoadPanel(LoadPanel lp){
       
       
    }
我想在public void addLoadPanel(LoadPanel lp)里调用那些textfield什么的,
要怎么做呀?
求人帮忙~!!!!
感激!!!



1楼2010-05-20 11:17回复
    我是压根儿没看这是干什么用的 只看问题了
    一个类要调用另一个类的属性 只能创建类实例 然后调用set get方法


    2楼2010-05-20 11:58
    回复
      2026-02-01 05:03:34
      广告
      不感兴趣
      开通SVIP免广告
      具体怎么弄呀?大神赐教
      是同一个界面来的,我觉得只要在view里面直接用JPanel就好了
      但是老师偏偏把LoadPanel放在另外的地方,要我们在View里调出那些button什么的


      3楼2010-05-20 12:08
      回复