Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPasswordField;

public class Main extends JFrame {
    JPasswordField field = new JPasswordField("*", 10);

    public Main() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        field.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("Field=" + field.getText());
            }
        });

        getContentPane().add(field);
        pack();
        setVisible(true);
    }

    public static void main(String arg[]) {
        new Main();
    }
}