Error setting property / binding alignment on buttons

#1

I’m trying to bind Horizontal Alignment on a button to a template parameter, it’s an int… I’ve tried 0-5 and get

Error setting property to '1' for binding on
button.button.Button.horizontalAlignment
at com.inductiveautomation.factorypmi.application.binding.AbstractPropertyAdapter.updateTarget(AbstractPropertyAdapter.java:327)

Caused by: java.lang.IllegalArgumentException: horizontalAlignment
	at javax.swing.AbstractButton.checkHorizontalKey(Unknown Source)
	at javax.swing.AbstractButton.setHorizontalAlignment(Unknown Source)

What’s the trick?

0 Likes

#2

I guess I didn’t actually try 0-5… or had something goofed up when I did it. Even so, it’s kind of tricky.

To make this work, you have to use values of:

0 = Center
2 = Left
4 = Right
11 = Trailing

found here: https://docs.oracle.com/javase/8/docs/api/constant-values.html under ‘SwingConstants’

0 Likes