以下のコードを実行すると配列の最後のラベルが思っていない場所に表示されます。
なぜこうなるのでしょうか?
public class Test {
public static void main(String[] args) {
Frame f = new Frame();
}
}
public class Frame extends JFrame{
JLabel[] nl = new JLabel[5];
Frame(){ setSize(300,300); setLocationRelativeTo(null); setResizable(false); setVisible(true); for(int i = 0;i < 5;i++){ nl[i] = new JLabel(); add(nl[i]); nl[i].setBounds(10,20+30*i,85,20); nl[i].setText("aaaaa"); } }
環境 NetBeans IDE 7.3.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。