Default Color Scheme for G4P Controls
in
Contributed Library Questions
•
1 month ago
I sent Quarks a message about the default color scheme for GTextFields.
So for future reference, BLUE_SCHEME is the default. This can be set using the setLocalColorScheme() function for each control, or setGlobalColorScheme() after declaring the fields to set the color scheme for all the controls. The function getLocalColorScheme() can be used to retrieve the color scheme for each control.
The other schemes can be found at
http://www.lagers.org.uk/g4p/ref/interfaceg4p__controls_1_1_g_constants.html
And a brief example:
- GTextField textF;
- textF = new GTextField(this, 10, 10, 100, 25);
- textF.addEventHandler(this, "handleTextChangesToTextF");
- //Change scheme to red if the length of the text field is less than 5.
- public void handleTextChangesToTextF(GTextField textField, GEvent event)
- {
- if (event == GEvent.CHANGED)
- {
- if (textField.getText().length() < 5)
- {
- //Set text field to red scheme
- textField.setLocalColorScheme(RED_SCHEME);
- }
- else
- {
- //Return text field to the default scheme
- textField.setLocalColorScheme(BLUE_SCHEME);
- }
- }
- }
1