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, uninstall
-
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)
-