Java JComponent Padding pad(JComponent component, int w, int h)

Here you can find the source of pad(JComponent component, int w, int h)

Description

pad

License

Creative Commons License

Declaration

public static void pad(JComponent component, int w, int h) 

Method Source Code


//package com.java2s;
/*/*from  ww  w  . ja  va  2 s.c o  m*/
 * CS 106A
 *
 * This instructor-provided file contains utility functions related to GUIs.
 *
 * Author : Marty Stepp
 * Version: Tue 2014/06/05
 * 
 * This file and its contents are copyright (C) Stanford University and Marty Stepp,
 * licensed under Creative Commons Attribution 2.5 License.  All rights reserved.
 */

import java.awt.*;

import javax.swing.*;

public class Main {
    public static void pad(JComponent component, int w, int h) {
        Dimension size = component.getPreferredSize();
        size.width += w;
        size.height += h;
        component.setPreferredSize(size);
    }
}

Related

  1. addPadding(JComponent comp, int topbottom, int leftright)
  2. makePaddedPanel(JComponent aComponent, Insets aInsets)
  3. paint(JComponent jc, int padding)
  4. setComponentHeight(JComponent setme, JComponent getme, int padding)
  5. setLeftPadding(JComponent component, int padding)