Java Swing Border repaintBorder(JComponent component)

Here you can find the source of repaintBorder(JComponent component)

Description

repaint Border

License

Open Source License

Declaration

public static void repaintBorder(JComponent component) 

Method Source Code

//package com.java2s;
/*// ww w.  ja  v  a2  s .  com
 * @(#)QuaquaUtilities.java  3.1  2006-09-04
 *
 * Copyright (c) 2003-2006 Werner Randelshofer
 * Staldenmattweg 2, Immensee, CH-6405, Switzerland.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Werner Randelshofer. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Werner Randelshofer.
 */

import java.awt.*;

import javax.swing.*;

import javax.swing.border.*;

public class Main {
    public static void repaintBorder(JComponent component) {
        JComponent c = component;
        Border border = null;
        Container container = component.getParent();
        if (container instanceof JViewport) {
            c = (JComponent) container.getParent();
            if (c != null) {
                border = c.getBorder();
            }
        }
        if (border == null) {
            border = component.getBorder();
            c = component;
        }
        if (border != null && c != null) {
            int w = c.getWidth();
            int h = c.getHeight();
            Insets insets = c.getInsets();
            c.repaint(0, 0, w, insets.top);
            c.repaint(0, 0, insets.left, h);
            c.repaint(0, h - insets.bottom, w, insets.bottom);
            c.repaint(w - insets.right, 0, insets.right, h);
        }
    }
}

Related

  1. installBorder(JComponent c, Border defaultBorder)
  2. isStandardBorder(Border b)
  3. makeTitledBorder(JComponent panel, String title, Color color)
  4. paintBorderDebugInfo(final Graphics g, final JComponent c)
  5. removePopupBorder(final Container c)
  6. repaintBorder(JComponent component)
  7. setBorder(Border b, JComponent... components)
  8. setBorder(JComponent comp, boolean setBorder, Color col)
  9. setBorder(JComponent comp, Border border)