GUI in Java | How to make userdefined login page in graphical user interface in java

 Login page in graphical user interface (GUI) in java

Code:

package javaapplication22;
import javax.swing.*;

public class JavaApplication22 {

    public static void main(String[] args) {
       
         JFrame frame = new JFrame("My First Swing Example");
      
        frame.setSize(350, 200);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel();   
        frame.add(panel);
        frame.setVisible(true);
    }
        JLabel userLabel = new JLabel("User");
        userLabel.setBounds(10,20,80,25);
        panel.add(userLabel);

        JTextField userText = new JTextField(20);
        userText.setBounds(100,20,165,25);
        panel.add(userText);

        JLabel passwordLabel = new JLabel("Password");
        passwordLabel.setBounds(10,50,80,25);
        panel.add(passwordLabel);

        JPasswordField passwordText = new JPasswordField(20);
        passwordText.setBounds(100,50,165,25);
        panel.add(passwordText);

        JButton loginButton = new JButton("login");
        loginButton.setBounds(10, 80, 80, 25);
        panel.add(loginButton);
    }

}

Output:

GUI IN java

 

 

Comments

Popular posts from this blog

Multiple Inheritence in Java /How to inherit a class from another in Java| Programmer Hub

Search an Element in Arraylist in java | Programming Hub