我正在尝试创建一个对象并将其添加到我创建的数组中,作为我构造的参数 GUI 对象。出于某种原因,我不断收到TheDates cannot be resolved to a Variable。
正在构造的对象:
public static void main(String[] args)
{
DateDriver myDateFrame = new DateDriver();
}
//Constructor
public DateDriver()
{
outputFrame = new JFrame();
outputFrame.setSize(600, 500);
outputFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String command;
Date [] theDates = new Date[100]; //this is the array I am having issues with
int month, day, year;
...
}
这就是我对 theDates 的问题所在:
public void actionPerformed(ActionEvent e)
{ //The meat and Potatoes
if ( e.getSource() == arg3Ctor)
{
JOptionPane.showMessageDialog(null, "3 arg Constructor got it");
int month = Integer.parseInt(monthField.getText());
int day = Integer.parseInt(dayField.getText());
int year = Integer.parseInt(yearField.getText());
theDates[getIndex()] = new Date(month, day, year);//here is the actual issue
}
}
我不知道是我想多了还是怎么了,我尝试过将数组设为static、public等。我也尝试过将其实现为myDayeFrame.theDates
.
非常感谢任何指导