gpt4 book ai didi

Java 找不到我的类的方法

转载 作者:行者123 更新时间:2023-12-01 22:14:07 24 4
gpt4 key购买 nike

我见过类似的问题,但其答案并不能解决我的问题。

在下面的代码中,我可以创建一个 BookCard对象并调用其 getAuthorField其他类中的方法,但我的 IDE 似乎没有从需要它的特定类中找到它。

package com.company;

import com.SourceTypeCards.BookCard;
import com.SourceTypeCards.FilmCard;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class EditSourceDialog extends JDialog
{
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JComboBox<Enum> typeOfSourceComboBox;
private JPanel cards;

JTextField authorNameField = new JTextField(20);

JPanel bookCard = new BookCard();
JPanel filmCard = new FilmCard();

...

private void onOK()
{
System.out.println(bookCard.getAuthorField()); //CANNOT RESOLVE METHOD

dispose();
}
}

为什么我的 IDE/编译器在这个特定的 EditSourceDialog 中找不到这个方法类?

BookCard.java

package com.SourceTypeCards;

import javax.swing.*;

/**
* Created by Trevor on 14/07/2015.
*/
public class BookCard extends MainCard
{
JLabel authorLabel;
JLabel editorsLabel;
JLabel yearPublishedLabel;
JLabel titleLabel;

CardTextField authorField;
JCheckBox editorsCheckBox;
CardTextField yearPublishedField;
CardTextField titleField;

...

public String getAuthorField()
{
return authorField.getText();
}
}

最佳答案

改变

JPanel bookCard = new BookCard();

BookCard bookCard = new BookCard();

关于Java 找不到我的类的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31415563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com