简体   繁体   中英

Java - Get difference between old and new size of JFrame

After I do a resizing at a JFrame, is there any method that returns the difference between the old and new size, ie (dx,dy) ?

If not, is there a way to get this info?

(dx,dy) - Image

You need to know what the size was before the frame was resized, then you could use a ComponentListener to detect when the frame's size was changed. The trick here is knowning when the "size" has changed to a fixed point from which taking a measure is worthwhile. Once the frame has "settled" you would simply need to calculate the difference from the "last resize" to now

Start by having a look at How to Write a Component Listener

Conceptually, you want to do something like this or something like this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM