0
크기가 다른 직사각형을 그리는 방법, 한 프레임에 비례 적으로 맞추는 방법 (프레임이 고정되어 있다고 가정)프레임에 비례하여 사각형을 맞추는 방법은 무엇입니까?
public class Draw extends JComponent {
public void paint(Graphics g) {
int width = 100;
int length = 100;
g.drawRect(10, 10, width, length);
}
}
public class DrawRect {
public static void main(String[] a) {
JFrame frame = new JFrame();
frame.setSize(400, 600));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Container content = frame.getContentPane();
content.add(new Draw());
}
}