在Java中是否有设置特定JFrame的分辨率而不是更改计算机的分辨率,这意味着如果我有一个大小为100x100的JFrame,我可以使它左上角为(0,0)右下角是(50,50)?这些点是JFrame内部的坐标,例如使用Graphics(java.awt.Graphics)时。
谢谢。
答案 0 :(得分:1)
Graphics2D
有一个缩放选项,请在Javadoc中查看。
在你的情况下,就是这样:
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.scale(0.5, 0.5); // 50% x and 50% y
// rest of rendering
}