1 | class SeparatorBorder implements Border {↵ | | 1 | class SeparatorBorder implements Border {↵
|
|
2 | boolean isFirst(Component c) {↵ | | 2 | boolean isFirst(Component c) {↵
|
3 | return c.getParent() == null || c.getParent().getComponent(0) == c;↵ | | 3 | return c.getParent() == null || c.getParent().getComponent(0) == c;↵
|
4 | }↵ | | 4 | }↵
|
|
5 | public Insets getBorderInsets(Component c) {↵ | | 5 | public Insets getBorderInsets(Component c) {↵
|
6 | // if the collapsible is collapsed, we do not want its border to be↵ | | 6 | // if the collapsible is collapsed, we do not want its border to be↵
|
7 | // painted.↵ | | 7 | // painted.↵
|
8 | if (c instanceof JXCollapsiblePane) {↵ | | 8 | if (c instanceof JXCollapsiblePane) {↵
|
9 | if (((JXCollapsiblePane) c).isCollapsed()) {↵ | | 9 | if (((JXCollapsiblePane) c).isCollapsed()) {↵
|
10 | return new Insets(0, 0, 0, 0);↵ | | 10 | return new Insets(0, 0, 0, 0);↵
|
11 | }↵ | | 11 | }↵
|
12 | }↵ | | 12 | }↵
|
13 | return new Insets(isFirst(c) ? 4 : 1, 0, 1, 0);↵ | | 13 | return new Insets(isFirst(c) ? 4 : 1, 0, 1, 0);↵
|
14 | }↵ | | 14 | }↵
|
|
15 | public boolean isBorderOpaque() {↵ | | 15 | public boolean isBorderOpaque() {↵
|
16 | return true;↵ | | 16 | return true;↵
|
17 | }↵ | | 17 | }↵
|
|
18 | public void paintBorder(Component c, Graphics g, int x, int y,↵ | | 18 | public void paintBorder(Component c, Graphics g, int x, int y,↵
|
19 | int width, int height) {↵ | | 19 | int width, int height) {↵
|
20 | g.setColor(borderColor1);↵ | | 20 | g.setColor(borderColor1);↵
|
21 | if (isFirst(c)) {↵ | | 21 | if (isFirst(c)) {↵
|
22 | g.drawLine(x, y + 2, x + width, y + 2);↵ | | 22 | g.drawLine(x, y + 2, x + width, y + 2);↵
|
23 | }↵ | | 23 | }↵
|
24 | // g.setColor(borderColor2);↵ | | 24 | // g.setColor(borderColor2);↵
|
25 | // g.drawLine(x, y + height - 1, x + width, y + height - 1);↵ | | 25 | // g.drawLine(x, y + height - 1, x + width, y + height - 1);↵
|
26 | }↵ | | 26 | }↵
|
27 | | | 27 |
|