1 Replies - 186 Views - Last Post: 01 November 2017 - 05:58 PM Rate Topic: -----

#1 Jubie3018  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-October 17

What is this error "AWT-EventQueue-0" java.lang.ClassCastExcep

Posted 01 November 2017 - 05:43 PM

Hi !

I've been advised to add certain lines to fix errors, and I started getting this new error saying
"Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: main.Transaction cannot be cast to main.Deposit"
It's the lines 11 and 14 respectively.

I'd really appreciate all the help ! Thanks in advance.

I was wondering what exactly that meant, and how to fix it. .

public static void listDeposits() {
        String message;
        frame.setVisible(false);

        message = "List of All Deposits Made for " + c.getName() + "\n" + "\n";
        message += String.format("%-7s%10s%15s%20s\n", "ID", "Check", "Cash", "Amount");

        for (int i = 0; i < c.getTransCount(); i++) {
            if (c.getTrans(i).getTransId() == 2) {
                String amount = fmt.format(c.getTrans(i).getTransAmount());
                dpst = (Deposit)c.getTrans(i);
                message += String.format("%-7s%10s%15s%20s\n", c.getTrans(i).getTransNumber(), dpst.getCheckAmt(), dpst.getCashAmt(), amount);
            }
        }
        JTextArea text = new JTextArea(message);
        text.setBorder(null);
        text.setOpaque(false);
        text.setFont(new Font("Monospaced", Font.PLAIN, 14));
        JOptionPane.showMessageDialog(null, text);

        frame.setVisible(true);
    }


    public static void listChecks() {
        String message;
        int checknumb;

        frame.setVisible(false);

        message = "List of All Checks for " + c.getName() + "\n" + "\n";
        message += String.format("%-20s%-20s%15s\n", "ID", "Check #", "Amount");

        for (int i = 0; i < c.getTransCount(); i++) {

            if (c.getTrans(i).getTransId() == 1) {
                String amount = fmt.format(c.getTrans(i).getTransAmount());
                chk = (Check)c.getTrans(i);
                message += String.format("%-20d%-20d%15s\n", c.getTrans(i).getTransNumber(), chk.getCheckNumber(), amount);
            }
        }
        JTextArea text = new JTextArea(message);

        text.setBorder(
                null);
        text.setOpaque(
                false);
        text.setFont(
                new Font("Monospaced", Font.PLAIN, 14));
        JOptionPane.showMessageDialog(
                null, text);

        frame.setVisible(
                true);
    }


Is This A Good Question/Topic? 0
  • +

Replies To: What is this error "AWT-EventQueue-0" java.lang.ClassCastExcep

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,887
  • Joined: 12-June 08

Re: What is this error "AWT-EventQueue-0" java.lang.ClassCastExcep

Posted 01 November 2017 - 05:58 PM

This looks like the topic here.

http://www.dreaminco...ost__p__2341994

Please do not create duplicate topics.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1