
JAVA编程中的问题 十万火急 !!!高手帮帮我吧!!! 5
源程序如下:为什么我用Jbuilder2006调试的时候会出现nointerfaceexpectedhereatline(29:36);这是为什么啊?高手帮帮我!!!pa...
源程序如下 :为什么我用Jbuilder2006 调试的时候会出现
no interface expected here at line (29:36);
这是为什么啊?高手帮帮我!!!
package myframe;
import java.awt.*;
import java.awt.event.*;
public class myframe {
public static void main(String[] args) {
Frame f=new Frame();
f.setTitle("my web") ;
f.setSize(400,400) ;
f.setLocation(400,400) ;
f.setBackground(Color.BLUE ) ;
f.setLayout(new GridLayout(3,2));
Button btn1=new Button("north");
Button btn2=new Button("south");
Button btn3=new Button("west");
Button btn4=new Button("east");
Button btn5=new Button("center");
f.add(btn1);
f.add(btn2);
f.add(btn3);
f.add(btn4);
f.add(btn5);
f.setVisible(true);
}
}
class MywindowListener extends WindowListener {
void windowOpened(WindowEvent e)
{
}
void windowClosing(WindowEvent e)
{
}
void windowClosed(WindowEvent e)
{
}
void windowIconified(WindowEvent e)
{
}
void windowDeiconified(WindowEvent e)
{
}
void windowDeactivated(WindowEvent e)
{
}
} 展开
no interface expected here at line (29:36);
这是为什么啊?高手帮帮我!!!
package myframe;
import java.awt.*;
import java.awt.event.*;
public class myframe {
public static void main(String[] args) {
Frame f=new Frame();
f.setTitle("my web") ;
f.setSize(400,400) ;
f.setLocation(400,400) ;
f.setBackground(Color.BLUE ) ;
f.setLayout(new GridLayout(3,2));
Button btn1=new Button("north");
Button btn2=new Button("south");
Button btn3=new Button("west");
Button btn4=new Button("east");
Button btn5=new Button("center");
f.add(btn1);
f.add(btn2);
f.add(btn3);
f.add(btn4);
f.add(btn5);
f.setVisible(true);
}
}
class MywindowListener extends WindowListener {
void windowOpened(WindowEvent e)
{
}
void windowClosing(WindowEvent e)
{
}
void windowClosed(WindowEvent e)
{
}
void windowIconified(WindowEvent e)
{
}
void windowDeiconified(WindowEvent e)
{
}
void windowDeactivated(WindowEvent e)
{
}
} 展开
展开全部
WindowListener 是接口,不是类,实现接口不用是extends,要用implements,应该写成class MyWindowListener implements WindowListener,实现接口还有要实现这个接口中的所有方法。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.awt.*;
import java.awt.event.*;
public class myframe extends Frame
{
public myframe()
{
this.addWindowListener(new MywindowListener());
Frame f=new Frame();
f.setTitle("my web") ;
f.setSize(400,400) ;
f.setLocation(400,400) ;
f.setBackground(Color.BLUE ) ;
f.setLayout(new GridLayout(3,2));
Button btn1=new Button("north");
Button btn2=new Button("south");
Button btn3=new Button("west");
Button btn4=new Button("east");
Button btn5=new Button("center");
f.add(btn1);
f.add(btn2);
f.add(btn3);
f.add(btn4);
f.add(btn5);
f.setVisible(true);
}
public static void main(String[] args)
{
new myframe();
}
class MywindowListener implements WindowListener {
public void windowActivated(WindowEvent e)
{
System.out.println("Window Activated");
}
public void windowClosed(WindowEvent e)
{
System.out.println("Window Closed");
System.exit(0);
}
public void windowClosing(WindowEvent e)
{
System.out.println("Window Closing....");
Window w=e.getWindow();
w.dispose();
}
public void windowDeactivated(WindowEvent e)
{
System.out.println("Window Deactivated");
}
public void windowDeiconified(WindowEvent e)
{
System.out.println("Window Deiconified");
}
public void windowIconified(WindowEvent e)
{
System.out.println("Window Iconified");
}
public void windowOpened(WindowEvent e)
{
System.out.println("Window Opened");
}
}
}
import java.awt.event.*;
public class myframe extends Frame
{
public myframe()
{
this.addWindowListener(new MywindowListener());
Frame f=new Frame();
f.setTitle("my web") ;
f.setSize(400,400) ;
f.setLocation(400,400) ;
f.setBackground(Color.BLUE ) ;
f.setLayout(new GridLayout(3,2));
Button btn1=new Button("north");
Button btn2=new Button("south");
Button btn3=new Button("west");
Button btn4=new Button("east");
Button btn5=new Button("center");
f.add(btn1);
f.add(btn2);
f.add(btn3);
f.add(btn4);
f.add(btn5);
f.setVisible(true);
}
public static void main(String[] args)
{
new myframe();
}
class MywindowListener implements WindowListener {
public void windowActivated(WindowEvent e)
{
System.out.println("Window Activated");
}
public void windowClosed(WindowEvent e)
{
System.out.println("Window Closed");
System.exit(0);
}
public void windowClosing(WindowEvent e)
{
System.out.println("Window Closing....");
Window w=e.getWindow();
w.dispose();
}
public void windowDeactivated(WindowEvent e)
{
System.out.println("Window Deactivated");
}
public void windowDeiconified(WindowEvent e)
{
System.out.println("Window Deiconified");
}
public void windowIconified(WindowEvent e)
{
System.out.println("Window Iconified");
}
public void windowOpened(WindowEvent e)
{
System.out.println("Window Opened");
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
line 29:36是哪行啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询