Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Main extends JPanel {

    public Main() {
        JLabel lblMarried = new JLabel("Are you married?", JLabel.LEFT);
        JLabel lblGolf = new JLabel("Do you play golf?", JLabel.RIGHT);

        add(lblMarried);
        add(lblGolf);
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().add(new Main());

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(200, 200);
        frame.setVisible(true);
    }
}