有问题,我有“ yC ”,当用户按 alt + C 时,它会一直改变
问题是如何让 JTextField 每次改变 yC 的值时都改变里面的值。
yT=new JTextField(5);
mainframe.add(yT);
yT.setText(Integer.toString(yC));
window.getContentPane().add(mainframe);
window.pack();
window.setVisible(true);
如何改变 yC:
cor.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
PointerInfo a = MouseInfo.getPointerInfo();
Point b = a.getLocation();
xC = (int) b.getX();
yC = (int) b.getY();
textArea.replaceSelection("X-Coordinates:" + xC + " Y-Coordinates: " + yC + "\n");
}
});