📄 exerciseoptions.java
字号:
import javax.swing.*;
public class ExerciseOptions{
public static void main(String[] args){
JFrame frame=new JFrame("ExerciseOptions");
frame.setSize(200,200);
frame.setVisible(true);
JOptionPane.showMessageDialog(frame,"you have mail");
JOptionPane.showMessageDialog(frame,"You are low on memory.","Apocalyptic nessage",JOptionPane.WARNING_MESSAGE);
int result=JOptionPane.showConfirmDialog(null,"Do you want to remove Windows 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("Cencel"); break;
case JOptionPane.CLOSED_OPTION: System.out.println("Closed"); break;
}
String name=JOptionPane.showInputDialog(null, "Please enter yout 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()));
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -