package javacodebook.gui.layouts; import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * In diesem Frame wird das Layout des Frames auf FlowLayout gesetzt. * Das Frame wird mit ein paar Buttons belegt, um die Funktionsweise * zu verdeutlichen. */ public class FlowFrame extends Frame { private Button one = new Button("eins"); private Button two = new Button("zwei"); private Button three = new Button("drei"); private Button four = new Button("vier"); private Button five = new Button("fünf"); /** * Konstruktor von FlowFrame. */ public FlowFrame(String title) { super(title); // Eine Instanz von dem Layout wird benötigt FlowLayout flowLayout= new FlowLayout(); // Über setAlignment kann die Ausrichtung der Komponenten gesetzt werden flowLayout.setAlignment(FlowLayout.LEFT); // Hier wird das Layout der Contentpane auf FlowLayout gesetzt. this.setLayout(flowLayout); this.add(one); this.add(two); this.add(three); this.add(four); this.add(five); } }