4
4
import java .awt .event .*;
5
5
import java .util .*;
6
6
import javax .swing .*;
7
+ import javax .swing .plaf .*;
7
8
import javax .swing .text .*;
8
9
import xyz .jadonfowler .phasebot .*;
9
10
10
11
public class ConsoleGui {
11
12
13
+ static final Color DARK_GREY = new Color (50 , 50 , 50 );
12
14
JFrame frame ;
13
15
JTextPane console ;
14
16
JTextPane chat ;
@@ -21,6 +23,7 @@ public class ConsoleGui {
21
23
ArrayList <String > recentInputs = new ArrayList <String >();
22
24
int recentInputId = 0 ;
23
25
int recentInputMax = 10 ;
26
+ SimpleAttributeSet background = new SimpleAttributeSet ();
24
27
25
28
public ConsoleGui () {
26
29
new Thread (new Runnable () {
@@ -30,20 +33,24 @@ public void run() {
30
33
UIManager .setLookAndFeel (UIManager .getSystemLookAndFeelClassName ());
31
34
}
32
35
catch (Exception e ) {}
36
+ //StyleConstants.setBackground(background, new Color(230, 255, 230));
37
+ UIDefaults defaults = UIManager .getDefaults ();
38
+ defaults .put ("TextPane[Enabled].backgroundPainter" , DARK_GREY );
39
+ defaults .put ("TextPane.background" , new ColorUIResource (DARK_GREY ));
40
+ defaults .put ("TextPane.inactiveBackground" , new ColorUIResource (DARK_GREY ));
33
41
frame = new JFrame ();
34
42
frame .setTitle ("PhaseBot: " + PhaseBot .HOST );
35
43
frame .setDefaultCloseOperation (3 );
36
44
console = new JTextPane ();
37
45
console .setEditable (false );
38
46
console .setFont (new Font ("Open Sans" , Font .PLAIN , 12 ));
39
47
console .setOpaque (false );
40
- console .setBackground (new Color (50 , 50 , 50 ));
48
+ // console.setBackground(new Color(50, 50, 50));
41
49
consoleDocument = console .getStyledDocument ();
42
50
chat = new JTextPane ();
43
51
chat .setEditable (false );
44
52
chat .setFont (new Font ("Open Sans" , Font .PLAIN , 12 ));
45
53
chat .setOpaque (false );
46
- chat .setBackground (new Color (50 , 50 , 50 ));
47
54
chatDocument = chat .getStyledDocument ();
48
55
input = new JTextField ();
49
56
// input.setEditable(true); //Probably don't need
@@ -100,14 +107,18 @@ public void keyTyped(KeyEvent e) {}
100
107
chatScrollPane .setOpaque (false );
101
108
chatScrollPane .getViewport ().setOpaque (false );
102
109
JTabbedPane tabs = new JTabbedPane ();
110
+ tabs .setBackground (DARK_GREY );
103
111
tabs .addTab ("Console" , null , consoleScrollPane , "Console for PhaseBot" );
112
+ console .putClientProperty ("Nimbus.Overrides" , defaults );
113
+ console .putClientProperty ("Nimbus.Overrides.InferitDefaults" , true );
114
+ console .setBackground (DARK_GREY );
104
115
tabs .addTab ("Chat" , null , chatScrollPane , "Incoming chat messages" );
105
- tabs .setBackground (new Color (50 , 50 , 50 ));
116
+ chat .putClientProperty ("Nimbus.Overrides" , defaults );
117
+ chat .putClientProperty ("Nimbus.Overrides.InferitDefaults" , true );
118
+ chat .setBackground (DARK_GREY );
106
119
frame .add (input , BorderLayout .SOUTH );
107
120
frame .add (tabs , BorderLayout .CENTER );
108
- //frame.add(consoleScrollPane, BorderLayout.WEST);
109
- //frame.add(chatScrollPane, BorderLayout.EAST);
110
- frame .getContentPane ().setBackground (new Color (50 , 50 , 50 ));
121
+ frame .getContentPane ().setBackground (DARK_GREY );
111
122
frame .setSize (660 , 350 );// TODO Change
112
123
frame .setLocationRelativeTo (null );
113
124
frame .setResizable (false ); // TODO Change
@@ -125,34 +136,33 @@ public void scrollBottom() {
125
136
}
126
137
127
138
public void print (String s , boolean trace ) {
128
- print (s , trace , new Color ( 255 , 255 , 255 ) );
139
+ print (s , trace , Color . BLACK );
129
140
}
130
141
131
142
public void addChatMessage (String s ) {
132
143
try {
133
- Style style = console . addStyle ( "Style" , null );
134
- chatDocument .insertString (chatDocument .getLength (), s + "\n " , style );
144
+ StyleConstants . setForeground ( background , Color . BLACK );
145
+ chatDocument .insertString (chatDocument .getLength (), s + "\n " , background );
135
146
}
136
147
catch (Exception e ) {}
137
148
}
138
149
139
150
public void print (String s , boolean trace , Color c ) {
140
151
try {
141
- Style style = console .addStyle ("Style" , null );
142
- StyleConstants .setForeground (style , c );
152
+ StyleConstants .setForeground (background , c );
143
153
if (trace ) {
144
154
Throwable t = new Throwable ();
145
155
StackTraceElement [] elements = t .getStackTrace ();
146
156
String caller = elements [0 ].getClassName ();
147
157
s = caller + " > " + s ;
148
158
}
149
- consoleDocument .insertString (consoleDocument .getLength (), s , style );
159
+ consoleDocument .insertString (consoleDocument .getLength (), s , background );
150
160
}
151
161
catch (Exception e ) {}
152
162
}
153
163
154
164
public void println (String s , boolean trace ) {
155
- print (s +"\n " , trace );
165
+ print (s + "\n " , trace );
156
166
}
157
167
158
168
public void println (String s , boolean trace , Color c ) {
@@ -184,7 +194,7 @@ public void clear() {
184
194
185
195
public void performCommand (String s ) {
186
196
try {
187
- println ("$ " + s , false , Color . GREEN );
197
+ println ("$ " + s , false , new Color ( 92 , 196 , 88 ) );
188
198
PhaseBot .getBot ().runCommand (s , true );
189
199
}
190
200
catch (Exception e ) {
0 commit comments