Java JComponent Width adjustNarrowField(final JComponent component, final int width)

Here you can find the source of adjustNarrowField(final JComponent component, final int width)

Description

Adjust the sizes of the specified component to be a narrower field.

License

Open Source License

Parameter

Parameter Description
component a parameter
width a parameter

Declaration


public static void adjustNarrowField(final JComponent component, final int width) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import javax.swing.*;

import java.awt.*;

public class Main {
    public static final int HEIGHT_ROW = 27;
    private static final int WIDTH_NARROW_FIELD = 100;

    /***********************************************************************************************
     * Adjust the sizes of the specified component to be a narrower field.
     */*from  www. j a va2  s .  c o  m*/
     * @param component
     */

    public static void adjustNarrowField(final JComponent component) {
        adjustNarrowField(component, WIDTH_NARROW_FIELD);
    }

    /***********************************************************************************************
     * Adjust the sizes of the specified component to be a narrower field.
     *
     * @param component
     * @param width
     */

    public static void adjustNarrowField(final JComponent component, final int width) {
        component.setMaximumSize(new Dimension(width, HEIGHT_ROW));
        component.setPreferredSize(new Dimension(width, HEIGHT_ROW));
    }
}

Related

  1. addComponent(Container container, JComponent component, int xPos, int yPos, int width, int height, double weightX, double weightY, int insetTop, int insetLeft, int insetBottom, int insetRight, int anchor, int stretch)
  2. adjustWidth(JComponent aComponent, int aWidth)
  3. allignBottom(JComponent lead, JComponent target, int width, int height)
  4. calculateCharWidth(JComponent component, int numChars)
  5. clearWidth(JComponent comp)