在Java中创建一个弹出框 [英] Creating a pop up box in Java

查看:575
本文介绍了在Java中创建一个弹出框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个弹出框,当我单击检查"按钮时,该弹出框将被激活.它的作用是询问用户是否确定他们所要求的内容.如果是,则执行请求.如果不是,则恢复到正常状态.

I want to create a pop up box that is activated when I click a "Check" button. What it does is ask the user if they are sure about what they requested. If yes, it does the request. If no, it goes back to it's normal state.

我知道我所说的内容有点含糊,但我想创建各种类型的弹出框.

I know what I said is a bit ambiguous but I want to create various types of pop up boxes.

所以我想知道是否有一个网站提供带有给出代码的通用弹出框?

So I was wondering is there a website that has generic pop up boxes with the code given?

我只需要一个简单的代码即可扩展.

I just need a simple code which I can expand on.

推荐答案

我认为

  • showConfirmDialog:询问确认 问题,例如是/否/取消.
  • showInputDialog:提示一些 输入.
  • showMessageDialog:告诉 用户关于已拥有的东西 发生了.
  • showOptionDialog:盛大 以上三者的统一.
    • showConfirmDialog: Asks a confirming question, like yes/no/cancel.
    • showInputDialog: Prompt for some input.
    • showMessageDialog: Tell the user about something that has happened.
    • showOptionDialog: The Grand Unification of the above three.

    一个像您要求的是-否弹出窗口的小例子是:

    A small example to get a Yes-No popup like you asked for would be:

    if (JOptionPane.showConfirmDialog(null, "Are you sure about your request?", "Request", 
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)
        == JOptionPane.YES_OPTION)
    {
     //Do the request
    }
    else
    {
     //Go back to normal
    }
    

    但是,仅当您使用 查看全文

    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