Can you add a color picker component for vision.
Hate to resurrect this, but this is a great idea and would be really helpful.
Was not aware of this, thank you!
I prefer system.gui.chooseColor() as recommended in post 3, but while working on a different problem, I developed a way to manipulate the cell renderer of the dropdown and subsequently began exploring alternate uses for the script. Here is an alternative approach that converts a dropdown component to a color picker:
• Replace the dropdown's string datatype Label column with a color datatype label column:
• Then, use the following script on the dropdown's propertyChange event handler:
if event.propertyName == "componentRunning":
from javax.swing import DefaultListCellRenderer
from java.awt import Color
class ColorCellRenderer(DefaultListCellRenderer):
def getListCellRendererComponent(self, list, value, index, isSelected, cellHasFocus):
component = DefaultListCellRenderer.getListCellRendererComponent(self, list, value, index, isSelected, cellHasFocus)
if index != -1:
color = event.source.data.getValueAt(index, 1)
component.background = color
component.foreground = color
elif event.source.selectedValue is not None:
selectedValue = event.source.selectedValue
color = event.source.data.getValueAt(selectedValue, 1)
component.background = color
component.foreground = color
else:
component.background = event.source.background
component.foreground = event.source.background
return component
renderer = ColorCellRenderer()
event.source.setRenderer(renderer)
Here is the result:
Note: for this script to run in the designer, preview mode must be on when the window is opened
I imagine that this could be useful if there is a need to limit the color choices