Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:39:14+00:00 2026-06-07T15:39:14+00:00

I had created a JOptionPane of type showInputDialog . When it opens it, it

  • 0

I had created a JOptionPane of type showInputDialog. When it opens it, it shows me two buttons: OK and Cancel. I would like to handle the action when I push on Cancel button, but I don’t know how to reach it. How can I get it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:39:15+00:00Added an answer on June 7, 2026 at 3:39 pm

    For example:

    int n = JOptionPane.showConfirmDialog(
                                frame, "Would you like green eggs and ham?",
                                "An Inane Question",
                                JOptionPane.YES_NO_OPTION);
    if (n == JOptionPane.YES_OPTION) {
    
    } else if (n == JOptionPane.NO_OPTION) {
    
    } else {
    
    }
    

    Alternatively with showOptionDialog:

    Object[] options = {"Yes, please", "No way!"};
    int n = JOptionPane.showOptionDialog(frame,
                    "Would you like green eggs and ham?",
                    "A Silly Question",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    options,
                    options[0]);
    if (n == JOptionPane.YES_OPTION) {
    
    } else if (n == JOptionPane.NO_OPTION) {
    
    } else {
    
    }
    

    See How to Make Dialogs for more details.

    EDIT: showInputDialog

    String response = JOptionPane.showInputDialog(owner, "Input:", "");
    if ((response != null) && (response.length() > 0)) {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i had created a class with two properties one of datetime datatype and other
I had created a webpage using asp.net mvc3 razor. I have two master pages
I had created an App Id and enabled Push notification service in clients's apple
I had created a Proxy Server (Fwd and Reverse) using Java sockets. which would
How can I play two or more audio file in Android? I had created
On the project I am currently working, I had created an action that generates
I had created one div window which is draggable,and created one child div (with
I had created the following view, SELECT currency_cd, SUM(comprate) AS salary, employee_code, (SELECT SUM(c.comprate)
I had created a Lib Project with a class inherits ServiceBase but when I
I had created one HTML page for my experiance. In this i had use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.