import java.awt.*; import javax.swing.*; public class Ex5_2 extends JPanel { public void paintComponent(Graphics g) { int[] x = {50, 150, 65, 100, 135}; // 配列の宣言(その1)と中身の代入 int[] y = {50, 50, 120, 20, 120}; int pt = 5; g.drawPolygon(x, y, pt); int[] s = new int[6]; // 配列の宣言(その2) int[] t = new int[6]; s[0] = 100; s[1] = 150; s[2] = 150; s[3] = 200; s[4] = 200; s[5] = 250; for (int i=0; i<6; i++) { t[i] = 200 + 20*i; } g.drawPolygon(s, t, 6); } public static void main(String[] args) { JFrame app = new JFrame(); app.add(new Ex5_2()); app.setSize(500, 400); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); app.setVisible(true); } }