954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How can i swap two buttons by clicking on them

that is i've got an array of buttons and i want to replace two buttons (their location on the screen) by clicking on first and then clicking on the second to replace thier location i.e. when i click on button1 first (which is at the first location in a row of buttons on the screen) and then button5, then these two button should replace locations i.e. after clicking on button5 at the fifth location in a row of buttons button5 goes to the location of button1 and button1 goes to the location of button5.

Is there any way that i can do this without replacing their captions with each other as currently i can swap them by swapping thier captions.

jim1
Newbie Poster
2 posts since Apr 2004
Reputation Points: 10
Solved Threads: 0
 

If you are using breezy swing (not sure if it works on standard swing):

just use the setLocation() method with the appropraite button object.

ex

myButton.setLocation(1,1);

BountyX
Posting Whiz in Training
230 posts since Mar 2004
Reputation Points: 28
Solved Threads: 9
 

explain more ... what layout are you using ??

nanosani
Unauthenticated Liar
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

thanks for your reply but i have already sorted it out therefore i have unsbscribed from this thread.
many thanks

jim1
Newbie Poster
2 posts since Apr 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You