File: ComponentBottomBar.java

package info (click to toggle)
mac-widgets 0.9.5%2Bsvn369-dfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,920 kB
  • sloc: java: 8,318; makefile: 13; sh: 12
file content (55 lines) | stat: -rw-r--r-- 2,231 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.explodingpixels.macwidgets;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.Border;
import java.awt.BorderLayout;

public class ComponentBottomBar extends TriAreaComponent {

    ComponentBottomBar() {
        super();
        setBackgroundPainter(MacButtonFactory.GRADIENT_BUTTON_IMAGE_PAINTER);
        getComponent().setBorder(BorderFactory.createMatteBorder(1,0,0,0,
                MacButtonFactory.GRADIENT_BUTTON_BORDER_COLOR));
    }

    public void addComponentToLeftWithBorder(JComponent toolToAdd) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.setOpaque(false);
        panel.setBorder(BorderFactory.createMatteBorder(0,0,0,1,
                MacButtonFactory.GRADIENT_BUTTON_BORDER_COLOR));
        panel.add(toolToAdd, BorderLayout.CENTER);
        super.addComponentToLeft(panel);
    }

    public void addComponentToCenterWithBorder(JComponent toolToAdd) {
        // TODO use matteBorder when on first center item addition.
        // if this is the first component being added, add a line to the left
        //    and right of the component.
        // else add a border just to the right.
        Border matteBorder = getCenterComponentCount() == 0
                ? BorderFactory.createMatteBorder(0,1,0,1,
                MacButtonFactory.GRADIENT_BUTTON_BORDER_COLOR)
                : BorderFactory.createMatteBorder(0,0,0,1,
                MacButtonFactory.GRADIENT_BUTTON_BORDER_COLOR);

        JPanel panel = new JPanel(new BorderLayout());
        panel.setOpaque(false);
        panel.setBorder(BorderFactory.createMatteBorder(0,0,0,1,
                MacButtonFactory.GRADIENT_BUTTON_BORDER_COLOR));
        panel.add(toolToAdd, BorderLayout.CENTER);
        super.addComponentToCenter(panel);
    }

    public void addComponentToRightWithBorder(JComponent toolToAdd) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.setOpaque(false);
        panel.setBorder(BorderFactory.createMatteBorder(0,0,0,1,
                MacButtonFactory.GRADIENT_BUTTON_BORDER_COLOR));
        panel.add(toolToAdd, BorderLayout.CENTER);
        super.addComponentToRight(panel);
    }

}