Java examples for Swing:JComponent
strech Swing Item To Component
//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)); } }