summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/CustomBorder.java
blob: 3e79ce7b59a5d849b199711fb36d788487dd8ec4 (plain)
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
package jrummikub.view.impl;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;

import javax.swing.border.Border;

class CustomBorder implements Border {
  private Color color;
  private int top, left, bottom, right;
  
  public CustomBorder(Color color, int top, int left, int bottom, int right) {
    this.color = color;
    this.top = top;
    this.left = left;
    this.bottom = bottom;
    this.right = right;
  }
  
  @Override
  public Insets getBorderInsets(Component c) {
    return new Insets(top, left, bottom, right);
  }

  @Override
  public boolean isBorderOpaque() {
    return true;
  }

  @Override
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    g.setColor(color);
    
    g.fillRect(x, y, width, top);
    g.fillRect(x, y+height-bottom, width, bottom);
    g.fillRect(x, y, left, height);
    g.fillRect(x+width-right, y, right, height);
  }

}