Skip to content

Commit 8eb501d

Browse files
committed
Implement modern theme.
1 parent 4d9d721 commit 8eb501d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

mainCode/mainCode.pde

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import processing.serial.*; //import serial library
2+
import com.formdev.flatlaf.FlatLightLaf; //import flatlaf light theme
3+
import com.formdev.flatlaf.FlatDarkLaf; //import flatlaf dark theme
24
import java.awt.*; //import awt library
35
import java.awt.Font; //import awt font library
46
import java.awt.event.*; //import awt event library
@@ -162,8 +164,28 @@ public void setFont(String fontName, float fontSize) {
162164
}
163165
}
164166

167+
// set software theme
168+
public void setTheme(String theme) {
169+
try {
170+
if (theme.equals("light")) {
171+
UIManager.setLookAndFeel(new FlatLightLaf());
172+
systemPrintln("setTheme complete @ " + millis());
173+
} else if (theme.equals("dark")) {
174+
UIManager.setLookAndFeel(new FlatDarkLaf());
175+
systemPrintln("setTheme complete @ " + millis());
176+
} else {
177+
systemPrintln("Theme not recognized, defaulting to light theme @ " + millis());
178+
UIManager.setLookAndFeel(new FlatLightLaf());
179+
}
180+
}
181+
catch (UnsupportedLookAndFeelException e) {
182+
systemPrintln("Error setting theme: " + e.getMessage());
183+
}
184+
}
185+
165186
// Processing setup function
166187
public void setup() {
188+
setTheme("light"); //set software theme
167189
icon = loadImage("icon.png"); //import software icon
168190
bufferedIcon = convertToBufferedImage(icon); //convert PImage to BufferedImage for use as JFrame icon
169191
frame = (javax.swing.JFrame) ((processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative()).getFrame();

0 commit comments

Comments
 (0)