⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stacklayout.java

📁 This is Layout manager for java using swing.
💻 JAVA
字号:
/* * Copyright (C) Jerry Huxtable 1998 */package com.jhlabs.awt;import java.awt.*;public class StackLayout extends ConstraintLayout {	private final static Integer DEFAULT = new Integer(Direction.CENTER);		public StackLayout() {	}	public static Integer alignment(int fill, int alignment) {		return new Integer(fill << 8 | alignment);	}	public void setConstraint(Component c, Object constraint) {		if (constraint == null)			constraint = DEFAULT;		if (!(constraint instanceof Integer))			throw new IllegalArgumentException("Constraint must be an Integer");		super.setConstraint(c, constraint);	}		public void measureLayout(Container target, Dimension dimension, int type)  {		int count = target.getComponentCount();		if (dimension != null) {			for (int i = 0 ; i < count ; i++) {				Component m = target.getComponent(i);				if (m.isVisible()) {					Dimension d = getComponentSize(m, type);					dimension.width = Math.max(d.width, dimension.width);					dimension.height = Math.max(d.height, dimension.height);				}			}		} else {			Insets insets = target.getInsets();			Dimension size = target.getSize();			int w = size.width - (insets.left + insets.right);			int h = size.height - (insets.top + insets.bottom);			Rectangle cell = new Rectangle(insets.left, insets.top, w, h);			for (int i = 0 ; i < count ; i++) {				Component m = target.getComponent(i);				int n = ((Integer)getConstraint(m)).intValue();				int alignment = n & 0xff;				int fill = (n >> 8) & 0xff;				if (m.isVisible()) {					Dimension d = getComponentSize(m, type);					Rectangle r = new Rectangle(0, 0, d.width, d.height);					Alignment.alignInCell(r, cell, alignment, fill);					m.setBounds(r.x, r.y, r.width, r.height);				}			}		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -