aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to highlight(change color) of the button and its neighbours  when it is clicked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to highlight(change color) of the button and its neighbours  when it is clicked" Watch "how to highlight(change color) of the button and its neighbours  when it is clicked" New topic
Author

how to highlight(change color) of the button and its neighbours when it is clicked

Ravi Gupta
Ranch Hand

Joined: Jul 15, 2006
Posts: 38
Can anyone see the code shown below and help me with the following requirements. i want to add these requirements to my code.

1. when the center button is clicked then all the five buttons and the lines connecting them should get highlighted as they are getting highlighted when any of the line gets clicked.

2. when any of the four buttons(leaving the center button)is clicked then that button and the center button with which it is connected through a line gets highlighted(just the three of them).

if this cannot be done in the existing program then please make a new one.



help your PC help you best
http://simplepccare.spaces.live.com
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2364
    
  50
This is not a very OO attempt at a solution. If I was you I'd create a button class that has knowledge of its highlighted state and knows how to draw itself when unhighlighted and highlighted. The same goes for the connecting lines, there should be a ConnectingLine class that has knowledge of the state it is in and can draw itself in both states, it will also need to generate ActionEvents when clicked. Then you need some actionListeners to respond to the mouse clicks and change the buttons/lines to the appropriate states or possibly a connection manager that knows which lines connect to which buttons and handles the highlighting logic for the line and button clicks
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
 
wood burning stoves
 
subject: how to highlight(change color) of the button and its neighbours when it is clicked