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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-15-2004, 12:05 AM
|
#1
|
Senior Member
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203
Rep:
|
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();
}
}
|
|
|
06-15-2004, 05:25 AM
|
#2
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
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.
|
|
|
06-23-2004, 06:33 PM
|
#3
|
Member
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Debian etch, Gentoo
Posts: 312
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 02:55 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|