Hi all,
I have created a FortuneTeller Class which creates a frame and button. When the button is pressed a random number is generated which is then used to select a
string from an array full of possible fortunes. At the minute, I can only display the fortune in my eclipse console using System.out.println(output); However, I would like to make the fortune appear on the frame alongside the button being pressed. My plan is for each time the button is pressed, the current fortune being displayed is erased and a new one is presented in its place.
The problem I am having is that I can't figure out how to display anything on the frame unless it is a fixed string using JLabel textLabel = new JLabel("text for fortune to go here",SwingConstants.CENTER); I'd like to use the output from the ButtonHandler Class, which would be somehow using the 'output' string variable.
Any advice would be much appreciated at this point as I feel like I'm hitting a brick wall. I know my output variable is of type String, and that output can't be used outwith the ButtonHandler class, but I can't figure out how to transfer that data to a more accessible variable.
I've attached my code, both classes for perusal if you have a few spare minutes.
Main FortuneTeller Class
RandomNumberSelector Class