문제 설명
Java의 캔버스에 마우스가 그리는 좌표만 화면에 인쇄하려면 어떻게 해야 합니까? (How do I only print to the screen the coordinates of what the mouse is drawing on a canvas in Java?)
저는 사용자가 캔버스에 그림을 그리고 그들이 그린 좌표가 화면에 출력되도록 하는 프로그램을 만들고 있습니다.
내 질문은, 마우스가 캔버스에 선을 그리는 경우 화면 해당 라인의 좌표를 화면에 어떻게 인쇄합니까?
참조 솔루션
방법 1:
My idea on how to do that:
- Create a
JFrame
, - Add
JPanel
and a newLayout
, - Add
JTextArea
or similar, - Decide how frequently you want to add new coordinates (as you can't do anything continuously),
- Run a
Runnable
which will append the text in theJTextArea
or similar with current coordinates.