入门问题,请指点 我用的是Visual age for java,在run之前,首先就没有通过检查the type named JFrame is not defined! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 错误如: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 你别用Visual age for java,用jdk或者别的试试吧 java robot类 到底编程语言好(JAVA DELIPHY C#?) 小型管理系统的问题 急!!!!!!!!!!!! 求助 请大家帮忙看看 怎么样实现xor运算?大家来看看 帮帮一个想学JAVA的人!(在线等待!!) 是path设置的问题吗? JAVA 能在Microsft SQL 2000上开发软件吗?难道JAVA只能用ORACLE? 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