当前位置: 技术问答>java相关
为何编译不通过?怎么办解决?
来源: 互联网 发布时间:2015-06-18
本文导语: import java.awt.*; import com.sun.java.swing.*; public class ButtonTest extends JApplet { public void init() { JButton b; b =new JButton("A JAVA Button"); getContentPane().add(b, BorderLayout.NORTH); } } ------------------------------------------...
import java.awt.*;
import com.sun.java.swing.*;
public class ButtonTest extends JApplet
{
public void init()
{
JButton b;
b =new JButton("A JAVA Button");
getContentPane().add(b, BorderLayout.NORTH);
}
}
------------------------------------------
报错如下
D:BUCKUPja>javac ButtonTest.java
ButtonTest.java:2: package com.sun.java.swing does not exist
import com.sun.java.swing.*;
^
ButtonTest.java:4: cannot resolve symbol
symbol : class JApplet
location: class ButtonTest
public class ButtonTest extends JApplet
^
ButtonTest.java:8: cannot resolve symbol
symbol : class JButton
location: class ButtonTest
JButton b;
^
ButtonTest.java:9: cannot resolve symbol
symbol : class JButton
location: class ButtonTest
b =new JButton("A JAVA Button");
^
ButtonTest.java:10: cannot resolve symbol
symbol : method getContentPane ()
location: class ButtonTest
getContentPane().add(b, BorderLayout.NORTH);
^
5 errors
import com.sun.java.swing.*;
public class ButtonTest extends JApplet
{
public void init()
{
JButton b;
b =new JButton("A JAVA Button");
getContentPane().add(b, BorderLayout.NORTH);
}
}
------------------------------------------
报错如下
D:BUCKUPja>javac ButtonTest.java
ButtonTest.java:2: package com.sun.java.swing does not exist
import com.sun.java.swing.*;
^
ButtonTest.java:4: cannot resolve symbol
symbol : class JApplet
location: class ButtonTest
public class ButtonTest extends JApplet
^
ButtonTest.java:8: cannot resolve symbol
symbol : class JButton
location: class ButtonTest
JButton b;
^
ButtonTest.java:9: cannot resolve symbol
symbol : class JButton
location: class ButtonTest
b =new JButton("A JAVA Button");
^
ButtonTest.java:10: cannot resolve symbol
symbol : method getContentPane ()
location: class ButtonTest
getContentPane().add(b, BorderLayout.NORTH);
^
5 errors
|
import javax.swing.*;