确认对话框(0是,1否,2取消):(1)在窗体类中:int result = JOptionPane.showConfirmDialog(this, "hello everyone!");
(2)在类之外:int result = JOptionPane.showConfirmDialog(new JFrame(), "hello everyone!");
或int result = JOptionPane.showConfirmDialog(null, "hello everyone!");(使用默认的Frame作为父窗口,此时对话框在屏幕正中)。
输入对话框:String input = JOptionPane.showInputDialog("hello, what is your name?");
消息显示框:JOptionPane.showMessageDialog(new JFrame(), "Hi everyone, my name is shudaye");
时间: 2024-10-12 20:51:39