import javax.swing.*;
import java.awt.*;
public class TestTriangle extends JFrame {
public TestTriangle() {
JTextArea textArea = new JTextArea();
textArea.setColumns(1);
textArea.setRows(10);
textArea.setLineWrap(false);
textArea.setWrapStyleWord(true);
add(textArea);
}
public static void main(String[] args) {
TestTriangle frame = new TestTriangle();
frame.setTitle("Number Triangle");
frame.setSize(200, 125);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
出力をループにしようとしています。今これを実行すると、空白のテキスト領域を持つフレームが表示されます。このような順序でテキスト領域を数字でいっぱいにする必要があります。
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
etc..
これに関する情報はどこにもありません。