Wednesday, 15 June 2011

java - Pascal Triangle in Gui -


Hello Can you help me print a Pascal triangle in jettextare? The output is printing in normal output. This is my creator

  public static Intel Compute Pascal {for (int i = 0; i & lt; rows; i ++) {int number = 1; System.out.format ("%" + (Rows-A) * 2 + "S", ""); {System.out.format ("% 4d", number) for (int j = 0; j & lt; = i; j ++); Number = number * (I - J) / (J + 1); } System.out.println (); } Return rows; }  

This is my ActionListener

  if (e.getSource () == B2) {String D = F 1.getText (); Int dev = integer. ParisInt (D); Int hard = ComputePascal (dev); String ans = String.valueOf (hard); Area.setText (ANS);  

I do not have experience in Java, so correct me if I am wrong, but I suggest making a JTextArea and then pass the line printed to that system. On this JTextArea

  JTextArea textArea = new JTextArea (); // Add your code here // instead of System.out with its own output in TextArea.Append ("Pascal Triangle:" + number)  

No comments:

Post a Comment