filler.java

来自「开源(Open Source)项目JHotDraw的文档和源程序」· Java 代码 · 共 49 行

JAVA
49
字号
/*
 * @(#)Filler.java 5.2
 *
 */

package CH.ifa.draw.util;

import javax.swing.*;
import java.awt.*;

/**
 * A component that can be used to reserve white space in a layout.
 */


public  class Filler
        extends JPanel {

    private int     fWidth;
    private int     fHeight;
    private Color   fBackground;


    public Filler(int width, int height) {
        this(width, height, null);
    }

    public Filler(int width, int height, Color background) {
        fWidth = width;
        fHeight = height;
        fBackground = background;
    }

    public Dimension getMinimumSize() {
        return new Dimension(fWidth, fHeight);
    }

    public Dimension getPreferredSize() {
        return getMinimumSize();
    }

    public Color getBackground() {
        if (fBackground != null)
            return fBackground;
        return super.getBackground();
    }
}

⌨️ 快捷键说明

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