怎么使用帮助文档
比如我想找个关于鼠标按键消息的或者其它函数。。不知道应该怎么找好[[it] 本帖最后由 zacom 于 2008-11-2 18:53 编辑 [/it]]
import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class MouseEventTest extends JFrame{ private Container container; private JLabel label; private JPanel panel; public MouseEventTest(){ super("鼠标事件一"); container = getContentPane(); label = new JLabel("显示坐标"); panel = new JPanel(); addMouseMotionListener( new MouseAdapter(){ public void mouseMoved(MouseEvent event){ label.setText(event.getX() + ":" + event.getY()); } } ); container.add(panel); container.add(label,BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400,400); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); setLocation((screenSize.width - frameSize.width)/2,(screenSize.height - frameSize.height)/2); setVisible(true); } public static void main(String[] args) { new MouseEventTest(); } }