1 package org.ozoneDB.adminGui.widget; 9 10 import org.ozoneDB.adminGui.res.Settings; 11 12 import javax.swing.*; 13 import javax.swing.border.Border ; 14 import java.awt.*; 15 16 19 public class TitledPanel extends JPanel { 20 21 public TitledPanel(String title, Color lineColor, int thickness) { 22 this(new BorderLayout(), title, lineColor, thickness); 23 } 24 25 public TitledPanel(String title) { 26 this(new BorderLayout(), title, Settings.COLOR_COBALT, 2); 27 } 28 29 public TitledPanel(LayoutManager manager, String title) { 30 this(manager, title, Settings.COLOR_COBALT, 2); 31 } 32 33 public TitledPanel(LayoutManager manager, String title, Color lineColor, int thickness) { 34 super(manager); 35 setBorder(createTitledBorder(title, lineColor, thickness)); 36 } 37 38 private Border createTitledBorder(String title, Color lineColor, int thickness) { 39 40 StringBuffer titleBuf = new StringBuffer (); 41 titleBuf.append(" "); 42 titleBuf.append(title); 43 titleBuf.append(" "); 44 45 Border border = BorderFactory.createLineBorder(lineColor, thickness); 46 return BorderFactory.createTitledBorder(border, titleBuf.toString()); 47 } 48 49 50 } 51 | Popular Tags |