我正在尝试调用 void 方法 addToList,它除了将通过用户传递给它的两个字符串。我检查了 dataSource 类以确保它确实接受这些作为参数。问题是我在该方法调用上不断收到标识符>预期错误,我不知道为什么。我已经使用数据源调用了其他方法并且没有遇到类似的问题。
public class JListFromFile extends JFrame {
private TextField wordA;
private TextField wordB;
private JButton openButton;
private JButton newButton;
private JButton addButton;
private JButton deleteButton;
private JButton saveButton;
private TextField output;
private JList listFromFile;
private JPanel listPanel;
private JPanel textPanel;
private JPanel inputPanel;
private JPanel buttonsPanel;
private DataSource2 dataSource;
private WordPair wordPair;
public JListFromFile ()
{
// create the object to provide the data
dataSource = new DataSource2();
.
.
.
private class AddButtonListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
listFromFile.setListData(new Object[0]);
wordA.setEnabled(true);
wordB.setEnabled(true);
String inputStringA = wordA.getText();
String inputStringB = wordB.getText();
//here is the problem
dataSource.addToList.(inputStringA, inputStringB);
}
}