📄 test.java
字号:
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.swing.plaf.*;
public class Test extends JApplet {
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
setMetalTheme(new ExperimentalTheme());
contentPane.add(new JButton("button"));
contentPane.add(new JCheckBox("check me"));
}
private void setMetalTheme(MetalTheme theme) {
MetalLookAndFeel.setCurrentTheme(new ExperimentalTheme());
// Metal Look and Feel must be (re)loaded for the
// new theme to take effect ...
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.metal.MetalLookAndFeel");
}
catch(IllegalAccessException e1) {}
catch(UnsupportedLookAndFeelException e2) {}
catch(InstantiationException e3) {}
catch(ClassNotFoundException e4) {}
}
}
class ExperimentalTheme extends DefaultMetalTheme {
public FontUIResource getControlTextFont() {
return new FontUIResource("SanSerif",
Font.BOLD + Font.ITALIC, 24);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -