• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ravi Gupta
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Tony Docherty
Bartender
Posts: 2965
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic