Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit.plaf
Class DefaultLookAndFeel

java.lang.Object
  extended by com.sun.dtv.lwuit.plaf.LookAndFeel
      extended by com.sun.dtv.lwuit.plaf.DefaultLookAndFeel
All Implemented Interfaces:
FocusListener

public class DefaultLookAndFeel
extends LookAndFeel
implements FocusListener

Used to render the default look of LWUIT.


Constructor Summary
DefaultLookAndFeel()
          Creates a new instance of DefaultLookAndFeel.
 
Method Summary
 void bind(Component cmp)
          Every component binds itself to the look and feel thus allowing the look and feel to customize the component.
 void drawButton(Graphics g, Button b)
          Invoked for drawing a button widget.
 void drawCheckBox(Graphics g, CheckBox cb)
          Invoked for drawing a checkbox widget.
 void drawComboBox(Graphics g, ComboBox cb)
          Invoked for drawing a combo box widget.
 void drawLabel(Graphics g, Label l)
          Invoked for drawing a label widget.
 void drawList(Graphics g, List l)
          Invoked for drawing a list widget.
 void drawMonthView(Graphics g, Calendar cal, Component mv)
          Invoked for drawing a month view widget.
 void drawRadioButton(Graphics g, RadioButton rb)
          Invoked for drawing the radio button widget.
 void drawTabbedPane(Graphics g, TabbedPane tp)
          Invoked for drawing the Tab Pane widget.
 void drawTabbedPaneContentPane(TabbedPane tp, Graphics g, Rectangle rect, Dimension cellsPreferredSize, int numOfTabs, int selectedTabIndex, Dimension tabsSize, int cellOffsetX, int cellOffsetY)
          Draws and return the TabbedPane content pane painter.
 void drawTextArea(Graphics g, TextArea ta)
          Invoked for drawing the text area widget.
 void drawTextField(Graphics g, TextField ta)
          Draws the text field without its cursor which is drawn in a separate method.
 void drawTextFieldCursor(Graphics g, TextField ta)
          Draws the cursor of the text field, blinking is handled simply by avoiding a call to this method.
 long findDayAt(int x, int y, Calendar cal, Component mv)
          Returns the day of the month in the month view at the given relative component X/Y offsets.
 void focusGained(Component cmp)
          Invoked when component gains focus.
 void focusLost(Component cmp)
          Invoked when component loses focus.
 Dimension getButtonPreferredSize(Button b)
          Returns the preferred size for the button.
 Dimension getCheckBoxPreferredSize(CheckBox cb)
          Returns the preferred size for the checkbox.
 Dimension getComboBoxPreferredSize(ComboBox cb)
          Returns the preferred size for the combo box.
 Dimension getLabelPreferredSize(Label l)
          Returns the preferred size for the label.
 Dimension getListPreferredSize(List l)
          Returns the preferred size for the list.
 Dimension getMonthViewPreferredSize(Component mv)
          Returns the preferred size for the month view component.
 Dimension getRadioButtonPreferredSize(RadioButton rb)
          Returns the preferred size for the radio button.
 Component getTabbedPaneCell(TabbedPane tp, String text, Image icon, boolean isSelected, boolean cellHasFocus, Style cellStyle, Style tabbedPaneStyle, int cellOffsetX, int cellOffsetY, Dimension cellsPreferredSize, Dimension contentPaneSize)
          Draws and return the TabbedPane cell component (renderer) according to each tab orientation, the borders are getting draws.
 Dimension getTextAreaPreferredSize(TextArea ta)
          Returns the preferred size for the text area.
 Dimension getTextFieldPreferredSize(TextField ta)
          Returns the preferred size for the text field.
 long getTickerSpeed()
          Gets the ticker speed.
 void setCheckBoxImages(Image checked, Image unchecked)
          Sets images for checkbox checked/unchecked modes.
 void setComboBoxImage(Image picker)
          Sets image for the combo box drop down drawing.
 void setRadioButtonImages(Image selected, Image unselected)
          Sets images for radio button selected/unselected modes.
 void setTickerSpeed(long tickerSpeed)
          Sets the ticker speed.
 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 com.sun.dtv.lwuit.plaf.LookAndFeel
