Package com.intellij.util.ui
Class UIUtil
java.lang.Object
com.intellij.util.ui.DrawUtil
com.intellij.util.ui.UIUtil
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Colorstatic final Colorstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Patternstatic final Colorstatic final Borderstatic final floatstatic final intstatic final intstatic final Stringstatic final Colorstatic final Colorstatic final Stringstatic final Stringstatic final intstatic final intstatic final Insetsstatic final Insetsstatic final Colorstatic final Stringstatic final Color -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddBorder(JComponent component, Border border) Adds the specified border to the specified component.static voidaddInsets(JComponent component, int top, int left, int bottom, int right) Adds an empty border with the specified insets to the specified component.static voidaddInsets(JComponent component, Insets insets) Adds an empty border with the specified insets to the specified component.static voidaddKeyboardShortcut(JComponent target, AbstractButton button, KeyStroke keyStroke) static StringaddPadding(String html, int hPadding) static voidaddParentChangeListener(Component component, PropertyChangeListener listener) static voidadjustWindowToMinimumSize(Window window) static voidappendColor(Color color, StringBuilder sb) static voidThis method is intended to use when user settings are not accessible yet.static voidapplyStyle(UIUtil.ComponentStyle componentStyle, Component comp) static voidassignMnemonic(String text, Action action) static voidchangeBackGround(Component component, Color background) Avoid blinking while changing background.static voidIt is your responsibility to set correct horizontal align (left in case of UI Designer)static StringconvertSpace2Nbsp(String html) static TimercreateNamedTimer(String name, int delay) static TimercreateNamedTimer(String name, int delay, ActionListener listener) static voidstatic booleanstatic StringdisplayPropertiesToCSS(Font font, Color fg) static voidstatic <T extends JComponent>
TfindComponentOfType(JComponent parent, Class<T> cls) static <T extends JComponent>
List<T> findComponentsOfType(JComponent parent, Class<T> cls) static Componentstatic <T extends Component>
TfindParentByClass(Component c, Class<T> cls) Deprecated.static ComponentfindParentByCondition(Component c, Condition<Component> condition) static Componentstatic intfixComboBoxHeight(int height) static voidstatic Colorstatic ColorDeprecated.use com.intellij.util.ui.UIUtil#getTextFieldBackground()static Windowstatic Colorstatic ColorDeprecated.use getBorderColor insteadstatic ColorDeprecated.static ColorDeprecated.use getBorderColor insteadstatic ColorDeprecated.use getBorderColor insteadstatic Colorstatic ColorgetBoundsColor(boolean focused) static Borderstatic Fontstatic Colorstatic PointgetCenterPoint(Dimension container, Dimension child) static PointgetCenterPoint(Rectangle container, Dimension child) static <T> TgetClientProperty(Object component, Key<T> key) static ObjectgetClientProperty(Object component, Object key) static ColorgetColorAt(Icon icon, int x, int y) static Colorstatic Colorstatic ComboPopupgetComboBoxPopup(JComboBox comboBox) static UIUtil.ComponentStylegetComponentStyle(Component component) Calculates a component style from the corresponding client property.static Colorstatic StringgetCssFontDeclaration(Font font) static StringgetCssFontDeclaration(Font font, Color fgColor, Color linkColor, String liImg) static ImagegetDebugImage(Component component) static Stringstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic FontgetFont(UIUtil.FontSize size, Font base) static floatgetFontSize(UIUtil.FontSize size) static GrayFilterstatic Stringstatic Colorstatic Colorstatic intgetHighestGlyphHeight(String string, Font font, Graphics graphics) static StringgetHtmlBody(String text) static HTMLEditorKitstatic HTMLEditorKitgetHTMLEditorKit(boolean noGapsBetweenParagraphs) static Colorstatic Colorstatic Colorstatic Colorstatic Fontstatic FontgetLabelFont(UIUtil.FontSize size) static ColorgetLabelFontColor(UIUtil.FontColor fontColor) static Colorstatic Colorstatic intstatic Colorstatic ColorgetListBackground(boolean isSelected) static intstatic Insetsstatic intstatic Fontstatic Colorstatic ColorgetListForeground(boolean isSelected) static Colorstatic Colorstatic Colorstatic Insetsstatic PointgetLocationOnScreen(JComponent component) static Fontstatic Colorstatic Objectstatic intstatic Colorstatic Fontstatic ColorDeprecated.use com.intellij.util.ui.UIUtil#getPanelBackground() insteadstatic <T> TgetParentOfType(Class<? extends T> type, Component component) Searches above in the component hierarchy starting from the specified component.static JComponentgetPreferredFocusedComponent(Container container) Returns the first focusable component in the specified container.static IntegergetPropertyMaxGutterIconWidth(String propertyPrefix) static StringgetRealFontFamily(String genericFontFamily) static JRootPanestatic intstatic intgetSelectedButton(ButtonGroup group) static Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic String[]static intgetStringY(String string, Rectangle bounds, Graphics2D g) static Stringstatic Colorstatic Objectstatic Colorstatic ColorgetTableBackground(boolean isSelected) static Colorstatic Colorstatic Borderstatic Colorstatic ColorgetTableForeground(boolean isSelected) static Colorstatic Colorstatic Borderstatic Colorstatic Colorstatic Colorstatic Colorstatic Borderstatic Colorstatic ColorDeprecated.use com.intellij.util.ui.UIUtil#getInactiveTextColor()static Fontstatic Colorstatic Fontstatic Colorstatic Colorstatic Iconstatic Iconstatic Fontstatic Colorstatic ColorgetTreeForeground(boolean selected, boolean hasFocus) static IcongetTreeIcon(boolean expanded) static intstatic intstatic Colorstatic ColorgetTreeSelectionBackground(boolean focused) static Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic WindowReturns the first window ancestor of the component.static Colorstatic booleanhasComponentOfType(Component component, Class<?>... types) Indicates whether the specified component is instance of one of the specified types or it contains an instance of one of the specified types.static booleanstatic booleanhasScrollPane(Component component) Indicates whether the specified component is scrollable or it contains a scrollable content.static voidstatic voidstatic voidinstallComboBoxCopyAction(JComboBox comboBox) static voidinstallPopupMenuBorder(JComponent contentPane) static voidinstallPopupMenuColorAndFonts(JComponent contentPane) static voidinvokeLaterIfNeeded(Runnable runnable) static booleanstatic booleanisActionClick(MouseEvent e, int effectiveType) static booleanisActionClick(MouseEvent e, int effectiveType, boolean allowShift) static booleanisAncestor(Component ancestor, Component descendant) static booleanisClientPropertyTrue(Object component, Object key) static booleanstatic booleanisCloseClick(MouseEvent e, int effectiveType) static booleanisControlKeyDown(MouseEvent mouseEvent) static booleanisDescendingFrom(Component child, Component parent) The main difference from javax.swing.SwingUtilities#isDescendingFrom(Component, Component) is that this method uses getInvoker() instead of getParent() when it meets JPopupMenustatic booleanisDialogRootPane(JRootPane rootPane) static booleanisFocusable(JComponent component) static booleanisFocusAncestor(JComponent component) static booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanisValidFont(Font font) static booleanstatic voidmaybeInstall(InputMap map, String action, KeyStroke stroke) static Colorstatic voidpump()static <T> voidputClientProperty(JComponent component, Key<T> key, T value) static voidstatic voidremoveParentChangeListener(Component component, PropertyChangeListener listener) static voidstatic voidstatic voidsetActionNameAndMnemonic(String text, Action action) static voidsetAutoRequestFocus(Window onWindow, boolean set) static voidsetBackgroundRecursively(Component component, Color bg) static voidsetColumns(JTextComponent textComponent, int columns) static voidsetComboBoxEditorBounds(int x, int y, int width, int height, JComponent editor) static voidsetFocusProxy(JComponent c, boolean isProxy) static voidsetFutureRootPane(JComponent c, JRootPane pane) static voidsetLineStyleAngled(JTree component) static voidsetNotOpaqueRecursively(Component component) static voidsetSelectedButton(ButtonGroup group, int index) static voidsetSliderIsFilled(JSlider slider, boolean value) static voidsetupEnclosingDialogBounds(JComponent component) static Colorstatic voidsuppressFocusStealing(Window window) static Colorstatic voidPlaces the specified window at the top of the stacking order and shows it in front of any other windows.static Stringstatic StringMethods inherited from class com.intellij.util.ui.DrawUtil
createImage, createImageForGraphics, drawBoldDottedLine, drawDottedLine, drawDottedRectangle, drawDoubleSpaceDottedLine, drawFramingLines, drawGradientHToolbarBackground, drawHDottedLine, drawHeader, drawHeader, drawImage, drawImage, drawImage, drawLine, drawLine, drawLinePickedOut, drawRectPickedOut, drawSearchMatch, drawSearchMatch, drawStringWithHighlighting, drawVDottedLine, getGradientPaint, getPanelBackground, isAppleRetina, isRetina, isRetina, isUnderDarcula, isUnderIntelliJLaF, paintWithXorOnRetina, paintWithXorOnRetina, setupComponentAntialiasing, setupComposite
-
Field Details
-
BORDER_LINE
- See Also:
-
HTML_MIME
- See Also:
-
JSLIDER_ISFILLED
- See Also:
-
ARIAL_FONT_NAME
- See Also:
-
TABLE_FOCUS_CELL_BACKGROUND_PROPERTY
- See Also:
-
CENTER_TOOLTIP_DEFAULT
- See Also:
-
CENTER_TOOLTIP_STRICT
- See Also:
-
CLOSE_TAG_PATTERN
-
FOCUS_PROXY_KEY
- See Also:
-
KEEP_BORDER_SIDES
-
CONTRAST_BORDER_COLOR
-
SIDE_PANEL_BACKGROUND
-
AQUA_SEPARATOR_FOREGROUND_COLOR
-
AQUA_SEPARATOR_BACKGROUND_COLOR
-
TRANSPARENT_COLOR
-
DEFAULT_HGAP
public static final int DEFAULT_HGAP- See Also:
-
DEFAULT_VGAP
public static final int DEFAULT_VGAP- See Also:
-
LARGE_VGAP
public static final int LARGE_VGAP- See Also:
-
PANEL_REGULAR_INSETS
-
PANEL_SMALL_INSETS
-
DEBUG_MARKER_BORDER
-
DEF_SYSTEM_FONT_SIZE
public static final float DEF_SYSTEM_FONT_SIZE- See Also:
-
GTK_AMBIANCE_TEXT_COLOR
-
GTK_AMBIANCE_BACKGROUND_COLOR
-
LIST_FIXED_CELL_HEIGHT
public static final int LIST_FIXED_CELL_HEIGHT- See Also:
-
-
Method Details
-
invokeLaterIfNeeded
-
getMultiClickInterval
public static int getMultiClickInterval() -
applyStyle
public static void applyStyle(@NotNull UIUtil.ComponentStyle componentStyle, @NotNull Component comp) -
getGrayFilter
-
hasLeakingAppleListeners
public static boolean hasLeakingAppleListeners() -
removeLeakingAppleListeners
public static void removeLeakingAppleListeners() -
isClientPropertyTrue
- Parameters:
component- a Swing component that may hold a client property valuekey- the client property key- Returns:
trueif the property of the specified component is set totrue
-
getClientProperty
- Parameters:
component- a Swing component that may hold a client property valuekey- the client property key that specifies a return type- Returns:
- the property value from the specified component or
null
-
getClientProperty
- Parameters:
component- a Swing component that may hold a client property valuekey- the client property key that specifies a return type- Returns:
- the property value from the specified component or
null
-
putClientProperty
public static <T> void putClientProperty(@NotNull JComponent component, @NotNull Key<T> key, T value) -
getHtmlBody
-
isReallyTypedEvent
-
getStringY
-
getHighestGlyphHeight
public static int getHighestGlyphHeight(@NotNull String string, @NotNull Font font, @NotNull Graphics graphics) - Parameters:
string-Stringto examinefont-Fontthat is used to render the stringgraphics-Graphicsthat should be used to render the string- Returns:
- height of the tallest glyph in a string. If string is empty, returns 0
-
setActionNameAndMnemonic
-
assignMnemonic
-
getLabelFont
-
getFont
-
getFontSize
-
getLabelFontColor
-
getScrollBarWidth
public static int getScrollBarWidth() -
getLabelFont
-
getLabelBackground
-
getLabelForeground
-
getLabelDisabledForeground
-
getTableHeaderBackground
-
getTreeTextForeground
-
getTreeSelectionBackground
-
getTreeTextBackground
-
getListSelectionForeground
-
getFieldForegroundColor
-
getTableSelectionBackground
-
getActiveTextColor
-
getInactiveTextColor
-
getSlightlyDarkerColor
-
getActiveTextFieldBackgroundColor
Deprecated.use com.intellij.util.ui.UIUtil#getTextFieldBackground() -
getInactiveTextFieldBackgroundColor
-
getTreeFont
-
getListFont
-
getTreeSelectionForeground
-
getTreeForeground
-
getTextInactiveTextColor
Deprecated.use com.intellij.util.ui.UIUtil#getInactiveTextColor() -
installPopupMenuColorAndFonts
-
installPopupMenuBorder
-
getTreeSelectionBorderColor
-
getTreeRightChildIndent
public static int getTreeRightChildIndent() -
getTreeLeftChildIndent
public static int getTreeLeftChildIndent() -
getToolTipBackground
-
getToolTipForeground
-
getComboBoxDisabledForeground
-
getComboBoxDisabledBackground
-
getButtonSelectColor
-
getPropertyMaxGutterIconWidth
-
getMenuItemDisabledForeground
-
getMenuItemDisabledForegroundObject
-
getTabbedPanePaintContentBorder
-
isMenuCrossMenuMnemonics
public static boolean isMenuCrossMenuMnemonics() -
getTableBackground
-
getTableBackground
-
getTableSelectionForeground
-
getTableForeground
-
getTableForeground
-
getTableGridColor
-
getListBackground
-
getListBackground
-
getListForeground
-
getListForeground
-
getEditorPaneBackground
-
getTreeBackground
-
getTreeForeground
-
getTableFocusCellBackground
-
getListSelectionBackground
-
getListUnfocusedSelectionBackground
-
getTreeSelectionBackground
-
getTreeUnfocusedSelectionBackground
-
getTextFieldForeground
-
getTextFieldBackground
-
getButtonFont
-
getToolTipFont
-
getTabbedPaneBackground
-
setSliderIsFilled
-
getLabelTextForeground
-
getControlColor
-
getOptionPaneMessageFont
-
getMenuFont
-
getSeparatorForeground
-
getSeparatorBackground
-
getSeparatorShadow
-
getSeparatorHighlight
-
getSeparatorColorUnderNimbus
-
getSeparatorColor
-
getTableFocusCellHighlightBorder
-
setLineStyleAngled
-
getTableFocusCellForeground
-
getPanelBackgound
Deprecated.use com.intellij.util.ui.UIUtil#getPanelBackground() instead -
getTextFieldBorder
-
getButtonBorder
-
getTreeCollapsedIcon
-
getTreeExpandedIcon
-
getTreeIcon
-
getTableHeaderCellBorder
-
getWindowColor
-
getTextAreaForeground
-
getOptionPaneBackground
-
isUnderAlloyLookAndFeel
public static boolean isUnderAlloyLookAndFeel() -
isUnderAlloyIDEALookAndFeel
public static boolean isUnderAlloyIDEALookAndFeel() -
isUnderWindowsLookAndFeel
public static boolean isUnderWindowsLookAndFeel() -
isUnderWindowsClassicLookAndFeel
public static boolean isUnderWindowsClassicLookAndFeel() -
isUnderNimbusLookAndFeel
public static boolean isUnderNimbusLookAndFeel() -
isUnderAquaLookAndFeel
public static boolean isUnderAquaLookAndFeel() -
isUnderJGoodiesLookAndFeel
public static boolean isUnderJGoodiesLookAndFeel() -
isUnderAquaBasedLookAndFeel
public static boolean isUnderAquaBasedLookAndFeel() -
isUnderGTKLookAndFeel
public static boolean isUnderGTKLookAndFeel() -
getGtkThemeName
-
isMurrineBasedTheme
public static boolean isMurrineBasedTheme() -
shade
-
mix
-
isFullRowSelectionLAF
public static boolean isFullRowSelectionLAF() -
isUnderNativeMacLookAndFeel
public static boolean isUnderNativeMacLookAndFeel() -
getListCellHPadding
public static int getListCellHPadding() -
getListCellVPadding
public static int getListCellVPadding() -
getListCellPadding
-
getListViewportPadding
-
isToUseDottedCellBorder
public static boolean isToUseDottedCellBorder() -
isControlKeyDown
-
getStandardFontSizes
-
isValidFont
-
setupEnclosingDialogBounds
-
displayPropertiesToCSS
-
appendColor
-
applyRenderingHints
This method is intended to use when user settings are not accessible yet. Use it to set up default RenderingHints.- Parameters:
g-
-
dispatchAllInvocationEvents
- See Also:
-
dispatchInvocationEvent
-
pump
- See Also:
-
addParentChangeListener
public static void addParentChangeListener(@NotNull Component component, @NotNull PropertyChangeListener listener) -
removeParentChangeListener
public static void removeParentChangeListener(@NotNull Component component, @NotNull PropertyChangeListener listener) -
isFocusAncestor
-
isCloseClick
-
isCloseClick
-
isActionClick
-
isActionClick
-
isActionClick
-
getBgFillColor
-
findNearestOpaque
-
findParentByCondition
-
findParentByClass
@Deprecated public static <T extends Component> T findParentByClass(@NotNull Component c, Class<T> cls) Deprecated. -
getCssFontDeclaration
-
getCssFontDeclaration
-
isWinLafOnVista
public static boolean isWinLafOnVista() -
isStandardMenuLAF
public static boolean isStandardMenuLAF() -
getFocusedFillColor
-
getFocusedBoundsColor
-
getBoundsColor
-
getBoundsColor
-
toAlpha
-
isFocusable
- Parameters:
component- to check whether it can be focused or not- Returns:
trueif component is notnulland can be focused- See Also:
-
requestFocus
-
dispose
-
findUltimateParent
-
getHeaderActiveColor
-
getHeaderInactiveColor
-
getBorderColor
Deprecated. -
getTitledBorderFont
-
getBorderInactiveColor
Deprecated.use getBorderColor instead -
getBorderActiveColor
Deprecated.use getBorderColor instead -
getBorderSeparatorColor
Deprecated.use getBorderColor instead -
getHTMLEditorKit
-
getHTMLEditorKit
-
getCenterPoint
-
getCenterPoint
-
toHtml
-
toHtml
-
addPadding
-
convertSpace2Nbsp
-
isFocusProxy
-
setFocusProxy
-
maybeInstall
-
changeBackGround
Avoid blinking while changing background.- Parameters:
component- component.background- new background.
-
getSystemLookAndFeelClassName
-
initDefaultLAF
public static void initDefaultLAF() -
initSystemFontData
public static void initSystemFontData() -
getSystemFontData
-
addKeyboardShortcut
public static void addKeyboardShortcut(JComponent target, AbstractButton button, KeyStroke keyStroke) -
installComboBoxCopyAction
-
getComboBoxPopup
-
fixFormattedField
-
isPrinting
-
getSelectedButton
-
setSelectedButton
-
isSelectionButtonDown
-
setComboBoxEditorBounds
-
fixComboBoxHeight
public static int fixComboBoxHeight(int height) -
isDescendingFrom
The main difference from javax.swing.SwingUtilities#isDescendingFrom(Component, Component) is that this method uses getInvoker() instead of getParent() when it meets JPopupMenu- Parameters:
child- child componentparent- parent component- Returns:
- true if parent if a top parent of child, false otherwise
- See Also:
-
getParentOfType
@Nullable public static <T> T getParentOfType(@NotNull Class<? extends T> type, Component component) Searches above in the component hierarchy starting from the specified component. Note that the initial component is also checked.- Parameters:
type- expected classcomponent- initial component- Returns:
- a component of the specified type, or
nullif the search is failed - See Also:
-
scrollListToVisibleIfNeeded
-
findComponentOfType
@Nullable public static <T extends JComponent> T findComponentOfType(JComponent parent, Class<T> cls) -
findComponentsOfType
-
getRootPane
-
setFutureRootPane
-
isMeaninglessFocusOwner
-
createNamedTimer
-
createNamedTimer
-
isDialogRootPane
-
setNotOpaqueRecursively
-
setBackgroundRecursively
-
addInsets
public static void addInsets(@NotNull JComponent component, int top, int left, int bottom, int right) Adds an empty border with the specified insets to the specified component. If the component already has a border it will be preserved.- Parameters:
component- the component to which border addedtop- the inset from the topleft- the inset from the leftbottom- the inset from the bottomright- the inset from the right
-
addInsets
Adds an empty border with the specified insets to the specified component. If the component already has a border it will be preserved.- Parameters:
component- the component to which border addedinsets- the top, left, bottom, and right insets
-
adjustWindowToMinimumSize
-
getColorAt
-
addBorder
Adds the specified border to the specified component. If the component already has a border it will be preserved. If component or border is not specified nothing happens.- Parameters:
component- the component to which border addedborder- the border to add to the component
-
getDecoratedRowColor
-
getLocationOnScreen
-
getActiveWindow
-
suppressFocusStealing
-
setAutoRequestFocus
-
getDebugText
-
isAncestor
-
getRealFontFamily
-
configureNumericFormattedTextField
It is your responsibility to set correct horizontal align (left in case of UI Designer) -
getWindow
Returns the first window ancestor of the component. Note that this method returns the component itself if it is a window.- Parameters:
component- the component used to find corresponding window- Returns:
- the first window ancestor of the component; or
nullif the component is not a window and is not contained inside a window
-
toFront
Places the specified window at the top of the stacking order and shows it in front of any other windows. If the window is iconified it will be shown anyway.- Parameters:
window- the window to activate
-
getDebugImage
-
hasScrollPane
Indicates whether the specified component is scrollable or it contains a scrollable content. -
hasComponentOfType
Indicates whether the specified component is instance of one of the specified types or it contains an instance of one of the specified types. -
setColumns
-
getPreferredFocusedComponent
Returns the first focusable component in the specified container. This method returnsnullif container isnull, or if focus traversal policy cannot be determined, or if found focusable component is not aJComponent.- Parameters:
container- a container whose first focusable component is to be returned- Returns:
- the first focusable component or
nullif it cannot be found
-
getComponentStyle
Calculates a component style from the corresponding client property. The key "JComponent.sizeVariant" is used by Apple's Linvalid input: '&F' to scale components.- Parameters:
component- a component to process- Returns:
- a component style of the specified component
-
getLcdContrastValue
public static int getLcdContrastValue()
-