swing 消息框 joptionpane

4.消息弹出窗口

[img]http://dl.iteye.com/upload/attachment/402670/dc9e98a1-9dfa-321f-ad45-1737f686991d.png[/img]
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class MessagePopUps {

public static void main(String[] a) {
JFrame parent = new JFrame();

JOptionPane.showMessageDialog(parent, "Printing complete");
// JOptionPane.showInternalMessageDialog(parent, "Printing complete");

}

}


5.确认弹出窗口

[img]http://dl.iteye.com/upload/attachment/402672/13a4065b-ebd8-3563-bf1b-2ca02e21494b.png[/img]
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class ConfirmPopUps {

public static void main(String[] a) {
JFrame frame = new JFrame();
int result = JOptionPane.showConfirmDialog(frame, "Continue printing?");
// JOptionPane.showInternalConfirmDialog(desktop, "Continue printing?");

System.out.println(JOptionPane.CANCEL_OPTION == result);
}

}


6.输入弹出窗口

[img]http://dl.iteye.com/upload/attachment/402674/7b8c8b48-e69b-3493-8894-065c0b367a02.png[/img]
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class InputPopUps {

public static void main(String[] a) {
JFrame frame = new JFrame();
Object result = JOptionPane.showInputDialog(frame, "Enter printer name:");

System.out.println(result);
}

}


更多敬请访问:
http://www.java2s.com/CN/Tutorial/Java/0240__Swing/0960__JOptionPane-Dialog.htm
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值