strech Swing Item To Component - Java Swing

Java examples for Swing:JComponent

Description

strech Swing Item To Component

Demo Code


//package com.java2s;

import java.awt.Dimension;

import javax.swing.JComponent;

public class Main {
    public static void strechItemToComponent(JComponent component,
            JComponent item) {/*from  ww  w. ja  v a 2 s  .c  o m*/
        int iWidth = (int) item.getPreferredSize().getWidth();
        int iHeight = (int) component.getPreferredSize().getHeight();
        item.setPreferredSize(new Dimension(iWidth, iHeight));
    }
}

Related Tutorials