public class SwingComponentWrapper extends Object implements ComponentWrapper
TYPE_BUTTON, TYPE_CHECK_BOX, TYPE_COMBO_BOX, TYPE_CONTAINER, TYPE_IMAGE, TYPE_LABEL, TYPE_LIST, TYPE_PANEL, TYPE_PROGRESS_BAR, TYPE_SCROLL_BAR, TYPE_SCROLL_PANE, TYPE_SEPARATOR, TYPE_SLIDER, TYPE_SPINNER, TYPE_TABBED_PANE, TYPE_TABLE, TYPE_TEXT_AREA, TYPE_TEXT_FIELD, TYPE_TREE, TYPE_UNKNOWN, TYPE_UNSET| 构造器和说明 |
|---|
SwingComponentWrapper(Component c) |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
equals(Object o) |
int |
getBaseline(int width,
int height)
Returns the baseline for the component given the suggested height.
|
Object |
getComponent()
Returns the actual object that this wrapper is aggregating.
|
int |
getComponentType(boolean disregardScrollPane)
Returns the type of component that this wrapper is wrapping.
|
int |
getContentBias()
Returns in what way the min/pref/max sizes relates to it's height or width for the current settings of the component (like wrapText).
|
int |
getHeight()
Returns the current height for this component.
|
int |
getHorizontalScreenDPI()
Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default
screen if the component is not visible.
|
int |
getLayoutHashCode()
Returns a hash code that should be reasonably different for anything that might change the layout.
|
String |
getLinkId()
Returns a String id that can be used to reference the component in link constraints.
|
int |
getMaximumHeight(int sz)
Returns the maximum height of the component.
|
int |
getMaximumWidth(int sz)
Returns the maximum width of the component.
|
int |
getMinimumHeight(int sz)
Returns the minimum height of the component.
|
int |
getMinimumWidth(int sz)
Returns the minimum width of the component.
|
ContainerWrapper |
getParent()
Returns the container for this component.
|
float |
getPixelUnitFactor(boolean isHor)
Returns the pixel unit factor for the horizontal or vertical dimension.
|
int |
getPreferredHeight(int sz)
Returns the preferred height of the component.
|
int |
getPreferredWidth(int sz)
Returns the preferred width of the component.
|
int |
getScreenHeight()
Returns the pixel size of the screen that the component is currently in or for the default
screen if the component is not visible or
null. |
int |
getScreenLocationX()
Returns the screen x-coordinate for the upper left coordinate of the component layout-able bounds.
|
int |
getScreenLocationY()
Returns the screen y-coordinate for the upper left coordinate of the component layout-able bounds.
|
int |
getScreenWidth()
Returns the pixel size of the screen that the component is currently in or for the default
screen if the component is not visible or
null. |
int |
getVerticalScreenDPI()
Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default
screen if the component is not visible.
|
int[] |
getVisualPadding()
Returns the padding on a component by component basis.
|
int |
getWidth()
Returns the current width for this component.
|
int |
getX()
Returns the current x coordinate for this component.
|
int |
getY()
Returns the current y coordinate for this component.
|
boolean |
hasBaseline()
Returns if the component has a baseline and if it can be retrieved.
|
int |
hashCode() |
static boolean |
isMaxSizeSetOn1_4()
已过时。
Java 1.4 is not supported anymore
|
boolean |
isVisible()
Returns if the component's visibility is set to
true. |
static boolean |
isVisualPaddingEnabled() |
void |
paintDebugOutline(boolean showVisualPadding)
Paints component outline to indicate where it is.
|
void |
setBounds(int x,
int y,
int width,
int height)
Sets the component's bounds.
|
static void |
setMaxSizeSetOn1_4(boolean b)
已过时。
Java 1.4 is not supported anymore
|
static void |
setVisualPaddingEnabled(boolean b) |
public SwingComponentWrapper(Component c)
public final int getBaseline(int width,
int height)
ComponentWrappergetBaseline 在接口中 ComponentWrapperwidth - The width to calculate for if other than the current. If -1 the current size should be used.height - The height to calculate for if other than the current. If -1 the current size should be used.public final Object getComponent()
ComponentWrapperIf this is a container the container should be returned instead.
getComponent 在接口中 ComponentWrappernull.public final float getPixelUnitFactor(boolean isHor)
ComponentWrapperThe factor is 1 for both dimensions on the normal font in a JPanel on Windows. The factor should increase with a bigger "X".
This is the Swing version:
Rectangle2D r = fm.getStringBounds("X", parent.getGraphics());
wFactor = r.getWidth() / 6;
hFactor = r.getHeight() / 13.27734375f;
getPixelUnitFactor 在接口中 ComponentWrapperisHor - If it is the horizontal factor that should be returned.public final int getX()
ComponentWrappergetX 在接口中 ComponentWrapperpublic final int getY()
ComponentWrappergetY 在接口中 ComponentWrapperpublic final int getHeight()
ComponentWrappergetHeight 在接口中 ComponentWrapperpublic final int getWidth()
ComponentWrappergetWidth 在接口中 ComponentWrapperpublic final int getScreenLocationX()
ComponentWrappergetScreenLocationX 在接口中 ComponentWrapperpublic final int getScreenLocationY()
ComponentWrappergetScreenLocationY 在接口中 ComponentWrapperpublic final int getMinimumHeight(int sz)
ComponentWrappergetMinimumHeight 在接口中 ComponentWrappersz - The Size hint for the other dimension. An implementation can use this value or the
current size for the widget in this dimension, or a combination of both, to calculate the correct size.public final int getMinimumWidth(int sz)
ComponentWrappergetMinimumWidth 在接口中 ComponentWrappersz - The Size hint for the other dimension. An implementation can use this value or the
current size for the widget in this dimension, or a combination of both, to calculate the correct size.public final int getPreferredHeight(int sz)
ComponentWrappergetPreferredHeight 在接口中 ComponentWrappersz - The Size hint for the other dimension. An implementation can use this value or the
current size for the widget in this dimension, or a combination of both, to calculate the correct size.public final int getPreferredWidth(int sz)
ComponentWrappergetPreferredWidth 在接口中 ComponentWrappersz - The Size hint for the other dimension. An implementation can use this value or the
current size for the widget in this dimension, or a combination of both, to calculate the correct size.public final int getMaximumHeight(int sz)
ComponentWrappergetMaximumHeight 在接口中 ComponentWrappersz - The Size hint for the other dimension. An implementation can use this value or the
current size for the widget in this dimension, or a combination of both, to calculate the correct size.public final int getMaximumWidth(int sz)
ComponentWrappergetMaximumWidth 在接口中 ComponentWrappersz - The Size hint for the other dimension. An implementation can use this value or the
current size for the widget in this dimension, or a combination of both, to calculate the correct size.public final ContainerWrapper getParent()
ComponentWrappergetParent 在接口中 ComponentWrappernull if the component has no parent.public final int getHorizontalScreenDPI()
ComponentWrapper
If headless mode PlatformDefaults.getDefaultDPI() will be returned.
getHorizontalScreenDPI 在接口中 ComponentWrapperpublic final int getVerticalScreenDPI()
ComponentWrapper
If headless mode PlatformDefaults.getDefaultDPI() will be returned.
getVerticalScreenDPI 在接口中 ComponentWrapperpublic final int getScreenWidth()
ComponentWrappernull.
If in headless mode 1024 is returned.
getScreenWidth 在接口中 ComponentWrapper1280.public final int getScreenHeight()
ComponentWrappernull.
If in headless mode 768 is returned.
getScreenHeight 在接口中 ComponentWrapper1024.public final boolean hasBaseline()
ComponentWrapperfalse for Swing before mustang.hasBaseline 在接口中 ComponentWrapperpublic final String getLinkId()
ComponentWrappernull should be returned.
For instance the Swing implementation returns the string returned from Component.getName().
getLinkId 在接口中 ComponentWrappernull.public final void setBounds(int x,
int y,
int width,
int height)
ComponentWrappersetBounds 在接口中 ComponentWrapperx - The x coordinate.y - The y coordinate.width - The width.height - The height.public boolean isVisible()
ComponentWrappertrue. This should not return if the component is
actually visible, but if the visibility is set to true or not.isVisible 在接口中 ComponentWrappertrue means visible.public final int[] getVisualPadding()
ComponentWrapper
Default implementation returns null for all components except for Windows XP's JTabbedPane which will return new Insets(0, 0, 2, 2).
NOTE! To reduce generated garbage the returned padding should never be changed so that the same insets can be returned many times.
getVisualPadding 在接口中 ComponentWrappernull if no padding. NOTE! To reduce generated garbage the returned padding should never be changed so that
the same insets can be returned many times. [top, left, bottom, right]public static boolean isMaxSizeSetOn1_4()
public static void setMaxSizeSetOn1_4(boolean b)
public static boolean isVisualPaddingEnabled()
public static void setVisualPaddingEnabled(boolean b)
public final void paintDebugOutline(boolean showVisualPadding)
ComponentWrapperpaintDebugOutline 在接口中 ComponentWrappershowVisualPadding - If the visual padding should be shown in the debug drawing.public int getComponentType(boolean disregardScrollPane)
ComponentWrapperThis method can be invoked often so the result should be cached.
getComponentType 在接口中 ComponentWrapperdisregardScrollPane - Is true any wrapping scroll pane should be disregarded and the type
of the scrolled component should be returned.ComponentWrapper.TYPE_LABEL.public int getLayoutHashCode()
ComponentWrappergetLayoutHashCode 在接口中 ComponentWrapperpublic int getContentBias()
ComponentWrapperLayoutUtil.HORIZONTAL
If the min/pref/max width depends on it's height (not common) return LayoutUtil.VERTICAL
If there is no connection between the preferred min/pref/max and the size of the component return -1.getContentBias 在接口中 ComponentWrapperCopyright © 2021. All rights reserved.