Any way to replicate "Other Border" on components like the Dropdown List?

I was hoping for a way to manually set the border property on certain components, like the Drowdown List, through expression or the Border chooser on the border property.

Some components have a preset property that says “Other Border”. I would like to do a conditional expression to set a red line around the border with the same look it has, else keep it the way it is by default. I tried selecting many combinations of options, but couldn’t replicate the default.

Otherwise, some workarounds are to put a rectangle of the same size of the component, set the fill opacity to zero or possibly get into the java swing code, but unable to find good resources or examples.

Not a complete working example, but toggling between the two states could be done with something like this:

from javax.swing import BorderFactory
from javax.swing.border import CompoundBorder

target = event.source.parent.getComponent("Dropdown")
# Add an outer red line border
target.border = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(system.gui.color(255, 0, 0), 3), target.border)

# Reset to the original border
if isinstance(target.border, CompoundBorder):
	target.border = target.border.insideBorder

Thank you. This does what I need through script. For anyone else, as written above on a button or some action event, it will cancel each other out so it does nothing, but the first "target.border =" could be in an if statement or separate action event/component.

Further more, to make this work in bindings, one could create a hidden component of each type (default, and one with border changed), then bind your working component's borders to these.

1 Like