我用的是Visual age for java,在run之前,首先就没有通过检查
the type named JFrame is not defined!
the type named JFrame is not defined!
解决方案 »
- java的基础问题
- 用TCP连接发送BufferedImage对象
- 怎么实现java ide 中的代码自动提示(完成)功能?
- 先給分 再問 收郵件附件中文問題 急急急,幫忙看看
- 我配置 jboss 后 run.bat –c all 后的错误,求助 !!!!!!!!!!!!
- 类的静态方法和单模态方法有什么差别
- 通宵都没解决的关于applet使用第三方组件的问题,请各位帮帮忙!
- HELP~~!!!
- 在JavaScript里面调用Java(通过Applet)的奇怪现象
- 有谁知道关于Applet中怎么样调用html. 50分全送
- 7年mm,有结局,撒分,java版每个都有,希望斑竹别删
- ———《菜菜鸟》菜级问题二:有参数程序执行不成功。—《来者有分》——
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();
}
}
JFrame frame=new JFrame("Sample GUI Components");
的时候,就停下了,出现
uncaught exception:java.lang.NoClassdefFoundError:com.sun.java.swing.jframe