Power table button

I know this has been asked some times now, however can’t make it work properly.

I can successfully add buttons to the power table, it is just not performing very well. The power table flashes and is unresponsive. Have been following this to get startet, but as said without any luck.

Is anyone doing this with success?

Here’s the code snippet from the configureEditor extension functions (copied directly from the linked thread)

if colName == "String Column":
	from javax.swing import AbstractCellEditor, JButton
	from javax.swing.table import TableCellEditor
	def func(e):
		print "This works. My Test."			
	class MyCellEditor(AbstractCellEditor,TableCellEditor):
		def getTableCellEditorComponent(self,table,value,isSelected,row,column):
			return JButton("My Button",actionPerformed=func)
	return {'editor':MyCellEditor()}

and the configureCell

if colName == "String Column":
    from javax.swing import JButton
    return { 'renderer' : JButton("My Button") }

Tried moving the code to a script module to remove the imports from every call,
Also, tried creating a JButton object and return this instead of creating a new object every call.
Either attempt didn’t have any effect on performance.

Did you make sure that “String Column” is set as Editable in the Table Customizer?

In terms of performance - removing the imports from the potentially frequently run extension functions (especially configureCell) is going to give you huge gains. I would recommend importing your JButton as a cached property in the initialize function (self.setClientProperty("button", JButton("My Button") | return { 'renderer': self.getClientProperty("button")})

1 Like

I tried both, still the same.