我花了一整天的时间在网上和这个网站上寻找我的问题的答案,并希望你们能提供帮助.首先,当我选择"报告"时,我试图将a的内容显示ArrayList为a .数组列表位于与文本区域分开的另一个类中.我的问题源于数组列表是一个对象数组的事实,所以当我尝试显示它时,我得到错误:JTextAreaJButton
The method append(String) in the type JTextArea is not applicable
for the arguments (ArrayList.Account.TransactionObject>)
Run Code Online (Sandbox Code Playgroud)
我可以在控制台窗口中显示数组列表,但是在文本区域中显示它时却很难过.我假设必须存在将Object转换为String的某种问题,因为我无法将其转换为String或toString使用数组列表调用方法.这是我的代码的相关部分.....
这是AccountUI我创建的类中的部分JTextArea:
private JPanel get_ReportPane()
{
JPanel JP_reportPane = new JPanel(new BorderLayout());
Border blackline = BorderFactory.createLineBorder(Color.BLACK);
TitledBorder title = BorderFactory.createTitledBorder(blackline, "Transaction Report");
title.setTitleJustification(TitledBorder.CENTER);
JP_reportPane.setBorder(title);
/* Create 'labels' grid and JLabels */
JPanel report_labels = new JPanel(new GridLayout(2, 1, 5, 5));
report_labels.add(new JLabel("Current Account Balance: ", SwingConstants.RIGHT));
report_labels.add(new JLabel("Account Creation Date: ", SwingConstants.RIGHT));
JP_reportPane.add(report_labels, BorderLayout.WEST); …Run Code Online (Sandbox Code Playgroud)