我正在尝试使用 swing 学习基本的 GUI。当我尝试激活/设置 nimbus 时,显示以下错误“com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel 无法解析为变量”。错误显示在 setLookAndFeel() 方法中的 com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel 行中。我正在使用 java build 1.7.0
import java.awt.FlowLayout;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.*;
public class swing1 extends JFrame {
public swing1(){
super("Title: Swing Project 1");
//setLookAndFeel();
setSize(225,80);
setLookAndFeel();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FlowLayout flo = new FlowLayout();
JButton adds = new JButton ("Add");
JButton minus = new JButton("Substract");
JButton mult = new JButton ("Multiply");
add(adds);
add(minus);
add(mult);
setVisible(true);
}
private void setLookAndFeel() {
// TODO Auto-generated method stub
try {
UIManager.setLookAndFeel(“com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel”);
}
catch (Exception exc) {
//ignore
}
}
public static void main (String args []){
swing1 startSwing = new swing1();
}
}