Problem with JButtons in JTable

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Problem with JButtons in JTable

  1. #1
    Join Date
    Feb 2005

    Question Problem with JButtons in JTable


    I using a JTable that has a column with JButtons. I was able to render the buttons and even fire the button's action by using a custom table cell editor.

    The problem is :

    I first click a button, say in row 1 and then click a button in another row, say row 2. When I click the second button, the button in row 1 is displayed in a pressed state. That is, the previously clicked button is rendered in a pressed state, untill the table is refreshed completely (say by adjusting the column size).

    I tried to confirm if the renderer on row1 is invoked or not. And the renderer on row1 IS invoked but still it is rendered as a toggle button in pressed state (But the buttons i add and render are just JButton and not JToggle button).

    The button is correctly rendered only when the table is fully repainted.

    Hope I am clear with my statements.

    Any solution on this problem would be appreciated.

    Thanks in advance,

  2. #2
    Join Date
    Dec 2004
    A renderer only 'lends' its drawing capabilities to the component
    (table/list) that is using it. What you see is really just a
    cardboard representation of the rendered component. E.g. when
    you use a JTexArea as base for your renderer you will see the
    scrollbars, but you cannot use them. The only components I
    have been able to use as (well behaved)renderers are lables,
    panels and comboboxes.
    I am not sure why a label column is able to keep
    its elements' individual coloring and a button apparently doesn't.
    Java Wreck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center