0% found this document useful (0 votes)
18 views

Code GUI

The document contains Java code that uses JOptionPane to prompt the user for input of their name, age, email, password, and number. It then displays messages to confirm the information and asks if the user would like to enter or log in. Based on the user's responses, it prints either "Selected Yes!", "Selected No!", or "Window closed without selecting!".

Uploaded by

D Y N A S Y
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Code GUI

The document contains Java code that uses JOptionPane to prompt the user for input of their name, age, email, password, and number. It then displays messages to confirm the information and asks if the user would like to enter or log in. Based on the user's responses, it prints either "Selected Yes!", "Selected No!", or "Window closed without selecting!".

Uploaded by

D Y N A S Y
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import javax.swing.

JOptionPane;
import javax.swing.JFrame;

public class main {

public static void main(String[] args) {

String name = JOptionPane.showInputDialog("Enter your name");


JOptionPane.showMessageDialog(null, "Hello "+name);

int age = Integer.parseInt(JOptionPane.showInputDialog("Enter your


age"));

int hey = JOptionPane.showOptionDialog(new JFrame(), "Are you really


"+age+" years old?","Window",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
new Object[] { "Yes", "No" }, JOptionPane.YES_OPTION);
if (hey == JOptionPane.YES_OPTION) {
System.out.println("Selected Yes!");
} else if (hey == JOptionPane.NO_OPTION) {
System.out.println("Selected No!");
} else if (hey == JOptionPane.CLOSED_OPTION) {
System.out.println("Window closed without selecting!");
}

String email = JOptionPane.showInputDialog("Enter your email:");

String pass = JOptionPane.showInputDialog("Enter your password:");


JOptionPane.showMessageDialog(null, "Logging as: "+email);

int number = Integer.parseInt(JOptionPane.showInputDialog("Enter your


number:"));
JOptionPane.showMessageDialog(null,""+number);

int you = JOptionPane.showOptionDialog(new JFrame(), "Is that


correct??","Window",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
new Object[] { "Yes", "No" }, JOptionPane.YES_OPTION);
if (you == JOptionPane.YES_OPTION) {
System.out.println("Selected Yes!");
} else if (you == JOptionPane.NO_OPTION) {
System.out.println("Selected No!");
} else if (you == JOptionPane.CLOSED_OPTION) {
System.out.println("Window closed without selecting!");
}

int res = JOptionPane.showOptionDialog(new JFrame(), "Do you like to


Enter?","Window",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
new Object[] { "Yes", "No" }, JOptionPane.YES_OPTION);
if (res == JOptionPane.YES_OPTION) {
System.out.println("Selected Yes!");
} else if (res == JOptionPane.NO_OPTION) {
System.out.println("Selected No!");
} else if (res == JOptionPane.CLOSED_OPTION) {
System.out.println("Window closed without selecting!");
}
JOptionPane.showMessageDialog(null, "Successfully Logged In ");

You might also like