views:

33

answers:

1

This is an undo feature button on a calculator that I am writing. undo is the button Status is a class that holds my status. listOfStates is an ArrayList of Status. displayBox is a object of JTextFeild. What I do not under stand is that when I display previousState in the text box I get something like: Status@11dc088. I know I am missing casting something here. Thanks for any help.

if(e.getSource() == undo)
             {
                 Status previousState  = (Status) listOfStates.get(listOfStates.size()- 1);

                 displayBox.setText(" ");
                 displayBox.setText(displayBox.getText()  + previousState);
                 System.out.println(previousState);
                }
+3  A: 

Status is a custom class and you didn't implement a toString() method so you get the Object default toString() method.

Override the toString() method in the Status class to return a meaningfull String.

Or, use a method from your class like previousState.getStatus() to use the appropriate property from your class.

camickr