ArrayList <String> cdcollection = new ArrayList();
private void initButtonActionPerformed(java.awt.event.ActionEvent evt) {
Collections.addAll(cdcollection, "renier\n", "mert\n", "rain\n", "mylen", "dreb\n" );
initButton.setEnabled(false);
}
private void displayButtonActionPerformed(java.awt.event.ActionEvent evt) {
String title1 = "Original Order\n\n";
String title2 = "Sorted Order\n\n";
String collection = "";
for (int i = 0; i < cdcollection.size(); i++) {
collection = collection + cdcollection.get(i);
}
mainTextArea.setText(title1 + collection);
Collections.sort(cdcollection);
for (int j = 0; j < cdcollection.size(); j++) {
mainTextArea.setText(title2 + collection.get(j));
}
}
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
cdcollection.add(cdtitleInput.getText());
}
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {
cdcollection.remove(cdcollection.size()-1);
}
对于这一行 mainTextArea.setText(title2 + collection.get(j)); 我收到一个错误“找不到符号”,并且在我运行程序时它不显示。我所看到的只有这样:
原始订单
雷尼尔·梅特
·雷恩·
迈伦
·德雷布