Reputation: 558
I have a console application that uses System.out.println
's to output text. What I want to do is turn it into an applet, where instead of System.out.println
's, it displays the text in a text box. Is there a relatively easy way to convert this?
Upvotes: 0
Views: 3539
Reputation: 170158
Is there a relatively easy way to convert this?
Sure, all you need to do is create an applet1 and add a single JTextArea2 to it. And then instead of your System.out.println(str)
's, you do textArea.setText(str)
(or textArea.setText(textArea.getText() + "\n" + str)
to append text)
And to get user input, checkout the showInputDialog
method from the JOptionPane
class. Examples can be found here:
Upvotes: 0
Reputation: 324118
Message Console is a simple class that will allow you to redirect ouput to a JTextArea or JTextPane.
Upvotes: 2