• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I would like to ask a question about java

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic