473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

code for a dialogue box to exit

50
I am trying to do this thing. When someone presses the exit button, a new window will be displayed asking the user whether he is sure to exit also 2 buttons will be displayed. One displaying yes and a one displaying no. If yes pressed the application closes if not, the user will be returned to the application. Though, I dont have an idea what code i need to place under each ActionPerformed for the button Yes and No. Can please someone help me how to do this?

thanks very much
Dec 30 '07 #1
1 2585
BigDaddyLH
1,216 Expert 1GB
I am trying to do this thing. When someone presses the exit button, a new window will be displayed asking the user whether he is sure to exit also 2 buttons will be displayed. One displaying yes and a one displaying no. If yes pressed the application closes if not, the user will be returned to the application. Though, I dont have an idea what code i need to place under each ActionPerformed for the button Yes and No. Can please someone help me how to do this?

thanks very much
To display a "Are you sure you want to exit? yes/no" dialog, you can use JOptionPane. This is very simple -- one line of code.

JOptionPane Tutorial
JOptionPane API

To react when the user tries to close the main frame, use a WindowListener:

Window Listener Tutorial

In this case, be sure to set the default behaviour of the window to do nothing on close -- you will be manually coding it:

Expand|Select|Wrap|Line Numbers
  1. mainWindow.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
Dec 30 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Raymond H. | last post by:
Hello, I tried the line in vb but it open the dialogue box (I'd like not to open this box; I'd like save without viewing a dialogue box). WebBrowser1.ExecWB OLECMDID_SAVEAS,...
8
by: Chris Markle | last post by:
When JavaScript writes out a dialogue box (like when confirm() is called) the header or title of that dialogue box shows up as "JavaScript Application"... Can this title be changed so that maybe...
4
by: Gazza | last post by:
Hi, I want to make a web page that causes the user's browser to pop a dialogue box onto their screen with a message of whatever I want (such as 'Thanks for visiting this site!'). The box should...
2
by: kevinm3574 | last post by:
So, I'm doing the following in a php script so that I can fire a download dialogue AND redirect the page (after clicking submit in a form). I'm doing it this way because of the problem with...
5
by: Brett Porter | last post by:
Hi, A very large portion of my site uses forms authentication which seems to work reasonably well. However many of my authenticated pages display a basic authentication dialogue box prior to...
44
by: sasan3 | last post by:
Please read below for my collective response to recent posts on this topic. First a repeat of my suggestion: "Anytime you feel you are in a position to answer a question, but don't feel like...
5
by: Crumplezone | last post by:
I'm setting up a system in small museum where a number of web sites will be run locally on a PC with a touchscreen running (I assume) Windows & IE7. I need every page to have a timed redirect to...
12
by: Donn Ingle | last post by:
Hi, Okay, so I am in the mood to try this: Inform the user about what modules the app requires in a graphical dialogue that can vary depending on what the system already has installed. (It will...
9
by: Joe Fawcett | last post by:
Dear All Can anyone explain why on some machines, when I choose to add a new item to a web site in VS 2008, I get the traditional dialogue that shows the checkbox for choose a master page and on...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.