aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Transparent color for the panel ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Transparent color for the panel !" Watch "Transparent color for the panel !" New topic
Author

Transparent color for the panel !

Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

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


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
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

Joined: Dec 17, 2004
Posts: 68
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

Joined: Feb 03, 2004
Posts: 576

Thank u guys.

Regards,
Narendranath
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transparent color for the panel !
 
Similar Threads
Getting the background color of an ImageIcon
component colors
EventHandling on pi-chart
Color
Inheriting the color of parent