0

I have two buttons that are supposed to open JOptionPanes. One of them does not format to the right size. The code looks the same to me. What am I doing wrong here?

This one does not display all the text in the JTextArea:

enter image description here

public static void listAllTransactions(){
    DecimalFormat fmt = new DecimalFormat("0.00");
    String message = "List All Transactions \n";
    message += "Name: " + ca.getName() + "\n\n";
    message += "ID\tType\tAmount\n";
    for (Transaction t : ca.transactions){
        message += t.getTransNumber() + "\t" +
                HelperTransactionIds.getTransactionName(t.getTransIdType()) + "\t$" +
                fmt.format(t.getTransAmount()) + "\n";
    }
    JTextArea jTextArea = new JTextArea(message);
    jTextArea.setEditable(false);
    jTextArea.setBackground(Color.LIGHT_GRAY);
    JOptionPane.showMessageDialog(null,jTextArea);
} 

The other one works as intended.

enter image description here

The code looks the same to me but I could be missing something:

public static void listChecks(){
    DecimalFormat fmt = new DecimalFormat("0.00");
    String message = "List All Checks \n";
    message += "Name: " + ca.getName() + "\n\n";
    message += "ID\tCheck\tAmount\n";
    for (Transaction t : ca.transactions){
        if (t.getTransIdType() == HelperTransactionIds.CHECK){
            Check myCheck = (Check) t;
            message += t.getTransNumber() + "\t" +myCheck.getNumber() + "\t$" + fmt.format(t.getTransAmount()) + "\n";
        }
    }
    JTextArea jTextArea = new JTextArea(message);
    jTextArea.setEditable(false);
    jTextArea.setBackground(Color.LIGHT_GRAY);
    JOptionPane.showMessageDialog(null, jTextArea);
}
Funlamb
  • 551
  • 7
  • 20

0 Answers0