import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestFlowLayout extends JFrame { public TestFlowLayout(String [] nomsBoutons) { super("FlowLayout"); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.RIGHT)); for (int i = 0; i < nomsBoutons.length; i++) { JButton b = new JButton(nomsBoutons[i]); c.add(b); } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public static void main(String [] args) { String [] nomsBoutons = {"Heureux", "qui", "comme", "Ulysse", "a", "fait", "un", "beau", "voyage", "ou", "comme", "cestui-la", "a", "conquis", "la", "toison", "..."}; JFrame tfl = new TestFlowLayout(nomsBoutons); tfl.pack(); tfl.setVisible(true); } }