-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLookAndFeelSecond.java
More file actions
131 lines (113 loc) · 4.06 KB
/
LookAndFeelSecond.java
File metadata and controls
131 lines (113 loc) · 4.06 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.JButton;
public class Main extends JFrame {
private JPanel buttonPanel;
public Main(){
buttonPanel = new JPanel();
add(buttonPanel);
pack();
// Metal
JButton metal = new JButton("Metal");
buttonPanel.add(metal);
metal.addActionListener(event -> {
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
});
// Nimbus
JButton nimbus = new JButton("Nimbus");
buttonPanel.add(nimbus);
nimbus.addActionListener(event -> {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
});
// Motif
JButton motif = new JButton("Motif");
buttonPanel.add(motif);
motif.addActionListener(event -> {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
});
// GTK (only works on Unix or Linux)
JButton gtk = new JButton("Gtk");
buttonPanel.add(gtk);
gtk.addActionListener(event -> {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
});
/*
Recommended not to use this Look and feel which are commnted
// Windows (only works on Windows)
JButton windows = new JButton("Windows");
buttonPanel.add(windows);
windows.addActionListener(event -> {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
});
JButton systemDefault = new JButton("System Default");
buttonPanel.add(systemDefault);
systemDefault.addActionListener(event -> {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
});
JButton macbook = new JButton("Macbook");
buttonPanel.add(macbook);
macbook.addActionListener(event -> {
try {
UIManager.setLookAndFeel("javax.swing.plaf.mac.MacLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
e.printStackTrace();
}
});
*/
setSize(450, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
/*
javax.swing.plaf.metal.MetalLookAndFeel
System
Motif
GTK
nimbus
java.swing.plaf.gtk.GTKLookAndFeel
java.swing.plaf.windows.WindowsLookAndFeel
javax.swing.plaf.metal.MetalLookAndFeel
You can even import other third party look-and-feel theme
Synthetica: A commercial library offering many different themes.
Substance: An open-source library providing a large set of different themes.
JGoodies: They offer a few free LookAndFeel themes.
WebLookAndFeel: This provides a LookAndFeel that imitates modern web styles.
Insubstantial: This is a fork of Substance and Flamingo, two projects that were originally created by Kirill Grouchnikov and are now inactive.
*/