e.getModifiers() & InputEvent.BUTTON1_MASK) = e.getModifiers(

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 09:06:52
e.getModifiers() & InputEvent.BUTTON1_MASK) = e.getModifiers(
xU[OA+-RhA[1Ctnff{|A"HࡉD@!pgmlt=999s:l4%@ApNۦ<\{8=}nhN%QǍ(1{d._gz~T[Y]uO׫';wn}{xn|7U=}mެ>'Z}k)Xs۫Gqf2VNlr`<[Hζ(G/q3f MRc DqՀp.`0a_M x}H,EO]j8J$OW Fʼn$1QN-ԔeXT94;6PkZ[^ %,x-rf Ayh"%,0 YůBVFq!)1ueNU4GVYv>h  HtWo=#vגʾO1FID(A6ec'>g*hi{)H{q .,? X}z.|qw пK芟\'@d[P GlLպS_A-8 ! cުP"EΞ='5AqP6iB&YY[v`H᝛]Ff P8u115TjoQaWʰxoX=.9t(\%>!b$o;#XvtT3Mї9

e.getModifiers() & InputEvent.BUTTON1_MASK) = e.getModifiers(
e.getModifiers() & InputEvent.BUTTON1_MASK) = e.getModifiers(

e.getModifiers() & InputEvent.BUTTON1_MASK) = e.getModifiers(
求求你下回抄程序也吵得认真点吧,错误太多了,这个是改完的,自己看吧
package com.opt.test;
import java.awt.*;
import java.awt.event.*;
class MyCanvas extends Canvas implements MouseListener
{
int left=-1,right=-1;
int x=-1,y=-1;
MyCanvas()
{
setSize(200,200);
setBackground(Color.pink);
super.addMouseListener(this);
}
public void paint(Graphics g)
{
if(left==-1)
{
g.drawString("按下了鼠标左键",x,y);
}
else if(right==-1)
{
g.drawString("按下了鼠标右键",x,y);
}
}
public void mousePressed(MouseEvent e)
{
x=e.getX();
y=e.getY();
if(e.getModifiers()==InputEvent.BUTTON1_MASK)
{
left=1;
right=-1;
repaint();
}
else if(e.getModifiers()==InputEvent.BUTTON2_MASK)
{
right=1;
left=-1;
repaint();
}
}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e)
{
right=-1;
left=-1;
repaint();
}
public void mouseClicked(MouseEvent e){}
public void update (Graphics g)
{
if (left==1||right==1)
{
paint(g);
}
else
{
super.update(g);
}
}
}
public class a
{
public static void main (String args[])
{
Frame f=new Frame ();
f.setBounds (100,100,300,300);
f.setVisible(true);
f.addWindowListener(new WindowAdapter()
{
public void WindowCloseing(WindowEvent e)
{
System.exit(0);
}
});
f.setLayout(new FlowLayout());
f.add(new MyCanvas());//添加画布
f.validate();
}
}