当前位置: 技术问答>java相关
: 关于鼠标的监听求助
来源: 互联网 发布时间:2015-07-10
本文导语: 帮忙看看那出错了 共四条出错 我不明白了 import javax.swing.*; import java.awt.*; public class Wide01 { static JFrame window = new JFrame("testing......"); public static void main(String[] args) { Toolkit theKit = window.getToolkit(...
帮忙看看那出错了
共四条出错
我不明白了
import javax.swing.*;
import java.awt.*;
public class Wide01
{
static JFrame window = new JFrame("testing......");
public static void main(String[] args)
{
Toolkit theKit = window.getToolkit();
Dimension wndSize = theKit.getScreenSize();
window.setBounds(0,0,wndSize.width,wndSize.height);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
window.getContentPane().setBackground(Color.pink);
window.addWindowListener(new WindowHandler());
window.setVisible(true);
}
class WindowHandler extends MouseAdapter
{
private Point start;
public mousePressed(MouseEvent e)
{
/*start = e.getPoint();
int modifier = e.getModifiers();
if((modifier & e.BUTTON1_MASK) != 0)
{
drawRect(e.getX,e.getY,20,20);
}*/
}
}
}
共四条出错
我不明白了
import javax.swing.*;
import java.awt.*;
public class Wide01
{
static JFrame window = new JFrame("testing......");
public static void main(String[] args)
{
Toolkit theKit = window.getToolkit();
Dimension wndSize = theKit.getScreenSize();
window.setBounds(0,0,wndSize.width,wndSize.height);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
window.getContentPane().setBackground(Color.pink);
window.addWindowListener(new WindowHandler());
window.setVisible(true);
}
class WindowHandler extends MouseAdapter
{
private Point start;
public mousePressed(MouseEvent e)
{
/*start = e.getPoint();
int modifier = e.getModifiers();
if((modifier & e.BUTTON1_MASK) != 0)
{
drawRect(e.getX,e.getY,20,20);
}*/
}
}
}
|
package untitled3;
/**
*
*
*
*
* @author unascribed
* @version 1.0
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
public class Wide01
{
static JFrame window = new JFrame("testing......");
public static void main(String[] args)
{
Toolkit theKit = window.getToolkit();
Dimension wndSize = theKit.getScreenSize();
window.setBounds(0,0,wndSize.width,wndSize.height);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
window.getContentPane().setBackground(Color.pink);
//window.addWindowListener(new WindowHandler());
window.setVisible(true);
}
class WindowHandler extends MouseAdapter
{
private Point start;
public void mousePressed(MouseEvent e)
{
/*start = e.getPoint();
int modifier = e.getModifiers();
if((modifier & e.BUTTON1_MASK) != 0)
{
drawRect(e.getX,e.getY,20,20);
}*/
}
}
}
/**
*
Title:
*
Description:
*
Copyright: Copyright (c) 2002
*
Company:
* @author unascribed
* @version 1.0
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
public class Wide01
{
static JFrame window = new JFrame("testing......");
public static void main(String[] args)
{
Toolkit theKit = window.getToolkit();
Dimension wndSize = theKit.getScreenSize();
window.setBounds(0,0,wndSize.width,wndSize.height);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
window.getContentPane().setBackground(Color.pink);
//window.addWindowListener(new WindowHandler());
window.setVisible(true);
}
class WindowHandler extends MouseAdapter
{
private Point start;
public void mousePressed(MouseEvent e)
{
/*start = e.getPoint();
int modifier = e.getModifiers();
if((modifier & e.BUTTON1_MASK) != 0)
{
drawRect(e.getX,e.getY,20,20);
}*/
}
}
}
|
错误:函数要不要求有反回值呀?