How can i return my results through a jLabel instead of "System.out.print"?
I have created a project which implements a game played at the terminal. The player explores various rooms( they are described to him on the terminal) and can use some commands (by writing them at the terminal) with which he can go to other rooms,pick up items and do other stuff like that (for those of you who know it,it's called world of zuul).
This project works perfectly! However, I want to go a step forward and create a GUI for the game!In the GUI that i am trying to create, I have used a JMenuBar with the command as JMenu(s).So far so good.The problem is that i am trying to return the results of each command through a jLabel. Thus, i have given an ActionListener at each command which calls the corresponding method from the game and i want the results that are shown with the
"System.out.print" , to be shown at the jLabel...how can i do that?Is it even possible?
I am not entirely sure one can understand exactly what i am trying to do, so if you want any further explanations, please don't hesitate to ask :D
Re: How can i return my results through a jLabel instead of "System.out.print"?
Yes it is possible. There are a few ways of doing it but the easiest is to have an instance variable (eg private JLabel myLabel;) that references the JLabel and in the action listeners use the reference to set the text value to display (eg myLabel.setText("Some Text");)