Create a Java GUI that allows the user to enter a desired user name and password. Provide a button, when clicked, informs the user that their account was successfully created. Include labels as appropriate.
What will be an ideal response?
```
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class LoginGui extends JFrame implements ActionListener
{
public static final int WIDTH = 200;
public static final int HEIGHT = 100;
public static void main(String args[])
{
LoginGui gui = new LoginGui();
gui.setVisible(true);
}
public LoginGui()
{
super("Account Login");
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new GridLayout(3,2));
JLabel label1 = new JLabel("User Name:");
JLabel label2 = new JLabel("Password:");
JTextField userName = new JTextField(20);
JTextField password = new JTextField(20);
JButton login = new JButton("Login");
c.add(label1);
c.add(userName);
c.add(label2);
c.add(password);
c.add(login);
login.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Account successfully created!");
}
}
```
You might also like to view...
When multiple windows are open, you can minimize all but the active window by using ________
Fill in the blank(s) with correct word
A third party certification registry for software security is available under a scheme that is known as the ____.
A. Common Validation B. Common Criteria C. Common Certification D. Common Controls