|
1 | 1 | 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 |
2 | 4 | import java.awt.*; //import awt library |
3 | 5 | import java.awt.Font; //import awt font library |
4 | 6 | import java.awt.event.*; //import awt event library |
@@ -162,8 +164,28 @@ public void setFont(String fontName, float fontSize) { |
162 | 164 | } |
163 | 165 | } |
164 | 166 |
|
| 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 | + |
165 | 186 | // Processing setup function |
166 | 187 | public void setup() { |
| 188 | + setTheme("light"); //set software theme |
167 | 189 | icon = loadImage("icon.png"); //import software icon |
168 | 190 | bufferedIcon = convertToBufferedImage(icon); //convert PImage to BufferedImage for use as JFrame icon |
169 | 191 | frame = (javax.swing.JFrame) ((processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative()).getFrame(); |
|
0 commit comments