LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-15-2004, 12:05 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
check it only once :Java


Hi. I want when i click the button the TextArea and appear as disabled or enabled...The problem is that the following code executes twice.... so everything still stays the same..

void mybuttonfunction(Button b,Event evt){
if ( (b.getLabel()=="Hide") ){
System.out.println(evt.id);
MyText.disable();
b.setLabel("Unhide");
}
if ( (b.getLabel()=="Unhide") & ( evt.id==1001) ){
System.out.println(evt.id);
MyText.enable();
b.setLabel("Hide");
//MyText.setText(DateFormat.getDateInstance().format(MyDate));
MyText.setText(DateFormat.getDateInstance().format(MyDate));
repaint();
}

}
 
Old 06-15-2004, 05:25 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
When you click on a button, two events (buttonPress and buttonRelease) are processed, thus the double execution.

Usually only the release event should trigger an action.
 
Old 06-23-2004, 06:33 PM   #3
german
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Debian etch, Gentoo
Posts: 312

Rep: Reputation: 30
implement ActionListener somewhere and do myButton.addActionListener(somewhere); then add the same code you have above to the ActionPerformed(ActionEvent evt) method of somewhere.

HTH

B.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Partition check, check double check Vincentius Linux - General 0 12-25-2004 05:47 AM
Media Check= FAIL - MDSUMs Check out tgrier Linux - Newbie 6 11-26-2004 10:07 PM
ATI's drivers -- How do I check... (check.sh) onthos Linux - Hardware 3 08-20-2004 05:05 PM
Java: check if a Casplock is enabled elluva Programming 2 04-26-2004 02:10 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 02:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration