08/03/03 22:37:01
質問です。
import java.awt.*;
import javax.swing.*;
public class GUI extends JFrame {
public static void main(String[] args){new GUI();}
public GUI(){
Container c = getContentPane();
c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
c.add(new MyForm("オラオラオラ", "オラ"));
c.add(new MyForm("無駄無駄無駄", "無駄"));
JButton b = new JButton("そして時は動き出す");
b.setAlignmentX(JButton.RIGHT_ALIGNMENT);
c.add(b);
pack();
setVisible(true);
}
class MyForm extends JPanel{
public MyForm(String label, String value){
setLayout(new FlowLayout(FlowLayout.RIGHT));
add(new JLabel(label));
JTextField tf = new JTextField(10);
tf.setText(value);
add(tf);
}
}
}
最後のボタンを右詰にしたいんですけど、右詰にならないのは何故でしょう。