1 package org.columba.core.gui.base; 19 20 import java.awt.BorderLayout ; 21 import java.awt.Color ; 22 import java.awt.Dimension ; 23 import java.awt.Graphics ; 24 25 import javax.swing.JComponent ; 26 import javax.swing.JLabel ; 27 import javax.swing.JPanel ; 28 29 import com.jgoodies.forms.layout.CellConstraints; 30 import com.jgoodies.forms.layout.ColumnSpec; 31 import com.jgoodies.forms.layout.FormLayout; 32 33 public class JStatusBar extends JPanel { 34 35 private JPanel contentPanel = new JPanel (); 36 37 private FormLayout layout; 38 39 private int layoutCoordinateX = 2; 40 41 private int layoutCoordinateY = 2; 42 43 public JStatusBar() { 44 45 setLayout(new BorderLayout ()); 46 setPreferredSize(new Dimension (getWidth(), 23)); 47 48 JLabel resizeIconLabel = new JLabel ( 49 new TriangleSquareWindowsCornerIcon()); 50 resizeIconLabel.setOpaque(false); 51 52 JPanel rightPanel = new JPanel (); 53 rightPanel.setOpaque(false); 54 rightPanel.add(resizeIconLabel, BorderLayout.SOUTH); 55 56 add(rightPanel, BorderLayout.EAST); 57 58 contentPanel.setOpaque(false); 59 layout = new FormLayout("2dlu, pref:grow", "3dlu, fill:10dlu, 2dlu"); 60 contentPanel.setLayout(layout); 61 62 add(contentPanel, BorderLayout.CENTER); 63 64 } 66 67 public void setMainLeftComponent(JComponent c) { 68 contentPanel.add(c, new CellConstraints(2, 2)); 69 } 70 71 public void addRightComponent(JComponent c, int dialogUnits) { 72 layout.appendColumn(new ColumnSpec("2dlu")); 73 layout.appendColumn(new ColumnSpec(dialogUnits + "dlu")); 74 75 layoutCoordinateX++; 76 77 contentPanel.add(new SeparatorPanel(Color.GRAY, Color.WHITE), 78 new CellConstraints(layoutCoordinateX, layoutCoordinateY)); 79 layoutCoordinateX++; 80 81 contentPanel.add(c, new CellConstraints(layoutCoordinateX, 82 layoutCoordinateY)); 83 } 84 85 public void addRightComponent(JComponent c) { 86 layout.appendColumn(new ColumnSpec("2dlu")); 87 layout.appendColumn(new ColumnSpec("default")); 88 89 layoutCoordinateX++; 90 91 contentPanel.add(new SeparatorPanel(Color.GRAY, Color.WHITE), 92 new CellConstraints(layoutCoordinateX, layoutCoordinateY)); 93 layoutCoordinateX++; 94 95 contentPanel.add(c, new CellConstraints(layoutCoordinateX, 96 layoutCoordinateY)); 97 } 98 99 100 protected void paintComponent(Graphics g) { 101 super.paintComponent(g); 102 103 int y = 0; 104 g.setColor(new Color (156, 154, 140)); 105 g.drawLine(0, y, getWidth(), y); 106 y++; 107 g.setColor(new Color (196, 194, 183)); 108 g.drawLine(0, y, getWidth(), y); 109 y++; 110 g.setColor(new Color (218, 215, 201)); 111 g.drawLine(0, y, getWidth(), y); 112 y++; 113 g.setColor(new Color (233, 231, 217)); 114 g.drawLine(0, y, getWidth(), y); 115 116 y = getHeight() - 3; 117 g.setColor(new Color (233, 232, 218)); 118 g.drawLine(0, y, getWidth(), y); 119 y++; 120 g.setColor(new Color (233, 231, 216)); 121 g.drawLine(0, y, getWidth(), y); 122 y = getHeight() - 1; 123 g.setColor(new Color (221, 221, 220)); 124 g.drawLine(0, y, getWidth(), y); 125 126 } 127 128 class SeparatorPanel extends JPanel { 129 private Color leftColor; 130 131 private Color rightColor; 132 133 SeparatorPanel(Color l, Color r) { 134 this.leftColor = l; 135 this.rightColor = r; 136 setOpaque(false); 137 } 138 139 protected void paintComponent(Graphics g) { 140 g.setColor(leftColor); 141 g.drawLine(0, 0, 0, getHeight()); 142 g.setColor(rightColor); 143 g.drawLine(1, 0, 1, getHeight()); 144 } 145 } 146 } | Popular Tags |