Class DefaultLookAndFeel
- All Implemented Interfaces:
FocusListener
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultLookAndFeel(UIManager manager) Creates a new instance of DefaultLookAndFeel -
Method Summary
Modifier and TypeMethodDescriptionvoidEvery component binds itself to the look and feel thus allowing the look and feel to customize the component.calculateLabelSpan(TextSelection sel, Label l) Calculates the text selection spans for a given labelcalculateSpanForLabelText(TextSelection sel, Label l, String text, int x, int y, int textSpaceW) calculateTextAreaSpan(TextSelection sel, TextArea ta) Calculates the Spans used in text selection for a given text area.calculateTextFieldSpan(TextSelection sel, TextArea ta) Calculates the Spans used in text selection for a given text field.voiddrawButton(Graphics g, Button b) Invoked for drawing a button widgetvoiddrawCheckBox(Graphics g, Button cb) Invoked for drawing a checkbox widgetvoiddrawComboBox(Graphics g, List cb) Invoked for drawing a combo box widgetvoidInvoked for drawing a label widgetprotected intdrawLabelText(Graphics g, Label l, String text, int x, int y, int textSpaceW) Draws the text of a labelvoidInvoked for drawing a list widgetvoiddrawPullToRefresh(Graphics g, Component cmp, boolean taskExecuted) Paints the pull to refreshvoiddrawRadioButton(Graphics g, Button rb) Invoked for drawing the radio button widgetvoiddrawTextArea(Graphics g, TextArea ta) Draw the given text areavoiddrawTextField(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.voiddrawTextFieldCursor(Graphics g, TextArea ta) Draws the cursor of the text field, blinking is handled simply by avoiding a call to this method.voidfocusGained(Component cmp) Invoked when component gains focusvoidInvoked when component loses focusCalculate the preferred size of the componentImage[]Returns the images used to represent the checkbox when focusedImage[]Returns the images used to represent the checkbox (selected followed by unselected).Calculate the preferred size of the componentCalculate the preferred size of the componentCalculate the preferred size of the componentCalculate the preferred size of the componentintReturns the required height of the pull to refresh featureImage[]Returns the images used to represent the radio button when in focused modeImage[]Returns the images used to represent the radio button (selected followed by unselected).Calculate the preferred size of the componentgetTextAreaSize(TextArea ta, boolean pref) Calculate the preferred size of the componentCalculate the preferred size of the componentprotected StringSimilar to getText() but works properly with password fieldsbooleanThis method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to start ticking when the text is too long.voidrefreshTheme(boolean b) This method is a callback to the LookAndFeel when a theme is being changed in the UIManagerstatic intreverseAlignForBidi(Component c, int align) Reverses alignment in the case of bidivoidsetCheckBoxFocusImages(Image checkedX, Image uncheckedX, Image disabledChecked, Image disabledUnchecked) Sets images for checkbox when in focused modevoidsetCheckBoxImages(Image checkedX, Image uncheckedX) Sets images for checkbox checked/unchecked modesvoidsetCheckBoxImages(Image checkedX, Image uncheckedX, Image disabledChecked, Image disabledUnchecked) Sets images for checkbox checked/unchecked modesvoidsetComboBoxImage(Image picker) Sets image for the combo box dropdown drawingvoidsetPasswordChar(char c) Sets the password character to display in the TextArea and the TextFieldvoidsetRadioButtonFocusImages(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 optionalvoidsetRadioButtonImages(Image selected, Image unselected) Sets images for radio button selected/unselected modesvoidsetRadioButtonImages(Image selected, Image unselected, Image disabledSelected, Image disabledUnselected) Sets images for radio button selected/unselected modesvoidsetTickWhenFocused(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, uninstallModifier and TypeMethodDescriptionvoiddrawHorizontalScroll(Graphics g, Component c, float offsetRatio, float blockSizeRatio) Draws a horizontal scroll bar in the given componentvoiddrawVerticalScroll(Graphics g, Component c, float offsetRatio, float blockSizeRatio) Draws a vertical scroll bar in the given componentAllows us to define a default animation that will draw the transition for entering a dialogAllows us to define a default animation that will draw the transition for exiting a dialogintTint color is set when a form is partially covered be it by a menu or by a dialog.Allows us to define a default animation that will draw the transition for entering a formAllows us to define a default animation that will draw the transition for exiting a formAllows us to define a default animation that will draw the transition for entering a MenuAllows us to define a default animation that will draw the transition for exiting a MenuintIndicates the default speed for smooth scrollingintThis color is used to paint disable mode text color.intReturns
intIndicates the width/height of the fading edge to indicate scrollingintReturns the default height of a horizontal scroll barThis method returns the MenuBar class.Image[]Simple getter for the menu iconsReturns the Menu default rendererintAllows defining a tactile touch device that vibrates when the user presses a component that should respond with tactile feedback on a touch device (e.g. vibrate).intThe color of the text field cursorlongGets the ticker speedintReturns the default width of a vertical scroll barbooleanIndicates if the bg image of a style should determine the minimum preferred size according to the themebooleanEnable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)booleanIndicates whether labels should end with 3 points by defaultbooleanIndicates whether lists and containers should have smooth scrolling by defaultbooleanIndicates whether scrolling this component should jump to a specific location in a gridbooleanIndicates whether tensile drag should be active by defaultbooleanIndicates whether tensile highlight should be active by defaultbooleanIndicates whether the scrollbar should fade when unusedbooleanIndicates whether the edge of a scrollable area should fade outbooleanIndicates whether lists and containers should scroll only via focus and thus "jump" when moving to a larger component as was the case in older versions of Codename One.booleanIndicates whether softbuttons should be reversed from their default orientationbooleanisRTL()Use this to check if the LookAndFeel is in RTL modebooleanReturns
booleanIndicates whether the menu UI should target a touch based device or a standard cell phonevoidpaintTensileHighlight(Component t, Graphics g, boolean top, int opacity) Paints the tensile hightlight imagevoidsetBackgroundImageDetermineSize(boolean backgroundImageDetermineSize) Indicates if the bg image of a style should determine the minimum preferred size according to the themevoidsetDefaultAlwaysTensile(boolean defaultAlwaysTensile) Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)voidsetDefaultDialogTransitionIn(Transition defaultDialogTransitionIn) Allows us to define a default animation that will draw the transition for entering a dialogvoidsetDefaultDialogTransitionOut(Transition defaultDialogTransitionOut) Allows us to define a default animation that will draw the transition for exiting a dialogvoidsetDefaultEndsWith3Points(boolean defaultEndsWith3Points) Indicates whether labels should end with 3 points by defaultvoidsetDefaultFormTintColor(int defaultFormTintColor) Tint color is set when a form is partially covered be it by a menu or by a dialog.voidsetDefaultFormTransitionIn(Transition defaultFormTransitionIn) Allows us to define a default animation that will draw the transition for entering a formvoidsetDefaultFormTransitionOut(Transition defaultFormTransitionOut) Allows us to define a default animation that will draw the transition for exiting a formvoidsetDefaultMenuTransitionIn(Transition defaultMenuTransitionIn) Allows us to define a default animation that will draw the transition for entering a MenuvoidsetDefaultMenuTransitionOut(Transition defaultMenuTransitionOut) Allows us to define a default animation that will draw the transition for exiting a MenuvoidsetDefaultSmoothScrolling(boolean defaultSmoothScrolling) Indicates whether lists and containers should have smooth scrolling by defaultvoidsetDefaultSmoothScrollingSpeed(int defaultSmoothScrollingSpeed) Indicates the default speed for smooth scrollingvoidsetDefaultSnapToGrid(boolean defaultSnapToGrid) Indicates whether scrolling this component should jump to a specific location in a gridvoidsetDefaultTensileDrag(boolean defaultTensileDrag) Indicates whether tensile drag should be active by defaultvoidsetDisableColor(int disableColor) Simple setter to disable colorvoidsetFadeScrollBar(boolean fadeScrollBar) Indicates whether the scrollbar should fade when unusedvoidsetFadeScrollBarSpeed(int fadeScrollBarSpeed) Parameters
voidsetFadeScrollEdge(boolean fadeScrollEdge) Indicates whether the edge of a scrollable area should fade outvoidsetFadeScrollEdgeLength(int fadeScrollEdgeLength) Indicates the width/height of the fading edge to indicate scrollingvoidSets the foreground color and font for a generic component, reuse-able by most component drawing codevoidsetFocusScrolling(boolean focusScrolling) Indicates whether lists and containers should scroll only via focus and thus "jump" when moving to a larger component as was the case in older versions of Codename One.voidsetMenuBarClass(Class menuBar) Simple setter for the MenuBar ClassvoidsetMenuIcons(Image select, Image cancel, Image menu) Sets globally the Menu iconsvoidsetMenuRenderer(ListCellRenderer menuRenderer) Sets the Menu default renderervoidsetReverseSoftButtons(boolean reverseSoftButtons) Indicates whether softbuttons should be reversed from their default orientationvoidsetRTL(boolean rtl) Sets this LookAndFeel to operate in right-to-left mode.voidsetTactileTouchDuration(int tactileTouchDuration) Allows defining a tactile touch device that vibrates when the user presses a component that should respond with tactile feedback on a touch device (e.g. vibrate).voidsetTextFieldCursorColor(int textFieldCursorColor) The color of the text field cursorvoidsetTickerSpeed(long tickerSpeed) Sets the ticker speedvoidsetTouchMenus(boolean touchMenus) Indicates whether the menu UI should target a touch based device or a standard cell phonevoidInvoked when a look and feel is removed, allows a look and feel to release resources related to binding components.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Constructor Details
-
DefaultLookAndFeel
Creates a new instance of DefaultLookAndFeel
-
-
Method Details
-
reverseAlignForBidi
Reverses alignment in the case of bidi -
bind
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:
bindin classLookAndFeel
-
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
-
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
Sets image for the combo box dropdown drawing
Parameters
picker: picker image
-
setRadioButtonImages
-
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
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
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
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
Returns the images used to represent the checkbox when focused
Returns
images representing the check box or null for using the default drawing
-
drawButton
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:
drawButtonin classLookAndFeel
-
-
drawCheckBox
Invoked for drawing a checkbox widget
Parameters
-
g: graphics context -
cb: component to draw
- Specified by:
drawCheckBoxin classLookAndFeel
-
-
drawLabel
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:
drawLabelin classLookAndFeel
-
-
calculateLabelSpan
Description copied from class:LookAndFeelCalculates 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:
calculateLabelSpanin classLookAndFeel
-
-
drawRadioButton
Invoked for drawing the radio button widget
Parameters
-
g: graphics context -
rb: component to draw
- Specified by:
drawRadioButtonin classLookAndFeel
-
-
drawComboBox
Invoked for drawing a combo box widget
Parameters
-
g: graphics context -
cb: component to draw
- Specified by:
drawComboBoxin classLookAndFeel
-
-
drawList
Invoked for drawing a list widget
Parameters
-
g: graphics context -
l: component to draw
- Specified by:
drawListin classLookAndFeel
-
-
calculateTextAreaSpan
Description copied from class:LookAndFeelCalculates 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:
calculateTextAreaSpanin classLookAndFeel
-
-
drawTextArea
Draw the given text area
Parameters
-
g: graphics context -
ta: component to draw
- Specified by:
drawTextAreain classLookAndFeel
-
-
getButtonPreferredSize
Calculate the preferred size of the component
Parameters
b: component whose size should be calculated
Returns
the preferred size for the button
- Specified by:
getButtonPreferredSizein classLookAndFeel
-
getCheckBoxPreferredSize
Calculate the preferred size of the component
Parameters
cb: component whose size should be calculated
Returns
the preferred size for the component
- Specified by:
getCheckBoxPreferredSizein classLookAndFeel
-
getLabelPreferredSize
Calculate the preferred size of the component
Parameters
l: component whose size should be calculated
Returns
the preferred size for the component
- Specified by:
getLabelPreferredSizein classLookAndFeel
-
getListPreferredSize
Calculate the preferred size of the component
Parameters
l: component whose size should be calculated
Returns
the preferred size for the component
- Specified by:
getListPreferredSizein classLookAndFeel
-
getRadioButtonPreferredSize
Calculate the preferred size of the component
Parameters
rb: component whose size should be calculated
Returns
the preferred size for the component
- Specified by:
getRadioButtonPreferredSizein classLookAndFeel
-
getTextAreaSize
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:
getTextAreaSizein classLookAndFeel
-
-
drawLabelText
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
Calculate the preferred size of the component
Parameters
box: component whose size should be calculated
Returns
the preferred size for the component
- Specified by:
getComboBoxPreferredSizein classLookAndFeel
-
getTextFieldString
-
calculateTextFieldSpan
Description copied from class:LookAndFeelCalculates 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:
calculateTextFieldSpanin classLookAndFeel
-
-
drawTextField
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:
drawTextFieldin classLookAndFeel
-
-
getTextFieldPreferredSize
Calculate the preferred size of the component
Parameters
ta: component whose size should be calculated
Returns
the preferred size for the component
- Specified by:
getTextFieldPreferredSizein classLookAndFeel
-
drawTextFieldCursor
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:
drawTextFieldCursorin classLookAndFeel
-
-
drawPullToRefresh
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:
drawPullToRefreshin classLookAndFeel
-
-
getPullToRefreshHeight
public int getPullToRefreshHeight()Returns the required height of the pull to refresh feature- Specified by:
getPullToRefreshHeightin classLookAndFeel
-
focusGained
Invoked when component gains focus
Parameters
cmp: the component that gains focus
- Specified by:
focusGainedin interfaceFocusListener
-
focusLost
Invoked when component loses focus
Parameters
cmp: the component that lost focus
- Specified by:
focusLostin interfaceFocusListener
-
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:
refreshThemein classLookAndFeel
-
calculateSpanForLabelText
public TextSelection.Span calculateSpanForLabelText(TextSelection sel, Label l, String text, int x, int y, int textSpaceW)
-