日期:2014-05-20  浏览次数:20865 次

swing怎么弹确认框
我要用swing弹一个确认框,比如我要删除一个东西,先得弹确认框提示我,如果我确认就执行删除方法,取消就不删除、、在线等、、谢谢

------解决方案--------------------
确认对话框:包括确定和取消或是和否两按钮;
showConfirmDialog(Component parentComponent, Object message) 调出带有选项 Yes、No 和 Cancel 的对话框;
showConfirmDialog(Component parentComponent, Object message, String title, int optionType) 
showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) 调用一个由 optionType 参数确定其中选项数的对话框,messageType 参数确定要显示的图标。


message 要显示的消息。

messageType 消息类型。

initialValue 应该在 options 中最初选择的值。icon 在窗格中使用的图标。options 要向用户显示的选项。

optionType 选项类型,DEFAULT_OPTION、YES_NO_OPTION、YES_NO_CANCEL_OPTION 或 OK_CANCEL_OPTION 之一。 

title 对话框的标题。 

parentComponent 定义作为此对话框的父对话框的 Component。通过两种方式使用此参数:包含它的 Frame 可以用作对话框的父 Frame,在对话框的位置使用其屏幕坐标。

网上找的,应该是这个,具体你得改点吧