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;
/*//from   ww  w.j  a  v  a 2 s  . c  o m
 * @(#)QuaquaUtilities.java  
 *
 * Copyright (c) 2003-2010 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */

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, insets.top, insets.left, h - insets.bottom
                    - insets.top);
            c.repaint(0, h - insets.bottom, w, insets.bottom);
            c.repaint(w - insets.right, insets.top, insets.right, h
                    - insets.bottom - insets.top);
        }
    }
}

Related

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