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 an algorithm has an upper limit to the number of instructions, regardless of the size of n, it is referred to as a(n) ______________ algorithm.
A. limited B. time complex C. constant time D. instruction-truncated
________ traffic can adjust, over wide ranges, to changes in delay and throughput across an internet and still meet the needs of its applications. A) Cloud
A) Cloud B) Elastic C) Real-time D) Inelastic
Box-shadow offers two optional attributes not found in text-shadow, the inset keyword attribute and the _______ attribute.
a. Color value b. X-offset c. Y-offset d. Blur-radius e. Spread
All of the following statements are TRUE regarding slicers EXCEPT:
A) Slicers were introduced in Excel 2007 as an interactive way to filter PivotTable data. B) In Excel 2013, slicers can now also be used to filter data in Excel tables, query tables, and other data tables. C) One of the benefits to using slicers is that they are easy to generate and use. D) Slicers indicate the current filter so you will know exactly what data you are viewing.