Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2009
    Posts
    88
    Rep Power
    0

    Default JTable Cell Merg

    How to merg two cell(i.e add two cells into single cell) check many code from codegure???

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Moving to Swing forum for better topic alignment.

  3. #3
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    5

    Default

    cells cannot be merged in JTable

    Here is how to make it look like cells are merged:
    Suppose cells [r,c] and [r,c+1] are to be merged.
    Install a cell renderer for the table.
    To render either of the two merged cells,
    render the contents to an offscreen buffer.
    Then copy the lefthalf of the buffer for [r,c]
    and the right half for [r+1,c].

    You would have to setIntercellSpacing(new Dimension(0,0))
    so there is no border between the two cells.
    Obviously this will impact the appearance of the entire table.

    The ugliness of this kluge suggests that you rethink the need to merge cells.
    Maybe you want a GridBagLayout.

  4. #4
    Join Date
    Oct 2009
    Posts
    88
    Rep Power
    0

    Default

    can u give the code for this plz... ZWeibieren

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by anilkumar_vist View Post
    can u give the code for this plz... ZWeibieren
    If you read his post carefully, I think he is telling your specifically not to do this. I have to say that your post is a bit short on important details that are necessary to give a good answer. So instead of asking for spoon-fed code, why not tell us exactly what you're trying to do here, and perhaps we can give you better alternatives?

    A useful link I think: How to ask smart questions

  6. #6
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    5

    Default

    Yes, I could give you the code for the kludge. But I'm a bit tied up at the moment.
    Besides, if you can't do offscreen buffers (create, draw on, crop) and cell renderers,
    it is not a good idea for you to venture into the inevitable morass.

  7. #7
    Join Date
    Oct 2009
    Posts
    88
    Rep Power
    0

    Default

    Sorry i think it is not good to implement stopping this thread thanks for help

  8. #8
    licensetool is offline Member
    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    Default row header in jtable

    Hi,

    I want to separate the rows in a jtable and give a heading to the set of rows. so i want to merge cells in a jtable. is there any way that i can achieve this.

  9. #9
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    5

    Default

    one way: Create a bunch of tables and place them next to each other on the screen.

Similar Threads

  1. Merg JTABLE CELL
    By anilkumar_vist in forum New To Java
    Replies: 1
    Last Post: 01-25-2010, 04:02 PM
  2. Jtable and cell coordinates
    By rattaman in forum AWT / Swing
    Replies: 2
    Last Post: 11-17-2009, 05:48 PM
  3. jtable cell renderer
    By ankitmcgill in forum New To Java
    Replies: 2
    Last Post: 05-22-2009, 01:08 AM
  4. jTable Cell editing
    By mahaling_m in forum AWT / Swing
    Replies: 0
    Last Post: 06-23-2008, 08:17 AM
  5. Jframe In Jtable cell
    By Clarion in forum AWT / Swing
    Replies: 4
    Last Post: 06-23-2008, 04:42 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
  •