Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

java - 有什么方法可以使鼠标侦听器自动化?(Any way to make a mouse listener automated?)

Lets say I have an array of {0,1,2} an I draw a random number.

(可以说我有一个{0,1,2}的数组,我画了一个随机数。)

If random number is 2 for example I want public void mouseClicked(MouseEvent e){... to do code...} the code inside this to work.

(例如,如果随机数是2,则我想让public void mouseClicked(MouseEvent e){...做代码...}里面的代码起作用。)

Any way to make it possible?

(有什么办法可以实现?)

JLabel lblNewLabel = new JLabel("");
     lblNewLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            //to do code
        }
     });
  ask by Sosruko Gorgasali translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are thinking about "simulating" a mouse click,

(如果您正在考虑“模拟”鼠标单击,)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...