Skip to content

Commit 4431431

Browse files
committed
Make colors white because I can't get the background black
1 parent 05d02d2 commit 4431431

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/xyz/jadonfowler/phasebot/gui/ConsoleGui.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import java.awt.event.*;
55
import java.util.*;
66
import javax.swing.*;
7+
import javax.swing.plaf.*;
78
import javax.swing.text.*;
89
import xyz.jadonfowler.phasebot.*;
910

1011
public class ConsoleGui {
1112

13+
static final Color DARK_GREY = new Color(50, 50, 50);
1214
JFrame frame;
1315
JTextPane console;
1416
JTextPane chat;
@@ -21,6 +23,7 @@ public class ConsoleGui {
2123
ArrayList<String> recentInputs = new ArrayList<String>();
2224
int recentInputId = 0;
2325
int recentInputMax = 10;
26+
SimpleAttributeSet background = new SimpleAttributeSet();
2427

2528
public ConsoleGui() {
2629
new Thread(new Runnable() {
@@ -30,20 +33,24 @@ public void run() {
3033
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
3134
}
3235
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));
3341
frame = new JFrame();
3442
frame.setTitle("PhaseBot: " + PhaseBot.HOST);
3543
frame.setDefaultCloseOperation(3);
3644
console = new JTextPane();
3745
console.setEditable(false);
3846
console.setFont(new Font("Open Sans", Font.PLAIN, 12));
3947
console.setOpaque(false);
40-
console.setBackground(new Color(50, 50, 50));
48+
// console.setBackground(new Color(50, 50, 50));
4149
consoleDocument = console.getStyledDocument();
4250
chat = new JTextPane();
4351
chat.setEditable(false);
4452
chat.setFont(new Font("Open Sans", Font.PLAIN, 12));
4553
chat.setOpaque(false);
46-
chat.setBackground(new Color(50, 50, 50));
4754
chatDocument = chat.getStyledDocument();
4855
input = new JTextField();
4956
// input.setEditable(true); //Probably don't need
@@ -100,14 +107,18 @@ public void keyTyped(KeyEvent e) {}
100107
chatScrollPane.setOpaque(false);
101108
chatScrollPane.getViewport().setOpaque(false);
102109
JTabbedPane tabs = new JTabbedPane();
110+
tabs.setBackground(DARK_GREY);
103111
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);
104115
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);
106119
frame.add(input, BorderLayout.SOUTH);
107120
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);
111122
frame.setSize(660, 350);// TODO Change
112123
frame.setLocationRelativeTo(null);
113124
frame.setResizable(false); // TODO Change
@@ -125,34 +136,33 @@ public void scrollBottom() {
125136
}
126137

127138
public void print(String s, boolean trace) {
128-
print(s, trace, new Color(255, 255, 255));
139+
print(s, trace, Color.BLACK);
129140
}
130141

131142
public void addChatMessage(String s) {
132143
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);
135146
}
136147
catch (Exception e) {}
137148
}
138149

139150
public void print(String s, boolean trace, Color c) {
140151
try {
141-
Style style = console.addStyle("Style", null);
142-
StyleConstants.setForeground(style, c);
152+
StyleConstants.setForeground(background, c);
143153
if (trace) {
144154
Throwable t = new Throwable();
145155
StackTraceElement[] elements = t.getStackTrace();
146156
String caller = elements[0].getClassName();
147157
s = caller + " > " + s;
148158
}
149-
consoleDocument.insertString(consoleDocument.getLength(), s, style);
159+
consoleDocument.insertString(consoleDocument.getLength(), s, background);
150160
}
151161
catch (Exception e) {}
152162
}
153163

154164
public void println(String s, boolean trace) {
155-
print(s +"\n", trace);
165+
print(s + "\n", trace);
156166
}
157167

158168
public void println(String s, boolean trace, Color c) {
@@ -184,7 +194,7 @@ public void clear() {
184194

185195
public void performCommand(String s) {
186196
try {
187-
println("$ " + s, false, Color.GREEN);
197+
println("$ " + s, false, new Color(92, 196, 88));
188198
PhaseBot.getBot().runCommand(s, true);
189199
}
190200
catch (Exception e) {

0 commit comments

Comments
 (0)