@@ -0,0 +1,880 @@
+package jp.ac.aitech.maslab.ando.javasample;%0A%0Aimport java.awt.Color;%0Aimport java.awt.GridLayout;%0A%0Aimport javax.swing.JFrame;%0Aimport javax.swing.JLabel;%0Aimport javax.swing.border.LineBorder;%0A%0Apublic class SwingGridLayoutSample %7B%0A%0A%09public static final int ROWS = 5;// %E8%A1%8C%E6%95%B0%0A%09public static final int COLS = 5;// %E5%88%97%E6%95%B0%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09JFrame jFrame = new JFrame(%22GridLayoutSample%22);%0A%09%09jFrame.setSize(400, 400);%0A%09%09jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A%0A%09%09// GridLayout%E3%82%92%E8%A8%AD%E5%AE%9A%0A%09%09jFrame.setLayout(new GridLayout(ROWS, COLS));%0A%0A%09%09// %E3%82%B3%E3%83%B3%E3%83%9D%E3%83%BC%E3%83%8D%E3%83%B3%E3%83%88%E3%81%AE%E8%A8%AD%E5%AE%9A%0A%09%09for (int col = 0; col %3C COLS; col++) %7B%0A%09%09%09for (int row = 0; row %3C ROWS; row++) %7B%0A%09%09%09%09String coord = String.format(%22(%25d, %25d)%22, row, col);%0A%09%09%09%09JLabel label = new JLabel(coord, JLabel.CENTER);%0A%09%09%09%09label.setBorder(new LineBorder(Color.BLACK));%0A%09%09%09%09jFrame.add(label);%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09jFrame.setVisible(true);%0A%09%7D%0A%0A%7D%0A

Add Source