Java 对话框

 1 import javax.swing.JFrame;
 2 import javax.swing.JOptionPane;
 3 
 4 public class li {
 5 
 6     public static void main(String[] args) {
 7         
 8         
 9         JFrame frame = new JFrame("窗体");
10         //显示一个对话框
11         frame.setBounds(300, 300, 300, 400);
12         //消息对话框
13         JOptionPane.showMessageDialog(frame, "明天不用上课", "通知",JOptionPane.INFORMATION_MESSAGE);
14         //警告对话框
15         JOptionPane.showMessageDialog(frame,"警告某位同学","警告",JOptionPane.WARNING_MESSAGE);
16         //错误对话框
17         JOptionPane.showMessageDialog(frame,"扣6分","错误",JOptionPane.ERROR_MESSAGE);
18         
19         //输入框
20         String moeny = JOptionPane.showInputDialog("请输入你要给我的金额($)");
21         System.out.println("money:"+ moeny);
22         
23         //确认框
24         int num = JOptionPane.showConfirmDialog(frame, "你确认要卸载吗?");
25         System.out.println(num);
26     }
27     
28 }

 

你可能感兴趣的:(Java 对话框)