1 package org.woehlke.computer.kurzweil.commons.widgets;
2
3 import lombok.Getter;
4 import lombok.ToString;
5 import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties;
6 import org.woehlke.computer.kurzweil.commons.has.HasTabTitle;
7 import org.woehlke.computer.kurzweil.commons.layouts.FlowLayoutCenter;
8
9 import javax.swing.*;
10 import javax.swing.border.CompoundBorder;
11 import java.awt.event.KeyEvent;
12
13 @Getter
14 @ToString
15 public abstract class SubTabImpl extends JPanel implements HasTabTitle {
16
17 private final String title;
18 private final String subTitle;
19 private final String toolTipText;
20 private final Icon icon;
21 private final int keyEvent;
22 private final ComputerKurzweilProperties properties;
23 private final CompoundBorder border;
24 private final FlowLayoutCenter layout;
25
26 public SubTabImpl(String title, String subTitle, String toolTipText, Icon icon, int keyEvent,ComputerKurzweilProperties properties) {
27 this.title = title;
28 this.subTitle = subTitle;
29 this.toolTipText = toolTipText;
30 this.icon = icon;
31 this.keyEvent = keyEvent;
32 this.properties = properties;
33 this.border = getDoubleBorder();
34 this.setBorder( this.border);
35 this.layout = new FlowLayoutCenter();
36 this.setLayout( this.layout);
37 }
38
39 public SubTabImpl(String title, ComputerKurzweilProperties properties) {
40 this.title = title;
41 this.subTitle = title;
42 this.toolTipText = title;
43 this.icon = null;
44 this.keyEvent = KeyEvent.CHAR_UNDEFINED;
45 this.properties = properties;
46 this.border = getDoubleBorder();
47 this.setBorder( this.border);
48 this.layout = new FlowLayoutCenter();
49 this.setLayout( this.layout);
50 }
51
52 private CompoundBorder getDoubleBorder(){
53 int left = this.getProperties().getAllinone().getView().getBorderPaddingX();
54 int right = this.getProperties().getAllinone().getView().getBorderPaddingX();
55 int top = this.getProperties().getAllinone().getView().getBorderPaddingY();
56 int bottom = this.getProperties().getAllinone().getView().getBorderPaddingY();
57 return BorderFactory.createCompoundBorder(
58 BorderFactory.createEmptyBorder(left,right,top,bottom),
59 BorderFactory.createEmptyBorder(left,right,top,bottom)
60 );
61 }
62
63 }