Package org.pushingpixels.lafwidget
Class LafWidgetSupport
- java.lang.Object
-
- org.pushingpixels.lafwidget.LafWidgetSupport
-
public class LafWidgetSupport extends Object
LAF-specific support for widgets. Each LAF should override relevant functions based on the internal implementation. Note that ifLafWidgetRepository.setLafSupport(LafWidgetSupport)is called with a custom implementation, that implementation should not throw exceptions in any function.
-
-
Constructor Summary
Constructors Constructor Description LafWidgetSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IcongetArrowIcon(int orientation)Returns the arrow icon (the icon used in combo box drop button, scroll bar buttons etc.).JComponentgetComponentForHover(JInternalFrame.JDesktopIcon desktopIcon)Returns the component for desktop icon hover (internal frame preview) functionality.IcongetLockIcon(Component c)Returns the lock icon.intgetLookupButtonSize()Returns the size of the lookup button.intgetLookupIconSize()Returns the size of the lookup icon.IcongetNumberIcon(int number)Returns the icon that matches the specified number.intgetRolloverTabIndex(JTabbedPane tabbedPane)Returns the index of the rollover tab in the specified tabbed pane.IcongetSearchIcon(int dimension, ComponentOrientation componentOrientation)Returns the search icon that matches the specified parameters.InsetsgetTabAreaInsets(JTabbedPane tabbedPane)Returns the tab area insets for the specified tabbed pane.Is used in theTabOverviewDialogWidgetwidget.RectanglegetTabRectangle(JTabbedPane tabbedPane, int tabIndex)Returns the tab rectangle for the specified tab in a tabbed pane.Is used in theTabHoverPreviewWidgetwidget.booleanhasLockIcon(Component comp)Checks whether the specified component should show a lock icon.voidmarkButtonAsFlat(AbstractButton button)Marks the specified button asflat.voidpaintPasswordStrengthMarker(Graphics g, int x, int y, int width, int height, LafConstants.PasswordStrength pStrength)Paints password strength marker.voidsetTabAreaInsets(JTabbedPane tabbedPane, Insets tabAreaInsets)Sets the tab area insets for the specified tabbed pane.booleantoInstallExtraElements(Component comp)Returns indication whether additional functionality should be installed on the specified component.booleantoInstallMenuSearch(JMenuBar menuBar)Returns indication whether the menu search functionality should be installed on the specified menu bar.
-
-
-
Method Detail
-
getComponentForHover
public JComponent getComponentForHover(JInternalFrame.JDesktopIcon desktopIcon)
Returns the component for desktop icon hover (internal frame preview) functionality. Is used in theDesktopIconHoverPreviewWidgetwidget.- Parameters:
desktopIcon- Desktop icon.- Returns:
- The component for desktop icon hover (internal frame preview) functionality.
-
toInstallMenuSearch
public boolean toInstallMenuSearch(JMenuBar menuBar)
Returns indication whether the menu search functionality should be installed on the specified menu bar. Is used in theMenuSearchWidgetwidget.- Parameters:
menuBar- Menu bar.- Returns:
trueif the menu search functionality should be installed on the specified menu bar,falseotherwise.
-
toInstallExtraElements
public boolean toInstallExtraElements(Component comp)
Returns indication whether additional functionality should be installed on the specified component.- Parameters:
comp- Component.- Returns:
trueif additional functionality should be installed on the specified component,falseotherwise.
-
getSearchIcon
public Icon getSearchIcon(int dimension, ComponentOrientation componentOrientation)
Returns the search icon that matches the specified parameters. Is used in theMenuSearchWidgetwidget.- Parameters:
dimension- Search icon dimension.componentOrientation- The orientation for the search icon. Should be considered in the implementation code for proper RTL support.- Returns:
- The search icon that matches the specified parameters.
-
getNumberIcon
public Icon getNumberIcon(int number)
Returns the icon that matches the specified number. This function is used inMenuSearchWidgetto set icons on menu search results. See default implementation inLafWidgetUtilities.getHexaMarker(int)that returns binary-based icons for numbers from 0 to 15. Is used in theMenuSearchWidgetwidget.- Parameters:
number- Number.- Returns:
- The icon that matches the specified number.
-
markButtonAsFlat
public void markButtonAsFlat(AbstractButton button)
Marks the specified button asflat. A flat button doesn't show its background unless selected, armed, pressed or (possibly) hovered over. Some LAFs have flat buttons on toolbars. Is used inMenuSearchWidgetandTabOverviewDialogWidgetwidgets.- Parameters:
button- Button to mark as flat.
-
getRolloverTabIndex
public int getRolloverTabIndex(JTabbedPane tabbedPane)
Returns the index of the rollover tab in the specified tabbed pane. Is used in theTabHoverPreviewWidgetwidget.- Parameters:
tabbedPane- Tabbed pane.- Returns:
- The index of the rollover tab in the specified tabbed pane.
- Throws:
UnsupportedOperationException- In the base implementation.
-
setTabAreaInsets
public void setTabAreaInsets(JTabbedPane tabbedPane, Insets tabAreaInsets)
Sets the tab area insets for the specified tabbed pane. Is used in theTabOverviewDialogWidgetwidget.- Parameters:
tabbedPane- Tabbed pane.tabAreaInsets- Tab area insets.- Throws:
UnsupportedOperationException- In the base implementation.
-
getTabAreaInsets
public Insets getTabAreaInsets(JTabbedPane tabbedPane)
Returns the tab area insets for the specified tabbed pane.Is used in theTabOverviewDialogWidgetwidget.- Parameters:
tabbedPane- Tabbed pane.- Returns:
- The tab area insets for the specified tabbed pane.
-
getTabRectangle
public Rectangle getTabRectangle(JTabbedPane tabbedPane, int tabIndex)
Returns the tab rectangle for the specified tab in a tabbed pane.Is used in theTabHoverPreviewWidgetwidget.- Parameters:
tabbedPane- Tabbed pane.tabIndex- Index of a tab.- Returns:
- The tab rectangle for the specified parameters.
- Throws:
UnsupportedOperationException- In the base implementation.
-
paintPasswordStrengthMarker
public void paintPasswordStrengthMarker(Graphics g, int x, int y, int width, int height, LafConstants.PasswordStrength pStrength)
Paints password strength marker. Is used in thePasswordStrengthCheckerWidgetwidget. The default implementation uses orange color forLafConstants.PasswordStrength.WEAKpasswords, yellow color forLafConstants.PasswordStrength.MEDIUMpasswords and green color forLafConstants.PasswordStrength.STRONGpasswords.- Parameters:
g- Graphics context.x- X coordinate for the marker.y- Y coordinate for the marker.width- Marker width.height- Marker height.pStrength- Password strength.
-
hasLockIcon
public boolean hasLockIcon(Component comp)
Checks whether the specified component should show a lock icon. Is used in theLockBorderWidgetwidget.- Parameters:
comp- Component.- Returns:
trueif the specified component should show a lock icon,falseotherwise.
-
getLockIcon
public Icon getLockIcon(Component c)
Returns the lock icon. Is used inLockBorderWidgetwidget.- Returns:
- Lock icon. Should be sufficiently small (preferrably not more than 5-6 pixels wide).
-
getArrowIcon
public Icon getArrowIcon(int orientation)
Returns the arrow icon (the icon used in combo box drop button, scroll bar buttons etc.).- Parameters:
orientation- One ofSwingConstants.NORTHorSwingConstants.SOUTH.- Returns:
- Arrow icon.
-
getLookupIconSize
public int getLookupIconSize()
Returns the size of the lookup icon. Override to handle high DPI mode.- Returns:
- The size of the lookup icon.
-
getLookupButtonSize
public int getLookupButtonSize()
Returns the size of the lookup button. Override to handle high DPI mode.- Returns:
- The size of the lookup button.
-
-