Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transparent color for the panel !

 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have my panel as a rectangle with some data on it. When I point my mouse over that, I should get the color of that panel changed (say a light green color). But, still I need the data present on it visible. How could I achieve this ?

Thanks in advance,
Narendranath
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on what you're doing. If the data is simple text you can put it on a JLabel and add the JLabel to the JPanel. Add a MouseListener to the JLabel and change the background color of the JPanel in the mouseEntered and mouseExited methods.
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,

Craig saying the right thing. you can use mouseEntered and [I]mouseExited[/I} methods.

in mouseEntered method write -- myPanel.setBackground(Color.green); // requried color

in mouseExited method write -- myPanel.setBackground(UIManager.getColor("Panel.background"));
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u guys.

Regards,
Narendranath
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic