8
8
import javax .swing .JFrame ;
9
9
import javax .swing .JPanel ;
10
10
import javax .swing .border .EmptyBorder ;
11
+
12
+ import de .rcblum .stream .deck .device .SoftStreamDeck ;
13
+
11
14
import javax .swing .UIManager ;
12
15
import javax .swing .UnsupportedLookAndFeelException ;
13
16
@@ -47,11 +50,12 @@ public class JSoundboardFrame extends JFrame {
47
50
private JLabel lblSoundBoards ;
48
51
private JSelectablePanel pnSounds ;
49
52
private JLabel lblSounds ;
50
- private JSelectablePanel pn ;
53
+ private JSelectablePanel pnOptions ;
51
54
private JLabel lblOptions ;
52
55
private JScrollPane scrollPane ;
53
56
private PageViewer pnContent ;
54
57
private JPanel pnStatus ;
58
+ private JLabel lblShowSoftdecks ;
55
59
56
60
/**
57
61
* Launch the application.
@@ -130,55 +134,54 @@ public JSoundboardFrame() {
130
134
lblSounds .setBounds (10 , 0 , 180 , 40 );
131
135
pnSounds .add (lblSounds );
132
136
133
- pn = new JSelectablePanel ();
134
- pn .setLayout (null );
135
- pn .setBackground (new Color (0 , 81 , 108 ));
136
- pn .setBounds (0 , 80 , 200 , 40 );
137
- pnSideBar .add (pn );
137
+ pnOptions = new JSelectablePanel ();
138
+ pnOptions .setLayout (null );
139
+ pnOptions .setBackground (new Color (0 , 81 , 108 ));
140
+ pnOptions .setBounds (0 , 80 , 200 , 40 );
141
+ JSelectablePanel .JSelectablePanelGroup pnGroup = new JSelectablePanel .JSelectablePanelGroup ();
142
+ pnGroup .add (pnSoundBoards );
143
+ pnGroup .add (pnSounds );
144
+ pnSideBar .add (pnOptions );
145
+
146
+ JSelectablePanel pnDecks = new JSelectablePanel ();
147
+ pnDecks .setSelected (true );
148
+ pnDecks .addSelectionListener (new JSelectablePanel .SelectionListener () {
149
+
150
+ @ Override
151
+ public void selectionChanged (JSelectablePanel source , boolean newValue ) {
152
+ if (newValue )
153
+ SoftStreamDeck .showDecks ();
154
+ else
155
+ SoftStreamDeck .hideDecks ();
156
+ }
157
+ });
158
+ pnDecks .setLayout (null );
159
+ pnDecks .setBounds (0 , 410 , 200 , 40 );
160
+ pnSideBar .add (pnDecks );
161
+
162
+ lblShowSoftdecks = new JLabel ("Show SoftDecks" );
163
+ lblShowSoftdecks .setOpaque (false );
164
+ lblShowSoftdecks .setHorizontalAlignment (SwingConstants .CENTER );
165
+ lblShowSoftdecks .setForeground (Color .LIGHT_GRAY );
166
+ lblShowSoftdecks .setBounds (10 , 0 , 180 , 40 );
167
+ pnDecks .add (lblShowSoftdecks );
138
168
139
169
lblOptions = new JLabel ("Options" );
140
170
lblOptions .setOpaque (false );
141
171
lblOptions .setHorizontalAlignment (SwingConstants .CENTER );
142
172
lblOptions .setBounds (10 , 0 , 180 , 40 );
143
- MouseListener ml = new MouseListener () {
144
- @ Override
145
- public void mouseReleased (MouseEvent e ) {
146
- mouseClicked (e );
147
- }
148
-
149
- @ Override
150
- public void mousePressed (MouseEvent e ) {}
151
-
173
+ JSelectablePanel .SelectionListener sl = new JSelectablePanel .SelectionListener () {
152
174
@ Override
153
- public void mouseExited (MouseEvent e ) {}
154
-
155
- @ Override
156
- public void mouseEntered (MouseEvent e ) {}
157
-
158
- @ Override
159
- public void mouseClicked (MouseEvent e ) {
160
- if (e .getSource () == JSoundboardFrame .this .pnSoundBoards ) {
161
- JSoundboardFrame .this .pnSounds .setSelected (false );
162
- JSoundboardFrame .this .pn .setSelected (false );
163
- JSoundboardFrame .this .pnSoundBoards .setSelected (true );
164
- }
165
- else if (e .getSource () == JSoundboardFrame .this .pn ) {
166
- JSoundboardFrame .this .pnSounds .setSelected (false );
167
- JSoundboardFrame .this .pnSoundBoards .setSelected (false );
168
- JSoundboardFrame .this .pn .setSelected (true );
175
+ public void selectionChanged (JSelectablePanel source , boolean newValue ) {
176
+ if (newValue ) {
177
+ switchContent ();
169
178
}
170
- else if (e .getSource () == JSoundboardFrame .this .pnSounds ) {
171
- JSoundboardFrame .this .pn .setSelected (false );
172
- JSoundboardFrame .this .pnSoundBoards .setSelected (false );
173
- JSoundboardFrame .this .pnSounds .setSelected (true );
174
- }
175
- switchContent ();
176
179
}
177
180
};
178
- pn .add (lblOptions );
179
- this .pnSounds .addMouseListener ( ml );
180
- this .pnSoundBoards .addMouseListener ( ml );
181
- this .pn . addMouseListener ( ml );
181
+ pnOptions .add (lblOptions );
182
+ this .pnSounds .addSelectionListener ( sl );
183
+ this .pnSoundBoards .addSelectionListener ( sl );
184
+ // this.pnOptions.addSelectionListener(sl );
182
185
JSoundboardFrame .this .pnSoundBoards .setSelected (true );
183
186
lblSoundBoards .setForeground (ColorScheme .SIDE_BAR_FOREGROUND_COLOR );
184
187
lblSounds .setForeground (ColorScheme .SIDE_BAR_FOREGROUND_COLOR );
@@ -193,14 +196,19 @@ private void switchContent() {
193
196
}
194
197
195
198
private void displaySoundBoards () {
196
- if (pnSoundBoards .isSelected ()) {
197
- Page p = new JSoundboardPage ();
198
- pnContent .viewPage (p );
199
- }
200
- else if (pnSounds .isSelected ()) {
201
- Page p = new JSoundPage ();
202
- pnContent .viewPage (p );
203
- }
199
+ SwingUtilities .invokeLater (new Runnable () {
200
+ @ Override
201
+ public void run () {
202
+ if (pnSoundBoards .isSelected ()) {
203
+ Page p = new JSoundboardPage ();
204
+ pnContent .viewPage (p );
205
+ } else if (pnSounds .isSelected ()) {
206
+ Page p = new JSoundPage ();
207
+ pnContent .viewPage (p );
208
+ }
209
+ }
210
+
211
+ });
204
212
}
205
213
206
214
private void setSize (Component comp , int width , int height ) {
0 commit comments