Source Code : Exercise Options
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Exercise Options
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(200, 200);
frame.setVisible(true);
JOptionPane.showMessageDialog(frame, "A");
JOptionPane.showMessageDialog(frame, "B", "message", JOptionPane.WARNING_MESSAGE);
int result = JOptionPane.showConfirmDialog(null, "Remove now?");
switch (result) {
case JOptionPane.YES_OPTION:
System.out.println("Yes");
break;
case JOptionPane.NO_OPTION:
System.out.println("No");
break;
case JOptionPane.CANCEL_OPTION:
System.out.println("Cancel");
break;
case JOptionPane.CLOSED_OPTION:
System.out.println("Closed");
break;
}
String name = JOptionPane.showInputDialog(null, "Please enter your name.");
System.out.println(name);
JTextField userField = new JTextField();
JPasswordField passField = new JPasswordField();
String message = "Please enter your user name and password.";
result = JOptionPane.showOptionDialog(frame, new Object[] { message, userField, passField },
"Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
if (result == JOptionPane.OK_OPTION)
System.out.println(userField.getText() + " " + new String(passField.getPassword()));
}
}
Thank with us