drawHorizontalScroll, drawVerticalScroll, getDefaultDialogTransitionIn, getDefaultDialogTransitionOut, getDefaultFormTintColor, getDefaultFormTransitionIn, getDefaultFormTransitionOut, getDefaultMenuTransitionIn, getDefaultMenuTransitionOut, getDefaultSmoothScrollingSpeed, getDisableColor, getHorizontalScrollHeight, getMenuIcons, getMenuRenderer, getVerticalScrollWidth, isDefaultSmoothScrolling, isReverseSoftButtons, setDefaultDialogTransitionIn, setDefaultDialogTransitionOut, setDefaultFormTintColor, setDefaultFormTransitionIn, setDefaultFormTransitionOut, setDefaultMenuTransitionIn, setDefaultMenuTransitionOut, setDefaultSmoothScrolling, setDefaultSmoothScrollingSpeed, setDisableColor, setFG, setMenuIcons, setMenuRenderer, setReverseSoftButtons, uninstall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLookAndFeel

public DefaultLookAndFeel()
Creates a new instance of DefaultLookAndFeel.

Method Detail

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.

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

getTickerSpeed

public long getTickerSpeed()
Gets the ticker speed.

Returns:
ticker speed in milliseconds
See Also:
setTickerSpeed(long)

setTickerSpeed

public void setTickerSpeed(long tickerSpeed)
Sets the ticker speed.

Parameters:
tickerSpeed - the speed in milliseconds
See Also:
getTickerSpeed()

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 - boolean indicating whether those components should start ticking if necessary

setCheckBoxImages

public void setCheckBoxImages(Image checked,
                              Image unchecked)
Sets images for checkbox checked/unchecked modes.

Parameters:
checked - the image to draw in order to represent a checked checkbox
unchecked - the image to draw in order to represent an uncheck checkbox

setComboBoxImage

public void setComboBoxImage(Image picker)
Sets image for the combo box drop down 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

drawButton

public void drawButton(Graphics g,
                       Button b)
Invoked for drawing a button widget.

Specified by:
drawButton in class LookAndFeel
Parameters:
g - the Graphics object
b - the button

drawCheckBox

public void drawCheckBox(Graphics g,
                         CheckBox cb)
Invoked for drawing a checkbox widget.

Specified by:
drawCheckBox in class LookAndFeel
Parameters:
g - the Graphics object
cb - the check box

drawLabel

public void drawLabel(Graphics g,
                      Label l)
Invoked for drawing a label widget.

Specified by:
drawLabel in class LookAndFeel
Parameters:
g - the Graphics object
l - the label

drawRadioButton

public void drawRadioButton(Graphics g,
                            RadioButton rb)
Invoked for drawing the radio button widget.

Specified by:
drawRadioButton in class LookAndFeel
Parameters:
g - the Graphics object
rb - the radio button

drawComboBox

public void drawComboBox(Graphics g,
                         ComboBox cb)
Invoked for drawing a combo box widget.

Specified by:
drawComboBox in class LookAndFeel
Parameters:
g - the Graphics object
cb - the combo box

drawList

public void drawList(Graphics g,
                     List l)
Invoked for drawing a list widget.

Specified by:
drawList in class LookAndFeel
Parameters:
g - the Graphics object
l - the list

drawMonthView

public void drawMonthView(Graphics g,
                          Calendar cal,
                          Component mv)
Invoked for drawing a month view widget.

Specified by:
drawMonthView in class LookAndFeel
Parameters:
g - the Graphics object
cal - the calendar
mv - the month view component

drawTextArea

public void drawTextArea(Graphics g,
                         TextArea ta)
Invoked for drawing the text area widget.

Specified by:
drawTextArea in class LookAndFeel
Parameters:
g - the Graphics object
ta - the text area

getButtonPreferredSize

public Dimension getButtonPreferredSize(Button b)
Returns the preferred size for the button.

Specified by:
getButtonPreferredSize in class LookAndFeel
Parameters:
b - the button
Returns:
the preferred size for the button

getCheckBoxPreferredSize

public Dimension getCheckBoxPreferredSize(CheckBox cb)
Returns the preferred size for the checkbox.

Specified by:
getCheckBoxPreferredSize in class LookAndFeel
Parameters:
cb - the checkbox
Returns:
the preferred size for the checkbox

getLabelPreferredSize

public Dimension getLabelPreferredSize(Label l)
Returns the preferred size for the label.

Specified by:
getLabelPreferredSize in class LookAndFeel
Parameters:
l - the label
Returns:
the preferred size for the label

getListPreferredSize

public Dimension getListPreferredSize(List l)
Returns the preferred size for the list.

Specified by:
getListPreferredSize in class LookAndFeel
Parameters:
l - the list
Returns:
the preferred size for the list

getMonthViewPreferredSize

public Dimension getMonthViewPreferredSize(Component mv)
Returns the preferred size for the month view component.

