1 package com.jpeterson.virtlcd.swing;
2
3 import javax.swing.JComponent;
4 import javax.swing.UIManager;
5
6 import com.jpeterson.virtlcd.swing.ui.BasicDotMatrixSixByEightUI;
7 import com.jpeterson.virtlcd.swing.ui.DotMatrixSixByEightUI;
8
9
10
11
12
13
14
15
16 public class JDotMatrixSixByEight extends JComponent {
17
18
19
20 private static final long serialVersionUID = 1L;
21
22
23
24
25 private static final String uiClassID = "DotMatrixSixByEightUI";
26
27 protected DotMatrixModel model;
28
29
30
31
32 public JDotMatrixSixByEight() {
33 this.model = new DefaultDotMatrixModel();
34
35 this.updateUI();
36 }
37
38
39
40
41
42
43
44 public void setUI(DotMatrixSixByEightUI ui) {
45 super.setUI(ui);
46 }
47
48
49
50
51
52
53 public void updateUI() {
54 if (UIManager.get(getUIClassID()) != null) {
55 setUI((DotMatrixSixByEightUI) UIManager.getUI(this));
56 } else {
57 setUI(new BasicDotMatrixSixByEightUI());
58 }
59 }
60
61
62
63
64
65
66
67 public DotMatrixSixByEightUI getUI() {
68 return (DotMatrixSixByEightUI) ui;
69 }
70
71
72
73
74
75
76
77
78
79
80 public String getUIClassID() {
81 return uiClassID;
82 }
83
84 public DotMatrixModel getModel() {
85 return this.model;
86 }
87
88
89
90
91
92
93 public char getChar() {
94 return model.getChar();
95 }
96
97
98
99
100
101
102
103 public void setChar(char c) {
104 char oldC = model.getChar();
105 if (oldC != c) {
106 model.setChar(c);
107 }
108 }
109 }