如何在JAVA中实现弹出模式窗口JDialog

来源:百度知道 编辑:UC知道 时间:2024/04/28 05:38:54
就是写帮助——关于的弹出窗口,怎么加上去,具体一点。

package myclass;

import javax.swing.JOptionPane;
import java.awt.*;
public class MyDialog extends Frame {
public String showInputDialog(String value){
//显示一个要求用户键入 String 的对话框:
return JOptionPane.showInputDialog(value);
}
public void showMessageDialog(String title,String message){
//显示一个错误对话框,该对话框显示的 message 为 'alert':
JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
}
public boolean showOptionDialog(){
//示一个警告对话框,其 options 为 OK、CANCEL,title 为 'Warning',message 为 'Click OK to continue':
String[] options = { "OK", "CANCEL" };
int result=JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
if(result==0)
return true;
else
return false;