Class ColorChooserBox

  • All Implemented Interfaces:
    EventHandler, PenListener

    public class ColorChooserBox
    extends Window
    implements PenListener
    Shows a color dialog that can be used to select a color. There are several ways to choose a color:
    • Using a color matrix
    • Using a websafe palette
    • Writting the red, green and blue components
    • Writting the color in hexdecimal.
    Here's a sample code:
     ColorChooserBox ccb = new ColorChooserBox(getBackColor());
     ccb.popup();
     if (ccb.choosenColor != -1) // user pressed cancel?
     {
        int color = ccb.choosenColor; // no, color was selected
     }
     
    Since:
    TotalCross
    • Field Detail

      • choosenColor

        public int choosenColor
        The choosen color or -1 if the user cancelled.
    • Constructor Detail

      • ColorChooserBox

        public ColorChooserBox​(int defaultColor)
    • Method Detail

      • initUI

        public void initUI()
        Description copied from class: Container
        Called to initialize the User Interface of this container. This differs from the onAddAgain method by that this method is called only once, at the first time the control is added to the parent. When the container is being setup, the initUI method is called; then, the onAddAgain is called every time the container is added again.
        Overrides:
        initUI in class Container
      • reposition

        protected void reposition​(boolean recursive)
        Description copied from class: Control
        Repositions this control, and dives into other controls if this is a container and recursive is true.
        Overrides:
        reposition in class Control
      • onEvent

        public void onEvent​(Event e)
        Description copied from class: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class Control
        Parameters:
        e - the event to process
        See Also:
        Event, KeyEvent, PenEvent
      • onPopup

        public void onPopup()
        Description copied from class: Window
        Placeholder called imediatly before the popup began. The default implementation does nothing.
        Overrides:
        onPopup in class Window