Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I would like to ask a question about java  RSS feed

 
lianchi gao
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to ask a question on the junior java not making fun of me

import java.awt.*;
import java.awt.event.*;
public class TestMultiListener implements MouseMotionListener,MouseListener {
Frame f = new Frame("多重监听器测试");
TextField tf = new TextField(30);
public TestMultiListener(){
f.add(new Label("请按下鼠标左键并拖动"), "North");
f.add(tf, "South");
f.setBackground(new Color(120,175,175));
f.addMouseMotionListener(this);
f.addMouseListener(this);
f.setSize(300, 200); f.setVisible(true);
}
public static void main(String args[]) {
TestMultiListener t = new TestMultiListener();
}
public void mouseDragged(MouseEvent e) {
String s = "鼠标拖动到位置(" + e.getX() + "," + e.getY() + ")";
tf.setText(s);
}
public void mouseEntered(MouseEvent e) {
String s = "鼠标已进入窗体";
tf.setText(s);
}
public void mouseExited(MouseEvent e) {
String s = "鼠标已移出窗体";
tf.setText(s);
}
// 未使用的MouseMotionListener和MouseListener接口中的方法,也必须实现
public void mouseMoved(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseClicked(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
}


Here this is what role? how to use it? MouseEvent incident is how to useing "this" came to sniffers?
my english is poor i am chinese. thank you for your answer.waiting on line
 
Shoumin Li
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You post in wrong place
"this" means the current class instance.here is the frame class
[ July 26, 2007: Message edited by: Shoumin Li ]
 
Tim Holloway
Bartender
Posts: 18713
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, my Chinese is a lot worse than your English. But I'm moving this question to the forum most suitable for it:the Swing / AWT / SWT (etc) forum
[ July 26, 2007: Message edited by: Tim Holloway ]
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here this is what role?
Allows us to get information about where the mouse is located and what the user clicks on or
selects on the Frame.
how to use it?
For some ideas see Lesson: Writing Event Listeners.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!