swing-FlowLayout垂直布局

更新时间:2023-05-22 01:36:21 阅读: 评论:0

swing-FlowLayout垂直布局package layout;
重量英语import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Ints;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
* VerticalFlowLayout is similar to FlowLayout except it lays out components
* vertically. Extends FlowLayout becau it mimics much of the behavior of the
* FlowLayout class, except vertically. An additional feature is that you can
* specify a fill to edge flag, which caus the VerticalFlowLayout manager to
* resize all components to expand to the column width Warning: This caus
* problems when the main panel has less space that it needs and it ems to
* prohibit multi-column output. Additionally there is a vertical fill flag,
* which fills the last component to the remaining height of the container.
*/
public class VFlowLayout extends FlowLayout
{
/**
*
*/
private static final long rialVersionUID = 1L;
/**
* Specify alignment top.
*/
public static final int TOP = 0;
/**
* Specify a middle alignment.
*/
public static final int MIDDLE = 1;
/**
* Specify the alignment to be bottom.
*/
public static final int BOTTOM = 2;
int hgap;
int vgap;
boolean hfill;
boolean vfill;
public static void main(String[] args)
{
System.out.println("Just for test ...");
JFrame frame = new JFrame();
frame.tDefaultCloOperation(JFrame.EXIT_ON_CLOSE);
frame.tBounds(0, 0, 600, 600);
frame.tLayout(new VFlowLayout());
int i = 0;
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
数据通信工程师frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.add(new JButton(String.valueOf(i++)));
frame.tVisible(true);
}
/**
* Construct a new VerticalFlowLayout with a middle alignment, and the fill  * to edge flag t.
*/
public VFlowLayout()
{
this(TOP, 5, 5, true, fal);
}
/**
* Construct a new VerticalFlowLayout with a middle alignment.
*
* @param hfill
*            the fill to edge flag
* @param vfill
*            the vertical fill in pixels.
*/
public VFlowLayout(boolean hfill, boolean vfill)
{
this(TOP, 5, 5, hfill, vfill);
}
/**
* Construct a new VerticalFlowLayout with a middle alignment.
*
* @param align
*            the alignment value
*/
public VFlowLayout(int align)
{
this(align, 5, 5, true, fal);
}
/**
* Construct a new VerticalFlowLayout.
*
* @param align
*            the alignment value
* @param hfill
*            the horizontalfill in pixels.
* @param vfill
*            the vertical fill in pixels.
*/
public VFlowLayout(int align, boolean hfill, boolean vfill)
{
this(align, 5, 5, hfill, vfill);
}
/**
* Construct a new VerticalFlowLayout.
*
* @param align
*            the alignment value
* @param hgap
印度尼西亚英文*            the horizontal gap variable
* @param vgap
*            the vertical gap variable
* @param hfill
*            the fill to edge flag
* @param vfill
*            true if the panel should vertically fill.
*/
public VFlowLayout(int align, int hgap, int vgap, boolean hfill, boolean vfill) {
tAlignment(align);
this.hgap = hgap;
this.vgap = vgap;
this.hfill = hfill;
this.vfill = vfill;
}
/**
* Returns the preferred dimensions given the components in the target  * container.
*
* @param target
*            the component to lay out
*/
public Dimension preferredLayoutSize(Container target)
{
Dimension tarsiz = new Dimension(0, 0);
for (int i = 0; i < ComponentCount(); i++)
{
Component m = Component(i);
if (m.isVisible())
{
Dimension d = m.getPreferredSize();
tarsiz.width = Math.max(tarsiz.width, d.width);
if (i > 0)
{
tarsiz.height += hgap;
}
tarsiz.height += d.height;
}
}突然头晕是什么原因
Ints ints = Ints();
tarsiz.width += ints.left + ints.right + hgap * 2;
tarsiz.height += p + ints.bottom + vgap * 2;
return tarsiz;
}
/**
* Returns the minimum size needed to layout the target container.
*
* @param target
*            the component to lay out.
* @return the minimum layout dimension.
*/
public Dimension minimumLayoutSize(Container target)
{
Dimension tarsiz = new Dimension(0, 0);
for (int i = 0; i < ComponentCount(); i++)
{
Component m = Component(i);
if (m.isVisible())
{
Dimension d = m.getMinimumSize();
tarsiz.width = Math.max(tarsiz.width, d.width);
if (i > 0)
{
tarsiz.height += vgap;
}
tarsiz.height += d.height;
}
}胃溃疡治疗
Ints ints = Ints();
tarsiz.width += ints.left + ints.right + hgap * 2;
tarsiz.height += p + ints.bottom + vgap * 2;
return tarsiz;
}
/**
* Set true to fill vertically.
*
* @param vfill
*            true to fill vertically.
*/
public void tVerticalFill(boolean vfill)
{
this.vfill = vfill;
}
/**
* Returns true if the layout vertically fills.
*
* @return true if vertically fills the layout using the specified.  */
public boolean getVerticalFill()
{
return vfill;
}
/**
* Set to true to enable horizontally fill.
*
* @param hfill
*            true to fill horizontally.
*/
public void tHorizontalFill(boolean hfill)
{
this.hfill = hfill;
游戏推广系统
}
/**
* Returns true if the layout horizontally fills.
*
* @return true if horizontally fills.
*/
public boolean getHorizontalFill()
{
return hfill;
/**
* places the components defined by first to last within the target
* container using the bounds box defined.
*
* @param target
*            the container.
* @param x
*            the x coordinate of the area.
* @param y
*            the y coordinate of the area.
* @param width
*            the width of the area.
* @param height
*            the height of the area.
* @param first
*            the first component of the container to place.
* @param last
*            the last component of the container to place.
*/
private void placethem(Container target, int x, int y, int width, int height, int first, int last) {
int align = getAlignment();
if (align == MIDDLE)
{
y += height / 2;
}
if (align == BOTTOM)
{
y += height;
}
for (int i = first; i < last; i++)
{
Component m = Component(i);
Dimension md = m.getSize();
if (m.isVisible())
{
全画幅卡片机
int px = x + (width - md.width) / 2;
m.tLocation(px, y);
y += vgap + md.height;
}
}
}
/**
* Lays out the container.
*
* @param target
*            the container to lay out.
*/
元稹
public void layoutContainer(Container target)
{
Ints ints = Ints();
int maxheight = Size().height - (p + ints.bottom + vgap * 2);
int maxwidth = Size().width - (ints.left + ints.right + hgap * 2);
int numcomp = ComponentCount();
int x = ints.left + hgap, y = 0;
int colw = 0, start = 0;
for (int i = 0; i < numcomp; i++)

本文发布于:2023-05-22 01:36:21,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/922747.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:系统   布局   数据通信   头晕
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图