Results 1 to 12 of 12
  1. #1
    arubin is offline Member
    Join Date
    Jul 2007
    Posts
    5
    Rep Power
    0

    Default JTable Gridline in selected row

    I am trying to set up a JTable so that it looks like a JList so that I can use different colours in cells and have everything nicely arranged in columns.

    I do not want any grid lines showing so I have table.setShowGrid(false);

    My problem is that when I select a row I want it highlighted but I get a white vertical gridline showing in the selected line. Please help me get rid of this line. I want a solid block of background colour across the row.

    The code which handles the highlighting is an implemenation of TableCellRenderer in

    public Component getTableCellRendererComponent(
    .............................
    if(isSelected){
    setBackground(Color.getHSBColor(0.6F,0.2F,0.9F));
    }else {
    setBackground(Color.white);
    }
    Last edited by arubin; 07-11-2007 at 09:20 AM.

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Can you attach a screenshot of the problem? It is difficult to understand your problem by just reading.

  3. #3
    arubin is offline Member
    Join Date
    Jul 2007
    Posts
    5
    Rep Power
    0

    Default

    I want to get rid of the vertical white line in the highlighted blue line. I want solid colour right acrosss.

    TIA
    Attached Thumbnails Attached Thumbnails JTable Gridline in selected row-screen.jpg  

  4. #4
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Hi Arubin,

    If you want to have a customized rendered list, why don't you use a custom cell renderer for a list. Check the following resource for more information:

    How to Use Lists (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)

  5. #5
    arubin is offline Member
    Join Date
    Jul 2007
    Posts
    5
    Rep Power
    0

    Default

    There is nothing in that tutorial which indicates that what I want to do can be done. What I want works nicely in JTable. I just want to be rid of that irritating white line.

  6. #6
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    That is the result of having two columns. May be you can implement your own look and feel in this case :)

  7. #7
    arubin is offline Member
    Join Date
    Jul 2007
    Posts
    5
    Rep Power
    0

    Default

    In other words it cannot be done.

  8. #8
    arubin is offline Member
    Join Date
    Jul 2007
    Posts
    5
    Rep Power
    0

    Default

    So how do I go about achieving what I want which is a list with items neatly arranged underneath each other and using different colours.

    Actually I have managed to achieve this in a list using monospace fonts and I can control colours with html. But I do not really want to use monospace fonts. Is there another way of doing it?

  9. #9
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Why don't you use Custom Cell Renderer described here:

    How to Use Lists (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)

    As far as i see, if you implement ListCellRenderer, you can return whatever component you want (in different color, shape, type ...).

  10. #10
    iimasd is offline Member
    Join Date
    Nov 2007
    Posts
    10
    Rep Power
    0

    Default How can I add an ICON on a JDialog's Title-Bar?

    How can I add an ICON on a JDialog's Title-Bar??
    TIA.

  11. #11
    iimasd is offline Member
    Join Date
    Nov 2007
    Posts
    10
    Rep Power
    0

    Default

    sorry i posted the above question in the wrong place....

  12. #12
    geoji2000 is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Default

    Set column margin to zero so that the vertical grid lines do not appear even in the selected row.

    table.getColumnModel().setColumnMargin(0);

Similar Threads

  1. Replies: 0
    Last Post: 03-10-2008, 02:36 PM
  2. How to add in a new row in Jtable?
    By Ry4n in forum AWT / Swing
    Replies: 0
    Last Post: 01-18-2008, 12:26 PM
  3. Show Text Fields on combo Box selected value
    By smajidali26 in forum AWT / Swing
    Replies: 0
    Last Post: 11-29-2007, 09:28 AM
  4. Help with JTable
    By fernando in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:57 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
  •