0

How can we display the output of function on JTextArea in java ?

i want to display on JTextArea please only on help public static void move(int n, int startPole, int endPole) { if (n== 0) { return; } int intermediatePole = 6 - startPole - endPole; move(n-1, startPole, intermediatePole); System.out.println("Move " +n + " from " + startPole + " to " +endPole); move(n-1, intermediatePole, endPole); }

22nd Nov 2017, 4:33 PM
Gohar Ejaz
Gohar Ejaz - avatar
6 Respuestas
+ 5
after tfa.setSize(70,100); add: tfa.setText("your text goes here"); or, in case it's not working, replace it with: tfa.append("your text goes here");
23rd Nov 2017, 6:18 AM
seamiki
seamiki - avatar
0
i can't understand
22nd Nov 2017, 7:40 PM
Gohar Ejaz
Gohar Ejaz - avatar
0
can wo please guide me
22nd Nov 2017, 7:41 PM
Gohar Ejaz
Gohar Ejaz - avatar
0
import java.awt.Button; import java.awt.Component; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Frame; import java.awt.GridLayout; import java.awt.Panel; import java.awt.TextArea; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; class Gui22 extends WindowAdapter implements ActionListener{ Frame f; Button b1; TextArea tfa; int n1; Panel p; Gui22(){ f=new Frame("tower of hanoi"); f.setLayout(new GridLayout(2,0)); f.setSize(300,300); f.show(); p =new Panel(); p.setLayout(new GridLayout(2,2)); sb=new StringBuilder(); b1=new Button("continu"); tfa=new TextArea(" "); tfa.setFont (new Font("Helvetica", Font.BOLD, 18)); tfa.setEditable (true); tfa.setSize(70,100 ); p.add(b1); f.add(tfa); f.addWindowListener(this); b1.addActionListener(this); } public void windowClosing(WindowEvent we){ System.exit(0); } private String s; @Override public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1){ move(3,1,3); } } void move(int n, int startPole, int endPole) { if (n== 0) { return; } int intermediatePole = 6 - startPole - endPole; move(n-1, startPole, intermediatePole); System.out.println("Move " +n + " from " + startPole + " to " +endPole+"\n"); move(n-1, intermediatePole, endPole); } } public class JavaApplication20 { public static void main(String[] args) { Gui22 gu=new Gui22(); } }
22nd Nov 2017, 9:35 PM
Gohar Ejaz
Gohar Ejaz - avatar
0
its my code bro can you set this out put to my TextArea
22nd Nov 2017, 9:35 PM
Gohar Ejaz
Gohar Ejaz - avatar