Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

    Smile May I know how to add colors for specific cell in the JTable?

    May I know how to add colors for specific cell in the JTable?
    Java Code:
    while(rs.next())
    			{
    				for(int i = 1; i <=n; i++)
    				{
    					data[i-1] = rs.getString(i);
    
    
    				}
    
    				d.addRow(data);
    
    			}
    add(new JScrollPane(jtable));
    setVisible(true);
    Thanking You,
    With Regards,
    Nandhini.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    2,859
    Rep Power
    6

    Default Re: May I know how to add colors for specific cell in the JTable?

    I'm not really sure what the code is supposed to be demonstrating, but what you're looking for is a cell renderer. The basic tutorial covers them.

    How to Use Tables (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,936
    Rep Power
    16

    Default Re: May I know how to add colors for specific cell in the JTable?

    Moved here from 'New to Java'

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

  4. #4
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

    Default Re: May I know how to add colors for specific cell in the JTable?

    The tutorial is very useful to me.
    Thank You

Similar Threads

  1. Replies: 1
    Last Post: 10-18-2010, 06:48 AM
  2. Make specific cell a hyperlink (triggers event)
    By javanewbie in forum AWT / Swing
    Replies: 3
    Last Post: 06-21-2009, 03:26 AM
  3. Colour Specific Cell within Table
    By poddy88 in forum New To Java
    Replies: 2
    Last Post: 04-14-2009, 08:20 AM
  4. add a check box to only one cell in a JTable
    By aruna1 in forum New To Java
    Replies: 4
    Last Post: 04-03-2009, 06:28 PM
  5. Select specific cell
    By Echilon in forum New To Java
    Replies: 1
    Last Post: 01-01-2008, 07:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •