### Standardcolor Inputlist

Example class to select a Standardcolor using the InputList dialog as from B4J v4.00.
Class ColorChooser
`Private Sub Class_Globals
Private fx As JFX
Private StandardColorsMap As Map
Private ColorItems As List = Array("Black","Blue","Cyan","DarkGray","Gray","Green","LightGray","Magenta","Red","Transparent","White","Yellow")
End Sub`
'Initializes the object.
`Public Sub Initialize
'No action
End Sub`
'Select a standard color
'Returns Color selected as string
'Example: Blue
`Public Sub SelectStandardColor(Owner As Form, Message As String, Title As String, DefaultItem As Int) As String
Dim Result As String = ""
Dim rt As Int = fx.InputList(Null, ColorItems, Message, Title, DefaultItem)
If rt <> fx.DialogResponse.CANCEL Then
Result = ColorItems.Get(rt)
End If
Return Result
End Sub`
'Select a standard color
'Returns Color selected as Paint value
'Example: fx.Colors.Blue
`Public Sub SelectStandardColor2(Owner As Form, Message As String, Title As String, DefaultItem As Int) As Paint
Dim Result As Paint
Dim rt As Int = fx.InputList(Null, ColorItems, Message, Title, DefaultItem)
If rt <> fx.DialogResponse.CANCEL Then
FillStandardColorsMap
Result = StandardColorsMap.Get(ColorItems.Get(rt))
End If
Return Result
End Sub`
`Private Sub FillStandardColorsMap
StandardColorsMap.Initialize
StandardColorsMap.Put("Black", fx.Colors.Black)
StandardColorsMap.Put("Blue", fx.Colors.Blue)
StandardColorsMap.Put("Cyan", fx.Colors.Cyan)
StandardColorsMap.Put("DarkGray", fx.Colors.DarkGray)
StandardColorsMap.Put("Green", fx.Colors.Green)
StandardColorsMap.Put("LightGray", fx.Colors.LightGray)
StandardColorsMap.Put("Magenta", fx.Colors.Magenta)
StandardColorsMap.Put("Red", fx.Colors.Red)
StandardColorsMap.Put("Transparent", fx.Colors.Transparent)
StandardColorsMap.Put("Yellow", fx.Colors.Yellow)
StandardColorsMap.Put("White", fx.Colors.White)
End Sub`
Example Class Usage
`Sub ButtonSelectColor_Action
Dim cc As ColorChooser
cc.Initialize
Dim rt As String = cc.SelectStandardColor(Null, "Select a color from the list of standard colors", "ColorChooser", -1)
fx.Msgbox(Null, "Color selected: " & rt, "Result ColorChooser")
End Sub`
`Sub ButtonSelectColor2_Action
Dim cc As ColorChooser
cc.Initialize
Dim rt As Paint = cc.SelectStandardColor2(Null, "Select a color from the list of standard colors", "ColorChooser", -1)
fx.Msgbox(Null, "Color selected: " & rt, "Result ColorChooser")
End Sub`

Changed: , Category: Colors, File: T6C174M1264.htm, ID: 1264