eclipse调试程序出现selection a way to debug 'lizi05' 然后给出2个选择java applet和java application
无论我点哪个选择都不错,不能调式出来,我的程序是照书上的例子写的。请高手指点哪出问题了。我点javaapplet这个选择结果提示错误selectiondosenotcon...
无论我点哪个选择都不错,不能调式出来,我的程序是照书上的例子写的。请高手指点哪出问题了。我点java applet 这个选择结果提示错误selection dose not contain an applet
我点java application 这个选择结果提示错误selection dose not contain a main type.
我的书上的例子程序是:
import java.applet.*;
import javax.swing.*;
import java.awt.*;
class MyWindow extends JFrame{
public MyWindow(int w,int h){
setTitle("滚动面板实例");
Container con = getContentPane();
con.setPreferredSize(new Dimension(w,h));
con.setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setLayout(new GridLayout(6,6));
for(int i=0;i<6;i++){
p.add(new JLabel());
for(int j=1;j<=2;j++){
p.add(new JButton("按钮" + (2*i+j)));
p.add(new JLabel("标签" + (2*i+j)));
}
p.add(new JLabel());
}
p.setBackground(Color.blue);
p.setPreferredSize(new Dimension(w+60,h+60));
JScrollPane scrollPane = new JScrollPane(p);
scrollPane.setPreferredSize(new Dimension(w-60,h-60));
add(scrollPane,BorderLayout.CENTER);
setVisible(true);
pack();
}
}
class ScrollPane extends JScrollPane{
public ScrollPane(Component p){
super(p);
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
setVerticalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
}
}
public class lizi05 {
MyWindow myWindow;
public void init(){
myWindow = new MyWindow(400,350);
}
}
不好意思,贴的程序错了,上面的程序我查不来哪里出问题了。是下面这个程序出问题了
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lizi03 {
public static MyWindowDemo mw1;
public static MyWindowDemo mw2;
public static void mian(String args []){
JButton butt1 = new JButton("我是一个按钮");
String name1 = "我的第一个窗口";
String name2 = "我的第二个窗口";
mw1 = new MyWindowDemo(name1,butt1,Color.blue,350,350);
mw1.setVisible(true);
JButton butt2 = new JButton("我是另一个按钮");
mw2 = new MyWindowDemo(name2,butt2,Color.blue,300,400);
mw2.setVisible(true);
}
}
class MyWindowDemo extends JFrame{
public MyWindowDemo(String name,JButton button,Color c,int w,int h){
super();
setTitle(name);
setSize(w,h);
Container contentPane = getContentPane();
contentPane.add(button);
contentPane.setBackground(c);
}
} 展开
我点java application 这个选择结果提示错误selection dose not contain a main type.
我的书上的例子程序是:
import java.applet.*;
import javax.swing.*;
import java.awt.*;
class MyWindow extends JFrame{
public MyWindow(int w,int h){
setTitle("滚动面板实例");
Container con = getContentPane();
con.setPreferredSize(new Dimension(w,h));
con.setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setLayout(new GridLayout(6,6));
for(int i=0;i<6;i++){
p.add(new JLabel());
for(int j=1;j<=2;j++){
p.add(new JButton("按钮" + (2*i+j)));
p.add(new JLabel("标签" + (2*i+j)));
}
p.add(new JLabel());
}
p.setBackground(Color.blue);
p.setPreferredSize(new Dimension(w+60,h+60));
JScrollPane scrollPane = new JScrollPane(p);
scrollPane.setPreferredSize(new Dimension(w-60,h-60));
add(scrollPane,BorderLayout.CENTER);
setVisible(true);
pack();
}
}
class ScrollPane extends JScrollPane{
public ScrollPane(Component p){
super(p);
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
setVerticalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
}
}
public class lizi05 {
MyWindow myWindow;
public void init(){
myWindow = new MyWindow(400,350);
}
}
不好意思,贴的程序错了,上面的程序我查不来哪里出问题了。是下面这个程序出问题了
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lizi03 {
public static MyWindowDemo mw1;
public static MyWindowDemo mw2;
public static void mian(String args []){
JButton butt1 = new JButton("我是一个按钮");
String name1 = "我的第一个窗口";
String name2 = "我的第二个窗口";
mw1 = new MyWindowDemo(name1,butt1,Color.blue,350,350);
mw1.setVisible(true);
JButton butt2 = new JButton("我是另一个按钮");
mw2 = new MyWindowDemo(name2,butt2,Color.blue,300,400);
mw2.setVisible(true);
}
}
class MyWindowDemo extends JFrame{
public MyWindowDemo(String name,JButton button,Color c,int w,int h){
super();
setTitle(name);
setSize(w,h);
Container contentPane = getContentPane();
contentPane.add(button);
contentPane.setBackground(c);
}
} 展开
3个回答
展开全部
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lizi03 {
public static MyWindowDemo mw1;
public static MyWindowDemo mw2;
public static void main(String args []){
JButton butt1 = new JButton("我是一个按钮");
String name1 = "我的第一个窗口";
String name2 = "我的第二个窗口";
mw1 = new MyWindowDemo(name1,butt1,Color.blue,350,350);
mw1.setVisible(true);
JButton butt2 = new JButton("我是另一个按钮");
mw2 = new MyWindowDemo(name2,butt2,Color.blue,300,400);
mw2.setVisible(true);
}
}
class MyWindowDemo extends JFrame{
public MyWindowDemo(String name,JButton button,Color c,int w,int h){
super();
setTitle(name);
setSize(w,h);
Container contentPane = getContentPane();
contentPane.add(button);
contentPane.setBackground(c);
}
}
这样就Ok了,你把主函数写错了应该把mian改成main
import java.awt.*;
import java.awt.event.*;
public class lizi03 {
public static MyWindowDemo mw1;
public static MyWindowDemo mw2;
public static void main(String args []){
JButton butt1 = new JButton("我是一个按钮");
String name1 = "我的第一个窗口";
String name2 = "我的第二个窗口";
mw1 = new MyWindowDemo(name1,butt1,Color.blue,350,350);
mw1.setVisible(true);
JButton butt2 = new JButton("我是另一个按钮");
mw2 = new MyWindowDemo(name2,butt2,Color.blue,300,400);
mw2.setVisible(true);
}
}
class MyWindowDemo extends JFrame{
public MyWindowDemo(String name,JButton button,Color c,int w,int h){
super();
setTitle(name);
setSize(w,h);
Container contentPane = getContentPane();
contentPane.add(button);
contentPane.setBackground(c);
}
}
这样就Ok了,你把主函数写错了应该把mian改成main
展开全部
public static void mian(String args [])
这是面函数??
这是面函数??
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public static void mian(String args []),二楼真细心啊,main函数都写错了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询