使用Line方法画直线后,当前坐标在()。
A.坐标原点
B. 直线起点
C. 直线终点
D. 无法确定
A.坐标原点
B. 直线起点
C. 直线终点
D. 无法确定
第3题
第4题
Import java.awt.*
import java.awt.event.*;
import javax.swing.*;
class EventQueuePanel extends JPanel implements Ac-
tionListener
{EventQueuePanel()
{JButton button=new JButton("Draw line");
add(button);
button.addActionListener(this);
}
public void actionPerformed(ActionEvent evt)
(Graphics g=getGraphics();
P=getClick();
g.drawOval(P.x-2,P.Y-2,4,4);
Point q=getClick();
g.drawOval(q.x-2,q.y-2,4,4);
g.drawLine(P.X,P.Y,q.x,q.y);
g.dispose();
}
public Point getClick()
{EventQueue eq=Toolkit.getDefaultToolkit().
getSystemEventQueue();
while(true)
{try
{AWTEvent evt=eq.getNextEvent();
if(evt.getID()= =MouseEvent.MOUSE.
PRESSED)
{MouseEvent mevt=(MouseEvent)evt;
Point P= ();
Point top=getRootPane().getLocation();
P.X-=top.x;
P.Y-=top.Y;
return P;
}
}
catch(InterruptedException e)
{}
}
}
private int Y=60;
}
class EventQueueFrame. extends JFrame
{public EventQueueFrame()
{setTitle("java2");
setSize(300,200);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit(0);
}
});
Container contentPane=getContentPane();
contentPane.add(new EventQueuePanel());
}
}
public class java2
{public static void main(String[]args)
{Frame. frame=new EventQueueFrame();
frame.show();
}
}
第10题
B.(200,200)到(300,300)
C.(300,300)到(500,500)
D.(200,200)到(500,500)
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!