Resize drawing to match frame size

前端 未结 4 1675
自闭症患者
自闭症患者 2020-12-19 09:40

I\'ve written an app that custom draws everything inside paint() based on fixed pixel positions. Then I disabled resize of the frame so its always visible.

However,

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-19 10:15

    Not an expert, but you could just scale the Graphics2D object (the passed Graphics is in fact a Graphics2D instance), where the x and y ratios are the ratios of the fixed size you chose to draw and the actual size of the frame.

    See http://download.oracle.com/javase/6/docs/api/java/awt/Graphics2D.html#scale%28double,%20double%29

提交回复
热议问题