-2
getLocation()
과 getLocationOnScreen()
메이트의 차이는 JFrame
에 무엇입니까?자바 : JFrame에서의 getLocation()과 getLocationOnScreen()의 차이점은 무엇입니까?
이 코드와 어떤 차이점이 있는지 테스트하고 싶었지만 그 결과는 같습니다. 어떤 방법을 사용해야합니까?
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(150, 100);
frame.setVisible(true);
System.out.println("getLocation: " + frame.getLocation().getX() + " " + frame.getLocation().getY());
System.out.println("getLocationOnScreen: " + frame.getLocationOnScreen().getX() + " " + frame.getLocationOnScreen().getY());
}
출력 :이 같은 JFrame의를 만들 때 화면 그래서
getLocation: 150.0 100.0
getLocationOnScreen: 150.0 100.0
이들은 Component의 메소드이며 다음과 같습니다. 따라서 JFrame에만 국한되지는 않습니다. 그들의 javadoc은 그들이하는 일을 설명합니다. javadoc 읽기 : 그것은 당신의 친구입니다. –