0

To be simple, the desired goal is to freeze the active rendering loop on window resize (in order to get rid of some unsavory flashing as described here), but there doesn't appear to be a straightforward way to a determine when the border of a Frame/JFrame is grabbed.

Of course, an event is thrown when the frame border is grabbed and resized. This could be useful in that a small wait could be added after each resize event to freeze the rendering loop, but this would produce a nice frozen frame after the frame is done resizing. It would be best to have an actual event thrown. Does anyone know of how to do this?

NOTE: To be clear, I need to know when the frame border is grabbed and not when the frame is resized

Community
  • 1
  • 1
CoderTheTyler
  • 839
  • 2
  • 11
  • 30

2 Answers2

1

the desired goal is to freeze the active rendering loop on window resize

You might be looking for:

Toolkit.getDefaultToolkit().setDynamicLayout(false) 

The layout of the components will be done when you release the mouse.

I need to know when the frame border is grabbed and not when the frame is resized

The frame border is implemented by the frame component of the underlying OS, not Swing so Swing does not have access to any event that is generated when you click on the frames Border.

You can use an undecorated JFrame and add your own Border and resizing logic. Then you can determine yourself when the resizing has started/stopped.

You can check out Resizing Components for a class that will do the resizing for you.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • There are no components. As I said, I am using active rendering. I need a way to determine when the frame border is grabbed – CoderTheTyler Aug 12 '14 at 14:28
  • That's what I figured I would have to do.. Ah well! At least it will work properly in the end! I'll likely just grab a default border setup and throw in a new event handler of sorts. Thank you for the response and thorough answer! – CoderTheTyler Aug 12 '14 at 15:31
0

Take a look at ComponentListener.

public void componentResized(ComponentEvent e);
public void componentMoved(ComponentEvent e);

Add a ComponentListener to your JFrame and handle the events.

martinez314
  • 12,162
  • 5
  • 36
  • 63
  • Yes, I mentioned the resize event, and it has no application to the problem. It could be plausibly used, but I need a way to determine when the frame border is grabbed. – CoderTheTyler Aug 12 '14 at 14:27