下面一段代码是用来回去鼠标所在位置的像素值的,但是其中的
int x = (int) MouseInfo.getPointerInfo().getLocation().getX();
int y = (int) MouseInfo.getPointerInfo().getLocation().getY();
这两行代码是只能在jdk 1.5以后的版本中运行,我想找一个1.4.×中的api代替一下,但是找了半天也找不到,请大牛指教:)import java.awt.*;
import javax.swing.*;
import javax.swing.BorderFactory;public class PixelGetter extends JFrame {
JPanel contentPane; Robot robot; JTextField textX = new JTextField(); JTextField textY = new JTextField(); JLabel labelX = new JLabel(); JLabel labelY = new JLabel(); public static void main(String[] args) { PixelGetter f = new PixelGetter();
f.go(); }//end of main
public PixelGetter() {

this.setTitle("-_-");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setSize(138,88);
this.setLocation(0, 0);

contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);

try {
robot = new Robot();
} catch (Exception ex) {
System.out.println(ex);
}

textX.setBorder(BorderFactory.createLoweredBevelBorder());
textX.setBounds(38, 8, 58, 18);
textY.setBorder(BorderFactory.createLoweredBevelBorder());
textY.setBounds(38, 36, 58, 18); labelX.setText("x : ");
labelX.setBounds(15, 1, 20, 30);
labelY.setText("y : ");
labelY.setBounds(15, 29, 17, 31); contentPane.add(labelX);
contentPane.add(labelY);
contentPane.add(textX);
contentPane.add(textY); this.setVisible(true);
//this.setAlwaysOnTop(true); Use this if the version is 1.5 or later
this.toFront();

}//end of constructor public void go(){

try {
while (true) {
int x = (int) MouseInfo.getPointerInfo().getLocation()
.getX();
int y = (int) MouseInfo.getPointerInfo().getLocation()
.getY(); textX.setText("  "+x);
textY.setText("  "+y); Thread.sleep(20);//in case of wasting the CPU
}//end of while
} catch (Exception e) {
e.printStackTrace();
}//end of try-catch
}//end of go
}//end of class