Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pressing a button during main



Hi Dean,


Your problem might be very simple, or somewhat more complicated, depending on what else you have done in your code (or not) and what you would like to achieve. Primarily I mean: what exactly does your action do (GUI work, background calc...), from which thread do you want to "click" the button, when during the startup do you want to do that, etc.


1. If you just want to 'simulate' a button click, there is a handy method in AbstractButton class doClick(), where the GUI of the button reflects the "being clicked state". Would not try to call it from any thread other then the Event Dispatch Thread (if you are not familiar with it, check out tutorials on Sun's website).
2. If you want to run the same method as the mouse click, just call the method. If you are trying this and having problems, it might be that you are encountering some Swing threading issues.


Other situations (your wishes) might call for different solutions. We probably could help more if you defined your problem a bit more. In terms of the good old:

1. What do you do?
2. What do you think should happen?
3. What does actually happen?
4. Any clue why?
5. Any way you can stop it from happening?
etc...


Best regards, Flor

Hello all,

I've been having trouble getting a button to run during startup of the
application.  The current code is simply:


connectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { queue.connect(); } });

What would be the best way to add an OnLoad (?) to simulate clicking the
buton when launching the application.


Thanks,
Dean Shavit

_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Pressing a button during main (From: Dean Shavit <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.