Trouble with adjusting table font size within a template?

Using 7.9.23.

I have an application where I need to show the same table with the same functionality in 3+ different spots so I made a template that is just a power table, and the template parameters are mostly just fed into the Named Query parameters.

I realized though these tables are different sizes in these different areas and I needed the ability to adjust how they look from the parameters too so I added two more parameters rowHeight and fontSize, the power table rowHeight property bindes right to that, and I handle the font size parameter with a change script on the template like so -

if event.propertyName == 'fontSize':
	from java.awt import Font 
	table = event.source.getComponent('Power Table')
	table.font = Font('Dialog', 0, event.newValue)

But it seems like I don't really have control, the font size reverts. In the following gif I have the fontSize param bound to a numeric text label and you can see what happens, it's most obvious when I try to set it to 18 (think I forgot to hit enter on 14).

2023-08-31 09-23-16

I don't know that anything is wrong with my script, my hunch is that the template holder itself is doing some resizing here or something?

There is a configureCell script but I don't think it should be interefering its as follows -

	# This adds row background color based on severity
	data =
	if data.getValueAt(rowIndex, "Hot_Topic") == "New Topic":
		return {'background': 'FFCCCC'}
	elif data.getValueAt(rowIndex, "Hot_Topic") == "Milestone":
		return {'background': 'CCFFCC'}
	elif data.getValueAt(rowIndex, "Hot_Topic") == "Emerging Problem":
		return {'background': 'FFFFCC'}
		return {'background': 'white'}

If you disable this script, does the font size change? Alternately, you could try returning 'fontSize': yourCustomProperty in your configure cell.

1 Like

In 7.9 there is no fontSize but doing it all inside of configure cell with font seems to work as expected

	from java.awt import Font 
	font = Font('Dialog', 0, self.parent.fontSize)
	data =
	returnDict = {'font':font}
    # other attributes to follow

Appreciate the help.

Just disabling the configureCell and trying to do it from the parent template like I was originally doing it was still giving me the flip-flopping behavior for what it's worth. Not that I really care anymore that there is a working method.

Jeez, dude. Make a constant in a project library script. Or use .putClientProperty(). configureCell is called a million freaking times as Swing paints components.

Or a custom property running the toFont expression function. But yeah, something better than all those allocations :slight_smile:

Trying to get it to work first before making it pretty and put into a library. I don't think it is though further inspection.

@PGriffith seeing stuff like this now -

Seeing some weird behavior where if the Project Status column has a lot of text the whole row is much smaller in two of my template instances (one pictured above) but in my third instance it works fine lol

So now I'm kind of at a loss now why it looks so different. Obviously the size is different between these two instances but I don't know why only one is affected with making the font smaller on these particular rows vs the other instance not shrinking the text of the row.

Was just a typo. Final script that worked for me -

from java.awt import Font 
# This adds row background color based on severity (Hot_Topic):
	'personalized':Font('Dialog', 0, 18),
	'status':Font('Dialog', 0, 16),
	'addRemove':Font('Dialog', 0, 14)

	"Hot Topic":"FFCCCC",
	"Emerging Issue":"FFFFCC"

def configureCell(self, rowIndex):
	font = FONTS[self.parent.fontSize]
	data =
	returnDict = {'font':font}
	hotTopicValue = data.getValueAt(rowIndex, "Hot_Topic")
	returnDict['background'] = COLOR_MAPPINGS.get(hotTopicValue, 'white')
	return returnDict

then I called this in configure cell. Thanks!