我用的是Visual age for java,在run之前,首先就没有通过检查
the type named JFrame is not defined!

解决方案 »

  1.   

    错误如:
    java.lang.Error: Do not use javax.swing.JFrame.setLayout() use javax.swing.JFrame.getContentPane().setLayout() instead
    at javax.swing.JFrame.createRootPaneException(JFrame.java:446)
    at javax.swing.JFrame.setLayout(JFrame.java:512)
    at SimpleGUI.<init>(SimpleGUI.java:11)
    at SimpleGUI.main(SimpleGUI.java:40)
    Exception in thread "main" 把frame.setLayout(new FlowLayout());改为
    frame.getContentPane().setLayout(new FlowLayout());
    再加上一句frame.setVisible(true);
    旧可以见到你的窗体了,如下
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;public class SimpleGUI
    {
      public SimpleGUI()
      {
        JFrame frame=new JFrame("Sample GUI Components");
        frame.getContentPane().setLayout(new FlowLayout());
        JLabel label=new JLabel("A label");
        JButton aButton=new JButton("A button");
        JRadioButton aRadioButton=new JRadioButton("A radiobutton");
        JRadioButton anotherRadioButton=new JRadioButton("Another radioButton");
        JCheckBox checkBox=new JCheckBox("A checkBox",true);
        JTextField textField=new JTextField("A TextField");
        JButton tooltip=new JButton("A tooltip");
        tooltip.setToolTipText("A label with a tooltip");    frame.getContentPane().add(label);
        frame.getContentPane().add(aButton);
        frame.getContentPane().add(aRadioButton);
        frame.getContentPane().add(anotherRadioButton);
        frame.getContentPane().add(checkBox);
        frame.getContentPane().add(textField);
        frame.getContentPane().add(tooltip);
        frame.setVisible(true);
        frame.addWindowListener(new WindowAdapter()
        {
          public void windowClosing(WindowEvent evt)
          {
            System.exit(0);
          }
        });
      }public static void main(String[] argv)
      {
        SimpleGUI simple=new SimpleGUI();
        
      }
    }
      

  2.   

    还是有问题,走到
    JFrame frame=new JFrame("Sample GUI Components");
    的时候,就停下了,出现
    uncaught exception:java.lang.NoClassdefFoundError:com.sun.java.swing.jframe
      

  3.   

    你别用Visual age for java,用jdk或者别的试试吧