11/3/2018 - 3:22 AM

Swing Episode 3: FlowLayout

For episode 3:

import javax.swing.*;
import java.awt.*;

public class Main {

    public static void main(String[] args) {

        JFrame frame = new JFrame("Episode 3");
        frame.setSize(400, 400);

        Container content = frame.getContentPane(); //default fills components in from left to right
        content.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); //manually sets the flow
        FlowLayout layout = new FlowLayout(); //flowlayout starts with filling in as much horizontal space as possible, then vertical. It's real goal is to have everything in one row, but it will make a row if it must.
        layout.setAlignment(FlowLayout.RIGHT); //Sets the side the components will be placed on, it's center by default.
        layout.setHgap(20); //Horizontal Gap
        layout.setVgap(20); //Vertical Gap

        content.setLayout(layout); //Sets the pane to use FlowLayout

        for (int i = 1;i < 20;i++){
            frame.add(new JButton("Button #" + i));

//        frame.pack();
        //episode 3 done lil boi(or gurl)