Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-20-2007, 06:43 PM
Member
 
Join Date: Nov 2007
Posts: 6
SteM is on a distinguished road
Color of the focued row in a JTable
Hi all,
i'm configuring a JTable to have a controlled set of colours.
I'm able to control all the aspect but the color of the row with the focus.
Example: the row that receive the focus via mouse click ....
I always have a dark blue as color, i need a light blue !!

I'm also testing a TableCellRenderer, but again i'm not able to control that color !!

Thanks,
regards
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-20-2007, 08:29 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,266
hardwired is on a distinguished road
I'm also testing a TableCellRenderer, but again i'm not able to control that color
The logic can be a little tricky to get right. Look in the DefaultTableCellRenderer class source code - in the src folder in your sdk distribution. You can get an idea of how to implement the focus part in your cellRenderer.
Added:
The other alternative is to set the UI default color which will affect all JTabels in your app. Make sure you set this before creating any tables.
Code:
import javax.swing.plaf.ColorUIResource; ... Color lightBlue = yourColor... ColorUIResource colorResource = new ColorUIResource(lightBlue); UIManager.put("Table.focusCellBackground", colorResource);

Last edited by hardwired : 11-20-2007 at 08:38 PM. Reason: added suggestion
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-20-2007, 08:55 PM
Member
 
Join Date: Nov 2007
Posts: 6
SteM is on a distinguished road
Solved !!

In the paint() function i get the background color that is yet modified by the basic mechanism!!
I solved passing the background colours on the renderer constructor and used them instead of the returned by JTable.getBackground() or getSelectedBackground() functions ....


Last edited by SteM : 11-21-2007 at 11:52 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the color in my program carl New To Java 4 09-19-2008 03:38 PM
Help with switch color Daniel AWT / Swing 2 09-18-2008 09:54 AM
How to change color of JTable row having a particular value johnt AWT / Swing 3 09-18-2008 09:28 AM
Color objects CyberFrog New To Java 4 04-01-2008 02:41 AM
A bit of color! tim Java 2D 8 02-12-2008 01:57 AM


All times are GMT +3. The time now is 02:26 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org