java中MouseEvent事件
这是我的代码packageorg.liky.game.frame;importjava.awt.HeadlessException;importjava.awt.Tool...
这是我的代码
package org.liky.game.frame;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class FiveChessFrame extends JFrame implements MouseListener{
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
int x = 0;
int y = 0;
int[][] allChess = new int[19][19];
boolean isBlack = true;
boolean canPlay = true;
String message = "黑方先行";
int maxTime = 0;
int blackTime = 0;
int whiteTime = 0;
String blackMessage = "无限制";
String whiteMessage = "无限制";
public FiveChessFrame() throws HeadlessException{
this.setTitle("五子棋");
this.setSize(500,500);
this.setLocation((width-500)/2,(height-500)/2);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addMouseListener(this);
this.setVisible(true);
}
public void mouseClicked(MouseEvent arg0)
{
JOptionPane.showMessageDialog(this,"鼠标单击");
}
}
*******************************************************************************************************************
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
请问我的为什么就不能自动生成这些方法? public class FiveChessFrame extends JFrame implements MouseListener{} 编译器还会报FiveChessFrame的错。 展开
package org.liky.game.frame;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class FiveChessFrame extends JFrame implements MouseListener{
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
int x = 0;
int y = 0;
int[][] allChess = new int[19][19];
boolean isBlack = true;
boolean canPlay = true;
String message = "黑方先行";
int maxTime = 0;
int blackTime = 0;
int whiteTime = 0;
String blackMessage = "无限制";
String whiteMessage = "无限制";
public FiveChessFrame() throws HeadlessException{
this.setTitle("五子棋");
this.setSize(500,500);
this.setLocation((width-500)/2,(height-500)/2);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addMouseListener(this);
this.setVisible(true);
}
public void mouseClicked(MouseEvent arg0)
{
JOptionPane.showMessageDialog(this,"鼠标单击");
}
}
*******************************************************************************************************************
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
请问我的为什么就不能自动生成这些方法? public class FiveChessFrame extends JFrame implements MouseListener{} 编译器还会报FiveChessFrame的错。 展开
2个回答
2014-08-06
展开全部
最好把错误的代码弄出来,应该没谁愿意看你写的代码,而想先知道报错的问题。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询