Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame("JFrame");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JTextField nameTextField = new JTextField();
        JLabel nameLabel = new JLabel("Name:");
        nameLabel.setDisplayedMnemonic('N');
        nameLabel.setLabelFor(nameTextField);

        frame.add(nameLabel, BorderLayout.WEST);
        frame.add(nameTextField, BorderLayout.CENTER);

        frame.pack();
        frame.setVisible(true);
    }
}