javaSwing弹出框简单工具类集成

我们使用javaSwing的时候会经常使用到一些弹出框,下面我把一些常用的弹出框整理了一个工具类,拿来即用的。

/**
 * Date: 2020/5/20 17:07
 * Copyright (c) 2020,All Rights Reserved.
 */
package *****;

import javax.swing.*;
import java.awt.*;

/**
 * @Author: zhangjun
 * @Description:
 * @Date: Create in 17:07 2020/5/20 
 */
public class MessageDialog {
    /** Return value from class method if YES is chosen. */
    public static final int         YES_OPTION = JOptionPane.YES_OPTION;
    /** Return value from class method if NO is chosen. */
    public static final int         NO_OPTION = JOptionPane.NO_OPTION;
    /** Return value from class method if CANCEL is chosen. */
    public static final int         CANCEL_OPTION = JOptionPane.CANCEL_OPTION;
    /** Return value form class method if OK is chosen. */
    public static final int         OK_OPTION = JOptionPane.OK_OPTION;
    /** Return value from class method if user closes window without selecting
     * anything, more than likely this should be treated as either a
     * <code>CANCEL_OPTION</code> or <code>NO_OPTION</code>. */
    public static final int         CLOSED_OPTION = JOptionPane.CLOSED_OPTION;

    static {
    }
    private final static String title = "系统提示";
    public static void show_OK(Component parent, String message){
        JOptionPane.showMessageDialog(parent,message,title,JOptionPane.INFORMATION_MESSAGE);
    }
    public static int show_OK_CANCEL(Component parent, String message){
        return JOptionPane.showConfirmDialog(parent,message,title,JOptionPane.OK_CANCEL_OPTION);
    }
    public static int show_YES_NO_CANCEL(Component parent,String message){
        return JOptionPane.showConfirmDialog(parent,message,title,JOptionPane.YES_NO_OPTION);
    }
    public static int show_YES_NO(Component parent,String message){
        return JOptionPane.showConfirmDialog(parent,message,title,JOptionPane.YES_NO_OPTION);
    }
    public static void show_Error(Component parent,String message){
        JOptionPane.showMessageDialog(parent,message,title,JOptionPane.WARNING_MESSAGE );
    }
    public static void  show_WARNING(Component parent,String message){
        JOptionPane.showMessageDialog(parent,message,title,JOptionPane.ERROR_MESSAGE);

    }
    public static int show_Default(Component parent,String message){
        return JOptionPane.showConfirmDialog(parent,message,title,JOptionPane.DEFAULT_OPTION);
    }

    public static void main(String[] args) {
        MessageDialog.show_OK(null,"哈哈,超简单的啦");
    }
}

使用效果
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值