フロリダ州のレイク情報を入力できるGUIを作成し、そのレイク情報を表示する機能があります。表示情報をJOptionPane.showMessageDialogに入れて、すべての湖の名前のArrayListをスクロールする機能が必要です。 ArrayListに湖を追加することはできますが、JOptionPaneには表示されず空白です。私はそれがそのウィンドウを開いているので、それがArrayListで何かを読んでいることを知っています。以下は、すべてのことがクレイであるようにスニペットで以下のコードです。スクロール機能付きJTextAreaの配列を表示
public static ArrayList<Lakes> lake = new ArrayList<Lakes>();
private JTextArea textAreaDisplay;
private JScrollPane spDisplay;
// this is called in my initComponent method to create both
textAreaDisplay = new JTextArea();
for (Object obj : lake)
{
textAreaDisplay.append(obj.toString() + " ");
}
spDisplay = new JScrollPane(textAreaDisplay);
textAreaDisplay.setLineWrap(true);
textAreaDisplay.setWrapStyleWord(true);
spDisplay.setPreferredSize(new Dimension(500, 500));
// this is called in my createEvents method. After creating lakes in the database
// it will display the else statement but it is empty
btnDisplayLake.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try
{
if (lake.size() == 0)
{
JOptionPane.showMessageDialog(null, "No Lakes in database!");
}
else
JOptionPane.showMessageDialog(null, spDisplay, "Display Lakes", JOptionPane.YES_NO_OPTION);
}
catch (Exception e1)
{
}
}
});
ご協力いただきありがとうございます。私はこれについて数日間、私の脳をぶら下げている。他のものを完成させることができましたが、この問題に戻ってきました。
1)すぐに役立つようにするには、[MCVE]または[短く、自己完結型の正しい例](http://www.sscce.org/)を投稿してください。 2)例外を無視しないでください!彼らは何が悪くなったのかを正確に知らせます。ロギングが実装されていない限り、少なくともThrowable.printStackTrace()を呼び出します。 –