当前位置: 技术问答>java相关
又一个编译不通过的!!!!!
来源: 互联网 发布时间:2015-03-13
本文导语: //程序如下: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class FocusApplet extends JApplet { JPanel contentPanel=(JPanel)this.getContentPane(); JPanel touchPanel=new JPanel(); JLabel touchLabel=new JLabel("Active Region"); MyMouseListene...
//程序如下:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FocusApplet extends JApplet
{
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel touchPanel=new JPanel();
JLabel touchLabel=new JLabel("Active Region");
MyMouseListener mml=new MyMouseListener();
MyMouseMotionListener mmml=new MyMouseMotionListener();
public void init()
{
touchLabel.setHorizontalAlignment(SwingConstants.CENTER);
touchPanel.setBackground(Color.white);
touchPanel.add(touchLabel);
touchPanel.addMyMouseListener(mml);
touchPanel.addMyMouseMotionListener(mmml);
contentPanel.setLayout(new GridLayout(2,0));
contentPanel.add(touchPanel);
}
class MyMouseListener extends MouseAdapter
{
public void mouseEntered(MouseEvent e)
{
showStatus("Mouse entered the Active Region");
}
public void mouseExited(MouseEvent e)
{
showStatus("Mouse exited the Active Region");
}
}
class MyMouseMotionListener extends MouseAdapter
{
public void mouseMoved(MouseEvent e)
{
showStatus("Mouse moved to locatio:x:"
+e.getX()+"y:"+e.getY());
}
public void mouseDragged(MouseEvent e)
{
showStatus("Mouse dragged to locatio:x:"
+e.getX()+"y:"+e.getY());
}
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FocusApplet extends JApplet
{
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel touchPanel=new JPanel();
JLabel touchLabel=new JLabel("Active Region");
MyMouseListener mml=new MyMouseListener();
MyMouseMotionListener mmml=new MyMouseMotionListener();
public void init()
{
touchLabel.setHorizontalAlignment(SwingConstants.CENTER);
touchPanel.setBackground(Color.white);
touchPanel.add(touchLabel);
touchPanel.addMyMouseListener(mml);
touchPanel.addMyMouseMotionListener(mmml);
contentPanel.setLayout(new GridLayout(2,0));
contentPanel.add(touchPanel);
}
class MyMouseListener extends MouseAdapter
{
public void mouseEntered(MouseEvent e)
{
showStatus("Mouse entered the Active Region");
}
public void mouseExited(MouseEvent e)
{
showStatus("Mouse exited the Active Region");
}
}
class MyMouseMotionListener extends MouseAdapter
{
public void mouseMoved(MouseEvent e)
{
showStatus("Mouse moved to locatio:x:"
+e.getX()+"y:"+e.getY());
}
public void mouseDragged(MouseEvent e)
{
showStatus("Mouse dragged to locatio:x:"
+e.getX()+"y:"+e.getY());
}
}
}
|
touchPanel.addMyMouseListener(mml);改为touchPanel.addMouseListener(mml);
touchPanel.addMyMouseMotionListener(mmml);改为touchPanel.addMouseMotionListener(mmml);
另外class MyMouseMotionListener extends MouseAdapter改为
class MyMouseMotionListener extends MouseMotionAdapter。因为MouseMotionListener派生自MouseMotionAdapter类。
touchPanel.addMyMouseMotionListener(mmml);改为touchPanel.addMouseMotionListener(mmml);
另外class MyMouseMotionListener extends MouseAdapter改为
class MyMouseMotionListener extends MouseMotionAdapter。因为MouseMotionListener派生自MouseMotionAdapter类。
|
touchPanel.addMyMouseListener(mml);
touchPanel.addMyMouseMotionListener(mmml);
这两个方法没有啊
touchPanel.addMyMouseMotionListener(mmml);
这两个方法没有啊
|
yhc0125(小程)
说的很对!
说的很对!