Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Change Text for JButton rendered in a JTable  RSS feed

 
Shreyas Rane
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to change JButton text on mouse click, the JButton is rendered in a JTable.
JButton text gets changed for that JButton but it is not reflected in JTable..
Can any one tell where am i going wrong???


 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Can any one tell where am i going wrong???

to be honest with you, most people won't read more than a handful of lines (would you?)

if you have a problem, posting the code is great, but we have to be able to compile/run it,
to understand/see the problem.

these lines don't help.

import com.edex.MainApp.PageList;
import com.edex.controller.DefaultComboBoxController;
 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, these two imports aren't used anymore, but removing them still leaves 5 compiler errors.

Shreyas, please turn your code into an SSCCE.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your concept of a renderer is wrong. A renderer is used to display the data found in the TableModel.

So your renderer needs to set the text of the button based on the data in the TableModel. If you want to change the text that is displayed on the button then you need to update the TableModel to the new text value. Then you tell the table to repaint that cell and your renderer will automatically pick up the new text from the model.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!