0

Hi to all programmers out there! :D

I want to create a JFrame without borders and size buttons. For example like the frame of the Steam-program for PC. I searched and found JWindow and the setUndecorated method for JFrame.

When I use one of these options I get a window without borders, but I can't resize it. Is there an easy way to keep this feature, especially the "snap-feature"? I mean Valve managed to solve this problem somehow :)

This question describes perfectly what I want, but there is only one answer and it's not very helpful...

Community
  • 1
  • 1
Just_Paul
  • 67
  • 1
  • 9
  • Conceptually, something like [this](http://stackoverflow.com/questions/26476645/resizing-path2d-circle-by-clicking-and-dragging-its-outer-edge/26476909#26476909). The basic idea is you will need some "gutter" within the window which when the mouse moves within it you will allow for the window to be resized, you then need to monitor the mouse dragged event and calculate the new size. [This example](http://stackoverflow.com/questions/16869877/how-to-remove-window-box-from-any-java-gui/16869893#16869893) demonstrates how you would "move" a window, the concept of resizing is based on this – MadProgrammer Jan 24 '16 at 21:01

1 Answers1

2

Check out Resizing Components. It is a general purpose class that allows you to resize any component. It will provide the appropriate cursor as the mouse is around the edge of the frame.

Basic usage for a frame would be:

JFrame frame = new JFrame("SSCCE");
frame.setUndecorated( true );

ComponentResizer cr = new ComponentResizer();
cr.registerComponent(frame);

Of course you will need to make sure that the frame has blank border around the edges so the MouseEvents are passed to the frame and not the component added to the frame.

camickr
  • 321,443
  • 19
  • 166
  • 288