Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:1. All Swing components should be constructed on the EDT (also applies to chancing their internal state).
2. Learn to use Layouts and stop worrying about coordinates.
Returns the current x coordinate of the component's origin.
Ryan Sykes wrote:In any case, I've decided to refine my code and get rid of these methods and instance variables as they are unnecessary.
Paul Clapham wrote:
Ryan Sykes wrote:In any case, I've decided to refine my code and get rid of these methods and instance variables as they are unnecessary.
In fact, as far as I can see your action listener doesn't care much about which button was clicked. What I mean to say is, it doesn't care whether it's the button in row 1, column 3 or the button in row 2, column 2 -- it does the same regardless. So you don't need a separate action listener for each button, you can get away with a single action listener which you attach to all of the buttons.
Ryan Sykes wrote:That must still imply that the Swing code was calling getX() and getY() on the CNButton object and not a parent object, as the latter case would result in a call to the original JComponent getX() and getY() methods? Does that sound correct? (I'm just trying to make sure I have understood method overriding and inheritance correctly)
Ryan Sykes wrote:Hi Darryl. Thanks for your reply. Could you help me out a bit further by pointing out what I could do specifically to construct all my Swing components within the EDT?
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:
Ryan Sykes wrote:Hi Darryl. Thanks for your reply. Could you help me out a bit further by pointing out what I could do specifically to construct all my Swing components within the EDT?
You're welcome.
Search this forum for SwingUtilities.invokeLater and you'll find plenty of examples. To further your understanding, go through the tutorial on Concurrency in Swing.
Consider Paul's rocket mass heater. |