# Class DefaultLookAndFeel

java.lang.Object
com.codename1.ui.plaf.LookAndFeel
com.codename1.ui.plaf.DefaultLookAndFeel

All Implemented Interfaces:
  `FocusListener`

public class DefaultLookAndFeel extends LookAndFeel implements FocusListener
Used to render the default look of Codename One

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultLookAndFeel(UIManager manager)`
  Creates a new instance of DefaultLookAndFeel

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `bind(Component cmp)`
  Every component binds itself to the look and feel thus allowing the look and feel to customize the component.
  `TextSelection.Span`
  `calculateLabelSpan(TextSelection sel, Label l)`
  Calculates the text selection spans for a given label
  `TextSelection.Span`
  `calculateSpanForLabelText(TextSelection sel, Label l, String text, int x, int y, int textSpaceW)`
  `TextSelection.Spans`
  `calculateTextAreaSpan(TextSelection sel, TextArea ta)`
  Calculates the Spans used in text selection for a given text area.
  `TextSelection.Spans`
  `calculateTextFieldSpan(TextSelection sel, TextArea ta)`
  Calculates the Spans used in text selection for a given text field.
  `void`
  `drawButton(Graphics g, Button b)`
  Invoked for drawing a button widget
  `void`
  `drawCheckBox(Graphics g, Button cb)`
  Invoked for drawing a checkbox widget
  `void`
  `drawComboBox(Graphics g, List cb)`
  Invoked for drawing a combo box widget
  `void`
  `drawLabel(Graphics g, Label l)`
  Invoked for drawing a label widget
  `protected int`
  `drawLabelText(Graphics g, Label l, String text, int x, int y, int textSpaceW)`
  Draws the text of a label
  `void`
  `drawList(Graphics g, List l)`
  Invoked for drawing a list widget
  `void`
  `drawPullToRefresh(Graphics g, Component cmp, boolean taskExecuted)`
  Paints the pull to refresh
  `void`
  `drawRadioButton(Graphics g, Button rb)`
  Invoked for drawing the radio button widget
  `void`
  `drawTextArea(Graphics g, TextArea ta)`
  Draw the given text area
  `void`
  `drawTextField(Graphics g, TextArea ta)`
  Draws the text field without its cursor which is drawn in a separate method input mode indication can also be drawn using this method.
  `void`
  `drawTextFieldCursor(Graphics g, TextArea ta)`
  Draws the cursor of the text field, blinking is handled simply by avoiding a call to this method.
  `void`
  `focusGained(Component cmp)`
  Invoked when component gains focus
  `void`
  `focusLost(Component cmp)`
  Invoked when component loses focus
  `Dimension`
  `getButtonPreferredSize(Button b)`
  Calculate the preferred size of the component
  `Image[]`
  `getCheckBoxFocusImages()`
  Returns the images used to represent the checkbox when focused
  `Image[]`
  `getCheckBoxImages()`
  Returns the images used to represent the checkbox (selected followed by unselected).
  `Dimension`
  `getCheckBoxPreferredSize(Button cb)`
  Calculate the preferred size of the component
  `Dimension`
  `getComboBoxPreferredSize(List cb)`
  Calculate the preferred size of the component
  `Dimension`
  `getLabelPreferredSize(Label l)`
  Calculate the preferred size of the component
  `Dimension`
  `getListPreferredSize(List l)`
  Calculate the preferred size of the component
  `int`
  `getPullToRefreshHeight()`
  Returns the required height of the pull to refresh feature
  `Image[]`
  `getRadioButtonFocusImages()`
  Returns the images used to represent the radio button when in focused mode
  `Image[]`
  `getRadioButtonImages()`
  Returns the images used to represent the radio button (selected followed by unselected).
  `Dimension`
  `getRadioButtonPreferredSize(Button rb)`
  Calculate the preferred size of the component
  `Dimension`
  `getTextAreaSize(TextArea ta, boolean pref)`
  Calculate the preferred size of the component
  `Dimension`
  `getTextFieldPreferredSize(TextArea ta)`
  Calculate the preferred size of the component
  `protected String`
  `getTextFieldString(TextArea ta)`
  Similar to getText() but works properly with password fields
  `boolean`
  `isTickWhenFocused()`
  This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to start ticking when the text is too long.
  `void`
  `refreshTheme(boolean b)`
  This method is a callback to the LookAndFeel when a theme is being changed in the UIManager
  `static int`
  `reverseAlignForBidi(Component c, int align)`
  Reverses alignment in the case of bidi
  `void`
  `setCheckBoxFocusImages(Image checkedX, Image uncheckedX, Image disabledChecked, Image disabledUnchecked)`
  Sets images for checkbox when in focused mode
  `void`
  `setCheckBoxImages(Image checkedX, Image uncheckedX)`
  Sets images for checkbox checked/unchecked modes
  `void`
  `setCheckBoxImages(Image checkedX, Image uncheckedX, Image disabledChecked, Image disabledUnchecked)`
  Sets images for checkbox checked/unchecked modes
  `void`
  `setComboBoxImage(Image picker)`
  Sets image for the combo box dropdown drawing
  `void`
  `setPasswordChar(char c)`
  Sets the password character to display in the TextArea and the TextField
  `void`
  `setRadioButtonFocusImages(Image selected, Image unselected, Image disabledSelected, Image disabledUnselected)`
  Sets images for radio button selected/unselected and disabled modes, when the radio button has focus, these are entirely optional
  `void`
  `setRadioButtonImages(Image selected, Image unselected)`
  Sets images for radio button selected/unselected modes
  `void`
  `setRadioButtonImages(Image selected, Image unselected, Image disabledSelected, Image disabledUnselected)`
  Sets images for radio button selected/unselected modes
  `void`
  `setTickWhenFocused(boolean tickWhenFocused)`
  This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to start ticking when the text is too long.

  ### Methods inherited from class LookAndFeel

  `drawHorizontalScroll, drawVerticalScroll, getDefaultDialogTransitionIn, getDefaultDialogTransitionOut, getDefaultFormTintColor, getDefaultFormTransitionIn, getDefaultFormTransitionOut, getDefaultMenuTransitionIn, getDefaultMenuTransitionOut, getDefaultSmoothScrollingSpeed, getDisableColor, getFadeScrollBarSpeed, getFadeScrollEdgeLength, getHorizontalScrollHeight, getMenuBarClass, getMenuIcons, getMenuRenderer, getTactileTouchDuration, getTextFieldCursorColor, getTickerSpeed, getVerticalScrollWidth, isBackgroundImageDetermineSize, isDefaultAlwaysTensile, isDefaultEndsWith3Points, isDefaultSmoothScrolling, isDefaultSnapToGrid, isDefaultTensileDrag, isDefaultTensileHighlight, isFadeScrollBar, isFadeScrollEdge, isFocusScrolling, isReverseSoftButtons, isRTL, isScrollVisible, isTouchMenus, paintTensileHighlight, setBackgroundImageDetermineSize, setDefaultAlwaysTensile, setDefaultDialogTransitionIn, setDefaultDialogTransitionOut, setDefaultEndsWith3Points, setDefaultFormTintColor, setDefaultFormTransitionIn, setDefaultFormTransitionOut, setDefaultMenuTransitionIn, setDefaultMenuTransitionOut, setDefaultSmoothScrolling, setDefaultSmoothScrollingSpeed, setDefaultSnapToGrid, setDefaultTensileDrag, setDisableColor, setFadeScrollBar, setFadeScrollBarSpeed, setFadeScrollEdge, setFadeScrollEdgeLength, setFG, setFocusScrolling, setMenuBarClass, setMenuIcons, setMenuRenderer, setReverseSoftButtons, setRTL, setTactileTouchDuration, setTextFieldCursorColor, setTickerSpeed, setTouchMenus, uninstall`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DefaultLookAndFeel

    public DefaultLookAndFeel(UIManager manager)
    Creates a new instance of DefaultLookAndFeel

- ## Method Details

  - ### reverseAlignForBidi

    public static int reverseAlignForBidi(Component c, int align)
    Reverses alignment in the case of bidi

  - ### bind

    public void bind(Component cmp)

    Every component binds itself to the look and feel thus allowing the look and feel to customize the component. Binding occurs at the end of the constructor when the component is in a valid state and ready to be used. Notice that a component might be bound twice or more and it is the responsibility of the LookAndFeel to protect against that.

    ###### Parameters

    - `cmp`: component instance that may be customized by the look and feel
    Overrides:
      `bind` in class `LookAndFeel`

  - ### isTickWhenFocused

    public boolean isTickWhenFocused()

    This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to start ticking when the text is too long.

    ###### Returns

    tickWhenFocused

  - ### setTickWhenFocused

    public void setTickWhenFocused(boolean tickWhenFocused)

    This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to start ticking when the text is too long.

    ###### Parameters

    - `tickWhenFocused`

  - ### setCheckBoxImages

    public void setCheckBoxImages(Image checkedX, Image uncheckedX)

    Sets images for checkbox checked/unchecked modes

    ###### Parameters

    - `checkedX`: the image to draw in order to represent a checked checkbox

    - `uncheckedX`: the image to draw in order to represent an uncheck checkbox

  - ### setCheckBoxImages

    public void setCheckBoxImages(Image checkedX, Image uncheckedX, Image disabledChecked, Image disabledUnchecked)

    Sets images for checkbox checked/unchecked modes

    ###### Parameters

    - `checkedX`: the image to draw in order to represent a checked checkbox

    - `uncheckedX`: the image to draw in order to represent an uncheck checkbox

    - `disabledChecked`: same as checked for the disabled state

    - `disabledUnchecked`: same as unchecked for the disabled state

  - ### setCheckBoxFocusImages

    public void setCheckBoxFocusImages(Image checkedX, Image uncheckedX, Image disabledChecked, Image disabledUnchecked)

    Sets images for checkbox when in focused mode

    ###### Parameters

    - `checkedX`: the image to draw in order to represent a checked checkbox

    - `uncheckedX`: the image to draw in order to represent an uncheck checkbox

    - `disabledChecked`: same as checked for the disabled state

    - `disabledUnchecked`: same as unchecked for the disabled state

  - ### setComboBoxImage

    public void setComboBoxImage(Image picker)

    Sets image for the combo box dropdown drawing

    ###### Parameters

    - `picker`: picker image

  - ### setRadioButtonImages

    public void setRadioButtonImages(Image selected, Image unselected)

    Sets images for radio button selected/unselected modes

    ###### Parameters

    - `selected`: the image to draw in order to represent a selected radio button

    - `unselected`: the image to draw in order to represent an unselected radio button

  - ### setRadioButtonImages

    public void setRadioButtonImages(Image selected, Image unselected, Image disabledSelected, Image disabledUnselected)

    Sets images for radio button selected/unselected modes

    ###### Parameters

    - `selected`: the image to draw in order to represent a selected radio button

    - `unselected`: the image to draw in order to represent an unselected radio button

    - `disabledSelected`: same as selected for the disabled state

    - `disabledUnselected`: same as unselected for the disabled state

  - ### setRadioButtonFocusImages

    public void setRadioButtonFocusImages(Image selected, Image unselected, Image disabledSelected, Image disabledUnselected)

    Sets images for radio button selected/unselected and disabled modes, when the radio button has focus, these are entirely optional

    ###### Parameters

    - `selected`: the image to draw in order to represent a selected radio button

    - `unselected`: the image to draw in order to represent an unselected radio button

    - `disabledSelected`: same as selected for the disabled state

    - `disabledUnselected`: same as unselected for the disabled state

  - ### setPasswordChar

    public void setPasswordChar(char c)

    Sets the password character to display in the TextArea and the TextField

    ###### Parameters

    - `the`: char to display

  - ### getRadioButtonImages

    public Image[] getRadioButtonImages()

    Returns the images used to represent the radio button (selected followed by unselected).

    ###### Returns

    images representing the radio button or null for using the default drawing

  - ### getRadioButtonFocusImages

    public Image[] getRadioButtonFocusImages()

    Returns the images used to represent the radio button when in focused mode

    ###### Returns

    images representing the radio button or null for using the default drawing

  - ### getCheckBoxImages

    public Image[] getCheckBoxImages()

    Returns the images used to represent the checkbox (selected followed by unselected).

    ###### Returns

    images representing the check box or null for using the default drawing

  - ### getCheckBoxFocusImages

    public Image[] getCheckBoxFocusImages()

    Returns the images used to represent the checkbox when focused

    ###### Returns

    images representing the check box or null for using the default drawing

  - ### drawButton

    public void drawButton(Graphics g, Button b)

    Invoked for drawing a button widget

    ###### Parameters

    - `g`: graphics context

    - `b`: component to draw

    ###### Deprecated

    this method is no longer used by the implementation, we shifted code away to improve performance

    ###### Deprecated

    this method is no longer used by the implementation, we shifted code away to improve performance

    Specified by:
      `drawButton` in class `LookAndFeel`

  - ### drawCheckBox

    public void drawCheckBox(Graphics g, Button cb)

    Invoked for drawing a checkbox widget

    ###### Parameters

    - `g`: graphics context

    - `cb`: component to draw

    Specified by:
      `drawCheckBox` in class `LookAndFeel`

  - ### drawLabel

    public void drawLabel(Graphics g, Label l)

    Invoked for drawing a label widget

    ###### Parameters

    - `g`: graphics context

    - `l`: component to draw

    ###### Deprecated

    this method is no longer used by the implementation, we shifted code away to improve performance

    ###### Deprecated

    this method is no longer used by the implementation, we shifted code away to improve performance

    Specified by:
      `drawLabel` in class `LookAndFeel`

  - ### calculateLabelSpan

    public TextSelection.Span calculateLabelSpan(TextSelection sel, Label l)
    Description copied from class: `LookAndFeel`

    Calculates the text selection spans for a given label

    ###### Parameters

    - `sel`: TextSelection instance

    - `l`: Label

    ###### Returns

    A span representing the positions of characters in the label

    ###### Since

    7.0

    ###### See also

    - TextSelection
    Specified by:
      `calculateLabelSpan` in class `LookAndFeel`

  - ### drawRadioButton

    public void drawRadioButton(Graphics g, Button rb)

    Invoked for drawing the radio button widget

    ###### Parameters

    - `g`: graphics context

    - `rb`: component to draw

    Specified by:
      `drawRadioButton` in class `LookAndFeel`

  - ### drawComboBox

    public void drawComboBox(Graphics g, List cb)

    Invoked for drawing a combo box widget

    ###### Parameters

    - `g`: graphics context

    - `cb`: component to draw

    Specified by:
      `drawComboBox` in class `LookAndFeel`

  - ### drawList

    public void drawList(Graphics g, List l)

    Invoked for drawing a list widget

    ###### Parameters

    - `g`: graphics context

    - `l`: component to draw

    Specified by:
      `drawList` in class `LookAndFeel`

  - ### calculateTextAreaSpan

    public TextSelection.Spans calculateTextAreaSpan(TextSelection sel, TextArea ta)
    Description copied from class: `LookAndFeel`

    Calculates the Spans used in text selection for a given text area.

    ###### Parameters

    - `sel`: The current TextSelection instance.

    - `ta`: The TextArea to calculate spans for.

    ###### Returns

    The spans for the given text field.

    ###### Since

    7.0

    Specified by:
      `calculateTextAreaSpan` in class `LookAndFeel`

  - ### drawTextArea

    public void drawTextArea(Graphics g, TextArea ta)

    Draw the given text area

    ###### Parameters

    - `g`: graphics context

    - `ta`: component to draw

    Specified by:
      `drawTextArea` in class `LookAndFeel`

  - ### getButtonPreferredSize

    public Dimension getButtonPreferredSize(Button b)

    Calculate the preferred size of the component

    ###### Parameters

    - `b`: component whose size should be calculated

    ###### Returns

    the preferred size for the button

    Specified by:
      `getButtonPreferredSize` in class `LookAndFeel`

  - ### getCheckBoxPreferredSize

    public Dimension getCheckBoxPreferredSize(Button cb)

    Calculate the preferred size of the component

    ###### Parameters

    - `cb`: component whose size should be calculated

    ###### Returns

    the preferred size for the component

    Specified by:
      `getCheckBoxPreferredSize` in class `LookAndFeel`

  - ### getLabelPreferredSize

    public Dimension getLabelPreferredSize(Label l)

    Calculate the preferred size of the component

    ###### Parameters

    - `l`: component whose size should be calculated

    ###### Returns

    the preferred size for the component

    Specified by:
      `getLabelPreferredSize` in class `LookAndFeel`

  - ### getListPreferredSize

    public Dimension getListPreferredSize(List l)

    Calculate the preferred size of the component

    ###### Parameters

    - `l`: component whose size should be calculated

    ###### Returns

    the preferred size for the component

    Specified by:
      `getListPreferredSize` in class `LookAndFeel`

  - ### getRadioButtonPreferredSize

    public Dimension getRadioButtonPreferredSize(Button rb)

    Calculate the preferred size of the component

    ###### Parameters

    - `rb`: component whose size should be calculated

    ###### Returns

    the preferred size for the component

    Specified by:
      `getRadioButtonPreferredSize` in class `LookAndFeel`

  - ### getTextAreaSize

    public Dimension getTextAreaSize(TextArea ta, boolean pref)

    Calculate the preferred size of the component

    ###### Parameters

    - `ta`: component whose size should be calculated

    - `pref`: indicates whether preferred or scroll size should be returned

    ###### Returns

    the preferred size for the component

    Specified by:
      `getTextAreaSize` in class `LookAndFeel`

  - ### drawLabelText

    protected int drawLabelText(Graphics g, Label l, String text, int x, int y, int textSpaceW)

    Draws the text of a label

    ###### Parameters

    - `g`: graphics context

    - `l`: label component

    - `text`: the text for the label

    - `x`: position for the label

    - `y`: position for the label

    - `textSpaceW`: the width available for the component

    ###### Returns

    the space used by the drawing

  - ### getComboBoxPreferredSize

    public Dimension getComboBoxPreferredSize(List cb)

    Calculate the preferred size of the component

    ###### Parameters

    - `box`: component whose size should be calculated

    ###### Returns

    the preferred size for the component

    Specified by:
      `getComboBoxPreferredSize` in class `LookAndFeel`

  - ### getTextFieldString

    protected String getTextFieldString(TextArea ta)
    Similar to getText() but works properly with password fields

  - ### calculateTextFieldSpan

    public TextSelection.Spans calculateTextFieldSpan(TextSelection sel, TextArea ta)
    Description copied from class: `LookAndFeel`

    Calculates the Spans used in text selection for a given text field.

    ###### Parameters

    - `sel`: The current TextSelection instance.

    - `ta`: The textfield to calculate spans for.

    ###### Returns

    The spans for the given text field.

    ###### Since

    7.0

    Specified by:
      `calculateTextFieldSpan` in class `LookAndFeel`

  - ### drawTextField

    public void drawTextField(Graphics g, TextArea ta)

    Draws the text field without its cursor which is drawn in a separate method input mode indication can also be drawn using this method.

    ###### Parameters

    - `g`: graphics context

    - `ta`: component to draw

    Specified by:
      `drawTextField` in class `LookAndFeel`

  - ### getTextFieldPreferredSize

    public Dimension getTextFieldPreferredSize(TextArea ta)

    Calculate the preferred size of the component

    ###### Parameters

    - `ta`: component whose size should be calculated

    ###### Returns

    the preferred size for the component

    Specified by:
      `getTextFieldPreferredSize` in class `LookAndFeel`

  - ### drawTextFieldCursor

    public void drawTextFieldCursor(Graphics g, TextArea ta)

    Draws the cursor of the text field, blinking is handled simply by avoiding a call to this method.

    ###### Parameters

    - `g`: graphics context

    - `ta`: component to draw

    Specified by:
      `drawTextFieldCursor` in class `LookAndFeel`

  - ### drawPullToRefresh

    public void drawPullToRefresh(Graphics g, Component cmp, boolean taskExecuted)

    Paints the pull to refresh

    ###### Parameters

    - `g`: graphics context

    - `cmp`: the Component which we draw the pull to refresh beneath it

    - `taskExecuted`: an indication if the refresh task is currently running

    Specified by:
      `drawPullToRefresh` in class `LookAndFeel`

  - ### getPullToRefreshHeight

    public int getPullToRefreshHeight()
    Returns the required height of the pull to refresh feature
    Specified by:
      `getPullToRefreshHeight` in class `LookAndFeel`

  - ### focusGained

    public void focusGained(Component cmp)

    Invoked when component gains focus

    ###### Parameters

    - `cmp`: the component that gains focus
    Specified by:
      `focusGained` in interface `FocusListener`

  - ### focusLost

    public void focusLost(Component cmp)

    Invoked when component loses focus

    ###### Parameters

    - `cmp`: the component that lost focus
    Specified by:
      `focusLost` in interface `FocusListener`

  - ### refreshTheme

    public void refreshTheme(boolean b)

    This method is a callback to the LookAndFeel when a theme is being changed in the UIManager

    ###### Parameters

    - `completeClear`: indicates that the theme is set and not added
    Overrides:
      `refreshTheme` in class `LookAndFeel`

  - ### calculateSpanForLabelText

    public TextSelection.Span calculateSpanForLabelText(TextSelection sel, Label l, String text, int x, int y, int textSpaceW)