1

My problem is related with what Jonas asked on the next topics:

How to add support for resizing when using an undecorated JFrame?

How can I customize the title bar on JFrame?

I want to create a custom window without the native title bar. This can be done by calling:

setUndecorated(true);

However, this also removes the re-size mechanism. So now I am using the next code:

 public UndecoratedFrame() {
 this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    menu.add(item);
    menuBar.add(menu);
    this.setJMenuBar(menuBar);
    this.setUndecorated(true);
    this.getRootPane().setBorder(border);
    this.setSize(400,340);
    this.setVisible(true);
}

This returns a window like this: http://www.roseindia.net/java/example/java/swing/CreateJList.shtml (Consider only the title bar and borders)

How can I remove the top title bar without removing the re-size decorator? Or should I customize the default title bar? How can I do this by a simple way?

The idea is to end with a frame only with its borders (and the re-size working..). Then, I can create a custom title bar with a JPanel and buttons triggering the close, minimization, etc. OS events.

Thanks in advance for your support.

Community
  • 1
  • 1
supertreta
  • 359
  • 1
  • 6
  • 10
  • possible duplicate of [How to add support for resizing when using an undecorated JFrame?](http://stackoverflow.com/questions/2780780/how-to-add-support-for-resizing-when-using-an-undecorated-jframe) – Riduidel Jan 12 '11 at 15:08
  • I started answering this question, then realized there already was a correct answer. oh crap, I even realized **I** already answered this very question ! So close this one, dude. – Riduidel Jan 12 '11 at 15:09
  • Sorry, actually I saw those posts but I was wondering if it wasn't there a way to only remove the title bar. It seems not. If I remove the bar, I remove everything. I am now looking on this re-size re-implementation approach. Thanks! – supertreta Jan 12 '11 at 15:21

1 Answers1

2

You need to implement your own mouse listeners and interpret the mouse gestures, programmatically resizing the window.

Another option is to use JIDE Common Layer - it provides multiple implementations of its ResizableSupport interface, including ResizableFrame which does what you describe.

http://www.jidesoft.com/javadoc/com/jidesoft/swing/ResizableFrame.html

ddimitrov
  • 3,293
  • 3
  • 31
  • 46