1 /******************************************************************************* 2 * Copyhacked (H) 2012-2020. 3 * This program and the accompanying materials 4 * are made available under no term at all, use it like 5 * you want, but share and discuss about it 6 * every time possible with every body. 7 * 8 * Contributors: 9 * ron190 at ymail dot com - initial implementation 10 ******************************************************************************/ 11 package com.jsql.view.swing.scrollpane; 12 13 import com.jsql.view.swing.util.UiUtil; 14 15 import javax.swing.*; 16 import java.awt.*; 17 18 /** 19 * Scroller with border. 20 */ 21 public class JScrollPanePixelBorder extends JScrollPane { 22 23 /** 24 * Create a scrollpane with top and left border for default component and a slide one. 25 * A component slided to the right will normally hide the left border, JScrollPanePixelBorder fix this. 26 * @param c Component to decorate with a scroll 27 */ 28 public JScrollPanePixelBorder(Component c) { 29 30 super(c); 31 32 this.setBorder(BorderFactory.createMatteBorder(1, 1, 0, 0, UiUtil.COLOR_COMPONENT_BORDER)); 33 this.setViewportBorder(BorderFactory.createMatteBorder(1, 1, 0, 0, UiUtil.COLOR_COMPONENT_BORDER)); 34 } 35 36 /** 37 * A scrollpane with custom borders 38 * @param top Border top size 39 * @param left Border left size 40 * @param bottom Border bottom size 41 * @param right Border right size 42 * @param c Component to decorate 43 */ 44 public JScrollPanePixelBorder(int top, int left, int bottom, int right, Component c) { 45 46 this(c); 47 48 this.setBorder(BorderFactory.createMatteBorder(top, 0, bottom, 0, UiUtil.COLOR_COMPONENT_BORDER)); 49 this.setViewportBorder(BorderFactory.createMatteBorder(0, left, 0, right, UiUtil.COLOR_COMPONENT_BORDER)); 50 } 51 }