Sunday, 15 September 2013

NimbusLookAndFeel cannot be resolved to a variable

NimbusLookAndFeel cannot be resolved to a variable

I am trying to learn the basic GUI using swing. When I tried to
activate/set nimbus, the following error is shown
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel cannot be resolved to a
variable". The error is shown in the
com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel line in setLookAndFeel()
method. I am using 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();
}
}

No comments:

Post a Comment