Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Component;
import java.awt.Dimension;

public class Main {
    /** Sets preferred width of the component, leaving the height intact. */
    public static void setPreferredWidth(Component component, int width) {
        Dimension dim = component.getPreferredSize();
        component.setPreferredSize(new Dimension(width, dim.height));
    }
}