473,416 Members | 1,637 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,416 software developers and data experts.

how to implement confirm box using java.awt

hi,
i am new to java.Can annybody tell me how to implement confirm box using java.awt package.
i tried by extending dialog class with 2 buttons (buttonSave and buttonDiscard) on dialog box but as ActionEventListener has void return type i could not implement it.
Can anybody tell me any other method.

thanks in advance
Apr 15 '07 #1
2 2554
JosAH
11,448 Expert 8TB
hi,
i am new to java.Can annybody tell me how to implement confirm box using java.awt package.
i tried by extending dialog class with 2 buttons (buttonSave and buttonDiscard) on dialog box but as ActionEventListener has void return type i could not implement it.
Can anybody tell me any other method.

thanks in advance
Your ActionListeners could set a boolean member variable to false or true,
depending on which button was clicked. Add a nice convenience method to
your class (which extends the Dialog class) that basically does just this:
Expand|Select|Wrap|Line Numbers
  1. private boolean confirmed= false; // set by the ActionListeners
  2. ...
  3. public boolean isConfirmed() {
  4.    this.setVisible(true); // this thread will be suspended by the modal dialog.
  5.    return confirmed;
  6. }
In your calling code you just have to do this:
Expand|Select|Wrap|Line Numbers
  1. if ((new YourDialog(...)).isConfirmed())
  2.    // user pressed the confirm/ok/save whatever button
Your constructor initializes the entire YourDialog object but doesn't set it
visible yet; that's the task of the isConfirmed() method.

kind regards,

Jos
Apr 15 '07 #2
thanks friend.
it solved the problem. The solution is really good.
Apr 15 '07 #3

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

Similar topics

14
by: Medi Montaseri | last post by:
Hi, I think my problem is indeed "how to implement something like java's final in C++" The long version.... I have an abstract base class which is inherited by several concrete classes. I...
6
by: Philipp Holzschneider | last post by:
Are there any available c++ compilers around that strictly implement the mentioned "Exception Specification" feature?? where the following compiles void func() { throw A(); }; void gunc()...
2
by: sonu | last post by:
how to implement the alert box and confirm box in asp.net web application through c# any help please Sonu
1
by: Sandy | last post by:
I have a repeater which shows Group names. (Skip this part if you want rather irrelevant) The groups are ordered and formatted: Parent ---Child ------Grand Child (okay start reading again...
4
by: DrData | last post by:
I'm working on an ASP.Net application written in C#. On one page, there are several datagrid controls used to display, edit and delete detail records relating to the master record also displayed on...
8
by: rn5a | last post by:
I have gone through a no. of posts in this NewsGroup regarding my problem but alas, couldn't come across one which would have helped me in resolving the issue. My problem is this: An ASPX Form...
5
by: balakrishnan.dinesh | last post by:
hi Frnds, I need Confirm box with "yes" or "no" buttons, Is that possible in JAVASCRIPT , Can anyone tell me the solution for this or anyother way to create confirm box with "yes" or "no" button?...
6
by: sreekandan | last post by:
Hi everyone.... Now im going to implement FTP by using java program..But i dont know how to implement that...So kindly send me the java code to implement FTP program.And also I need help that "how...
3
by: ghjk | last post by:
I have a web page which is used to enter user data. In there I have 4 buttons named as "Submit, Confirm,Edit,Cancel". User should enter data and click "Submit " button. Then I want to display all...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.