Specified by:
getMonthViewPreferredSize in class LookAndFeel
Parameters:
mv - the month view component
Returns:
the preferred size for the month view component

getRadioButtonPreferredSize

public Dimension getRadioButtonPreferredSize(RadioButton rb)
Returns the preferred size for the radio button.

Specified by:
getRadioButtonPreferredSize in class LookAndFeel
Parameters:
rb - the radio button
Returns:
the preferred size for the radio button

getTextAreaPreferredSize

public Dimension getTextAreaPreferredSize(TextArea ta)
Returns the preferred size for the text area.

Specified by:
getTextAreaPreferredSize in class LookAndFeel
Parameters:
ta - the text area
Returns:
the preferred size for the text area

findDayAt

public long findDayAt(int x,
                      int y,
                      Calendar cal,
                      Component mv)
Returns the day of the month in the month view at the given relative component X/Y offsets. This is important for touch screen interaction.

Specified by:
findDayAt in class LookAndFeel
Parameters:
x - x coordinate of offset
y - y coordinate of offset
cal - the calendar
mv - the month view component
Returns:
the day of the month

getComboBoxPreferredSize

public Dimension getComboBoxPreferredSize(ComboBox cb)
Returns the preferred size for the combo box.

Specified by:
getComboBoxPreferredSize in class LookAndFeel
Parameters:
cb - the combo box
Returns:
the preferred size for the combo box

drawTabbedPane

public void drawTabbedPane(Graphics g,
                           TabbedPane tp)
Invoked for drawing the Tab Pane widget.

Specified by:
drawTabbedPane in class LookAndFeel
Parameters:
g - the Graphics object
tp - the tabbed pane

getTabbedPaneCell

public Component getTabbedPaneCell(TabbedPane tp,
                                   String text,
                                   Image icon,
                                   boolean isSelected,
                                   boolean cellHasFocus,
                                   Style cellStyle,
                                   Style tabbedPaneStyle,
                                   int cellOffsetX,
                                   int cellOffsetY,
                                   Dimension cellsPreferredSize,
                                   Dimension contentPaneSize)
Draws and return the TabbedPane cell component (renderer) according to each tab orientation, the borders are getting draws.

Specified by:
getTabbedPaneCell in class LookAndFeel
Parameters:
tp - the TabbedPane
text - the cell text
icon - the cell icon image
isSelected - is the cell is the selected one
cellHasFocus - is the cell has focus
cellStyle - the cell Style object
tabbedPaneStyle - the TabbedPane Style object
cellOffsetX - the offset when the cell is on TOP or BOTTOM orientation
cellOffsetY - the offset when the cell is on LEFT or RIGHT orientation
cellsPreferredSize - the total cells PreferredSize
contentPaneSize - the contentPaneSize
Returns:
A TabbedPane cell component

drawTabbedPaneContentPane

public void drawTabbedPaneContentPane(TabbedPane tp,
                                      Graphics g,
                                      Rectangle rect,
                                      Dimension cellsPreferredSize,
                                      int numOfTabs,
                                      int selectedTabIndex,
                                      Dimension tabsSize,
                                      int cellOffsetX,
                                      int cellOffsetY)
Draws and return the TabbedPane content pane painter.

Specified by:
drawTabbedPaneContentPane in class LookAndFeel
Parameters:
tp - the TabbedPane
g - the content pane graphics
rect - the content pane painting rectangle area
cellsPreferredSize - the total cells PreferredSize
numOfTabs - number of tabs
selectedTabIndex - the selected tab index
tabsSize - the tabs size
cellOffsetX - the offset when the cell is on TOP or BOTTOM orientation
cellOffsetY - the offset when the cell is on LEFT or RIGHT orientation

drawTextField

public void drawTextField(Graphics g,
                          TextField 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.

Specified by:
drawTextField in class LookAndFeel
Parameters:
g - the Graphics object
ta - the text field

getTextFieldPreferredSize

public Dimension getTextFieldPreferredSize(TextField ta)
Returns the preferred size for the text field.

Specified by:
getTextFieldPreferredSize in class LookAndFeel
Parameters:
ta - the text field
Returns:
the preferred size for the text field

drawTextFieldCursor

public void drawTextFieldCursor(Graphics g,
                                TextField ta)
Draws the cursor of the text field, blinking is handled simply by avoiding a call to this method.

Specified by:
drawTextFieldCursor in class LookAndFeel
Parameters:
g - the Graphics object
ta - the text field

focusGained

public void focusGained(Component cmp)
Invoked when component gains focus.

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

focusLost

public void focusLost(Component cmp)
Invoked when component loses focus.

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

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.