資源簡介
Java 制作階梯布局管理器(基礎篇-實例304).zip
代碼片段和文件信息
package?com.mingrisoft.layoutmanager;
import?java.awt.Component;
import?java.awt.Container;
import?java.awt.Dimension;
import?java.awt.Insets;
import?java.awt.LayoutManager;
public?class?LadderLayout?implements?LayoutManager?{
????
????@Override
????public?void?addLayoutComponent(String?name?Component?comp)?{
????}
????
????@Override
????public?void?layoutContainer(Container?parent)?{
????????Insets?insets?=?parent.getInsets();
????????int?maxWidth?=?parent.getWidth()?-?(insets.left?+?insets.right);
????????int?maxHeight?=?parent.getHeight()?-?(insets.top?+?insets.bottom);
????????int?count?=?parent.getComponentCount();
????????for?(int?i?=?0;?i?????????????Component?component?=?parent.getComponent(i);
????????????if?(component.isVisible())?{
????????????????Dimension?size?=?component.getPreferredSize();
????????????????int?x?=?maxWidth?/?count?*?i;
????????????????int?y?=?maxHeight?/?count?*?i;
????????????????component.setBounds(x?y?size
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????232??2010-09-11?17:00??.classpath
?????文件?????????379??2010-09-11?17:00??.project
?????文件????????1979??2013-11-21?08:41??bin\com\mingrisoft\layoutmanager\LadderLayout.class
?????文件?????????843??2013-11-21?08:41??bin\com\mingrisoft\layoutmanager\LadderLayoutTest$1.class
?????文件????????1996??2013-11-21?08:41??bin\com\mingrisoft\layoutmanager\LadderLayoutTest.class
?????文件????????1406??2010-09-11?17:00??src\com\mingrisoft\layoutmanager\LadderLayout.java
?????文件????????1757??2010-09-11?17:00??src\com\mingrisoft\layoutmanager\LadderLayoutTest.java
- 上一篇:Java 驗證IP地址的有效性
- 下一篇:Java 將字符串的每個字符進行倒序輸出
評論
共有 條評論