HorizontalLayout.java
资源名称:src.zip [点击查看]
上传用户:luxiaowei
上传日期:2022-06-06
资源大小:58k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- /*
- * HorizontalLayout.java
- *
- * Created on April 22, 2010, 1:04 PM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
- package com.framework;
- /**
- *
- * @author Tejaswi
- */
- public class HorizontalLayout implements Layout{
- public static final int STRETCH_NONE = 0;
- public static final int STRETCH_EQUAL = 1;
- private int stretchInfo,padding,startX,startY;
- /** Creates a new instance of HorizontalLayout */
- public HorizontalLayout(int stretchInfo,int startX,int startY,int padding) {
- this.stretchInfo = stretchInfo;
- this.padding = padding;
- this.startX = startX;
- this.startY = startY;
- }
- public void applyLayout(ScrollableContainer container) {
- int containerWidth = container.getWidth() ;
- if(container.isScrollBarPresent())
- {
- containerWidth -= ScrollableContainer.SCROLL_BAR_WIDTH;
- }
- int tmpX = startX;
- for (int i = 0; i < container.childrens.size(); i++) {
- UIControl control = (UIControl)container.childrens.elementAt(i);
- if(stretchInfo == STRETCH_EQUAL)
- {
- control.setWidth(containerWidth / container.childrens.size());
- }
- control.setX(tmpX);
- control.setY(startY);
- tmpX += control.getWidth() + padding;
- }
- }
- }