回答内容
回答を評価する
(0ポイント)
|
補足 ソースが次の通り package 第4章; import java.awt.*; import javax.swing.*;
public class Sample8 extends JApplet { private JLabel[] lb = new JLabel[3]; private Icon ic;
public void init() { //コンポーネントの作成 for(int i=0; i<lb.length; i++){ lb[i] = new JLabel("This is a Car."); } ic = new ImageIcon(getImage(getDocumentBase(), "bin/第4章/car.gif"));
//コンポーネントの設定 lb[0].setIcon(ic); lb[1].setIcon(ic); lb[2].setIcon(ic);
lb[0].setFont(new Font("SansSerif", Font.BOLD, 12)); lb[1].setFont(new Font("Helvetica", Font.BOLD, 14)); lb[2].setFont(new Font("Century", Font.BOLD, 16));
//コンテナの設定 setLayout(new GridLayout(3, 1));
//コンテナへの追加 for(int i=0; i<lb.length; i++){ add(lb[i]); } } }
|