1 19 20 package com.sshtools.ui.awt; 21 22 import java.awt.Color ; 23 import java.awt.Graphics ; 24 import java.awt.Insets ; 25 import java.awt.LayoutManager ; 26 import java.awt.Panel ; 27 28 public class BorderPanel extends Panel { 29 Insets insets; 30 Color borderColor; 31 32 public BorderPanel() { 33 super(); 34 init(); 35 } 36 37 public BorderPanel(LayoutManager layout) { 38 super(layout); 39 init(); 40 } 41 42 void init() { 43 insets = new Insets (1, 1, 1, 1); 44 } 45 46 public void setBorderColor(Color c) { 47 borderColor = c; 48 repaint(); 49 } 50 51 public void paint(Graphics g) { 52 if (borderColor != null) { 53 g.setColor(borderColor); 54 g.drawRect(0, 0, getSize().width - 1, getSize().height - 1); 55 } 56 super.paint(g); 57 } 58 59 public Insets getInsets() { 60 return borderColor == null ? super.getInsets() : insets; 61 } 62 } | Popular Tags |