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

📄 swingutils.java

📁 这是一个经典的程序
💻 JAVA
字号:
package kc.test;

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

/**
 * @author Thomas Neidhart, thomas.neidhart@gmail.com, all rights by Know-Center
 * Date: Aug 3, 2005
 *
 * Helper methods for use with Swing components
 */
public class SwingUtils
{
    /**
     * Add a component to a grid bag layout using several constraints
     * @param panel the panel the component should be added to
     * @param comp the component to be added
     * @param x the x position
     * @param y the y position
     * @param w the width of the component
     * @param h the height of the component
     * @param weightx the weight on the x-axis
     * @param weighty the weight on the y-axis
     */
    public static void addToGridBag(JPanel panel, Component comp,
            int x, int y, int w, int h, double weightx, double weighty) {

        GridBagLayout gbl = (GridBagLayout) panel.getLayout();
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.BOTH;
        c.gridx = x;
        c.gridy = y;
        c.gridwidth = w;
        c.gridheight = h;
        c.weightx = weightx;
        c.weighty = weighty;
        panel.add(comp);
        gbl.setConstraints(comp, c);
    }
}

⌨️ 快捷键说明

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