📄 jcomponent.html
字号:
<TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#getTopLevelAncestor()">Container getTopLevelAncestor()</a> </TD> <TD> Get the topmost container for the component — a <code>Window</code>, <code>Applet</code>, or null if the component hasn't been added to any container.</TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getParent()">Container getParent()</a> </TD> <TD> Get the component's immediate container.</TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#getComponentCount()">int getComponentCount()</a> </TD> <TD> Get the number of components in this container.</TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#getComponent(int)">Component getComponent(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#getComponents()">Component[] getComponents()</a> </TD> <TD> Get the one of or all of the components in this container. The <code>int</code> argument indicates the position of the component to get. </TD> </TR></TABLE><p><TABLE BORDER="1"><caption><a NAME="layoutapi"><b>Laying Out Components</b><br> (see<a class="TutorialLink" target="_top" href="../layout/index.html">Laying Out Components Within a Container</a> for more information)</a></caption><TR> <th> Method </th> <th> Purpose</th> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#setPreferredSize(java.awt.Dimension)">void setPreferredSize(Dimension)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#setMaximumSize(java.awt.Dimension)">void setMaximumSize(Dimension)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#setMinimumSize(java.awt.Dimension)">void setMinimumSize(Dimension)</a> </TD> <TD> Set the component's preferred, maximum, or minimum size, measured in pixels. The preferred size indicates the best size for the component. The component should be no larger than its maximum size and no smaller than its minimum size. Be aware that these are hints only and might be ignored by certain layout managers. </TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getPreferredSize()">Dimension getPreferredSize()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getMaximumSize()">Dimension getMaximumSize()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getMinimumSize()">Dimension getMinimumSize()</a> </TD> <TD> Get the preferred, maximum, or minimum size of the component, measured in pixels. For non-<code>JComponent</code> subclasses, which don't have the corresponding setter methods, you can set a component's preferred, maximum, or minimum size by creating a subclass and overriding these methods. </TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#setAlignmentX(float)">void setAlignmentX(float)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#setAlignmentY(float)">void setAlignmentY(float)</a> </TD> <TD> Set the alignment along the <em>x-</em> or <em>y-</em> axis. These values indicate how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, and 0.5 is centered, and so on. Be aware that these are hints only and might be ignored by certain layout managers. </TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getAlignmentX()">float getAlignmentX()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getAlignmentY()">float getAlignmentY()</a> </TD> <TD> Get the alignment of the component along the <em>x-</em> or <em>y-</em> axis. For non-<code>JComponent</code> subclasses, which don't have the corresponding setter methods, you can set a component's alignment by creating a subclass and overriding these methods. </TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#setLayout(java.awt.LayoutManager)">void setLayout(LayoutManager)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#getLayout()">LayoutManager getLayout()</a> </TD> <TD> Set or get the component's layout manager. The layout manager is responsible for sizing and positioning the components within a container. </TD> </TR> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#applyComponentOrientation(java.awt.ComponentOrientation)">void applyComponentOrientation(ComponentOrientation)</a> </td> <td>Set the <code>ComponentOrientation</code> property of this container and all the components contained within it. See <a class="TutorialLink" target="_top" href="../layout/using.html#orientation">Setting the Container's Orientation</a> for more information. </td> </tr></TABLE><p><TABLE BORDER="1"><caption><A NAME="sizeapi"><b>Getting Size and Position Information</b><br></A></caption><TR> <th> Method </th> <th> Purpose</th> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getWidth()">int getWidth()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getHeight()">int getHeight()</a> </TD> <TD> Get the current width or height of the component measured in pixels.</TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getSize()">Dimension getSize()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getSize(java.awt.Dimension)">Dimension getSize(Dimension)</a> </TD> <TD> Get the component's current size measured in pixels. When using the one-argument version of this method, the caller is responsible for creating the <code>Dimension</code> instance in which the result is returned. </TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getX()">int getX()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getY()">int getY()</a> </TD> <TD> Get the current <em>x</em> or y coordinate of the component's origin relative to the parent's upper left corner measured in pixels. </TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getBounds()">Rectangle getBounds()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getBounds(java.awt.Rectangle)">Rectangle getBounds(Rectangle)</a> </TD> <TD> Get the bounds of the component measured in pixels. The bounds specify the component's width, height, and origin relative to its parent. When using the one-argument version of this method, the caller is responsible for creating the <code>Rectangle</code> instance in which the result is returned.</TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getLocation()">Point getLocation()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getLocation(java.awt.Point)">Point getLocation(Point)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#getLocationOnScreen()">Point getLocationOnScreen()</a> </td> <TD> Gets the current location of the component relative to the parent's upper left corner measured in pixels. When using the one-argument version of <code>getLocation</code> method, the caller is responsible for creating the <code>Point</code> instance in which the result is returned. The <code>getLocationOnScreen</code> method returns the position relative to the upper left corner of the screen.</TD> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#getInsets()">Insets getInsets()</a> </TD> <TD> Get the size of the component's border.</TD> </TR></TABLE><p><TABLE BORDER="1"><caption><A NAME="absoluteapi"><b>Specifying Absolute Size and Position</b><br> (see<a class="TutorialLink" target="_top" href="../layout/none.html">Doing Without a Layout Manager (Absolute Positioning)</a> for more information)</A></caption><TR> <th> Method </th> <th> Purpose</th> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setLocation(int, int)">void setLocation(int, int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setLocation(java.awt.Point)">void setLocation(Point)</a> </TD> <TD> Set the location of the component, in pixels, relative to the parent's upper left corner. The two <code>int</code> arguments specify <em>x</em> and <em>y</em>, in that order. Use these methods to position a component when you aren't using a layout manager.</TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setSize(int, int)">void setSize(int, int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setSize(java.awt.Dimension)">void setSize(Dimension)</a> </TD> <TD> Set the size of the component measured in pixels. The two <code>int</code> arguments specify width and height, in that order. Use these methods to size a component when you aren't using a layout manager.</TD> </TR> <TR> <TD><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setBounds(int, int, int, int)">void setBounds(int, int, int, int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setBounds(java.awt.Rectangle)">void setBounds(Rectangle)</a> </TD> <TD> Set the size and location relative to the parent's upper left corner, in pixels, of the component. The four <code>int</code> arguments specify <em>x</em>, <em>y</em>, width, and height, in that order. Use these methods to position and size a component when you aren't using a layout manager.</TD> </TR></TABLE> </blockquote> <div class=NavBit> <a target=_top href=model.html>« Previous</a> • <a target=_top href=../TOC.html>Trail</a> • <a target=_top href=text.html>Next »</a> </div> </div> <div id=Footer><div id=TagNotes> Problems with the examples? Try <a target="_blank" href=../../information/run-examples.html>Compiling and Running the Examples: FAQs</a>. <br> Complaints? Compliments? Suggestions? <a target="_blank" href="http://developer.sun.com/contact/tutorial_feedback.jsp">Give us your feedback</a>.<br><br> <a target="_blank" href="../../information/copyright.html">Copyright</a> 1995-2006 Sun Microsystems, Inc. All rights reserved. <span id=Download></span></div> </div> <div class=PrintHeaders> <b>Previous page:</b> Using Models <br><b>Next page:</b> Using Text Components </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -