-
Notifications
You must be signed in to change notification settings - Fork 2
/
switchLookAndFeelRuntime.jy
38 lines (30 loc) · 1.25 KB
/
switchLookAndFeelRuntime.jy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
setScriptDescription('''Demo how you can switch the Java Swing Look and Feel (laf) at
runtime. See also .../demos/2024/20240716/darkLookAndFeelExperiment.jy which
experiments with a dark mode.''')
from javax.swing import UIManager
lafs= UIManager.getInstalledLookAndFeels()
aa= []
classNames= []
for info in lafs:
aa.append( info.getName() )
classNames.append( info.getClassName() )
print info.getName(), info.getClassName()
# The GUI-generator doesn't call the code to derive class names, so we do this by hand.
aa=['Metal','Nimbus','CDE/Motif','GTK+']
classNames= [ 'javax.swing.plaf.metal.MetalLookAndFeel',
'javax.swing.plaf.nimbus.NimbusLookAndFeel',
'com.sun.java.swing.plaf.motif.MotifLookAndFeel',
'com.sun.java.swing.plaf.gtk.GTKLookAndFeel' ]
lafn= getParam( 'laf', 'Nimbus', 'look and feel', aa )
for i in xrange(len(aa)):
if ( aa[i]==lafn ):
laf= classNames[i]
from javax.swing import SwingUtilities
from java.lang import Runnable
class MyRun(Runnable):
def run( self ):
import javax.swing.UIManager
javax.swing.UIManager.setLookAndFeel(laf)
x= getViewWindow()
SwingUtilities.updateComponentTreeUI( x )
SwingUtilities.invokeLater(MyRun())