Search code examples
javaswinggraphicscustom-componentgraphics2d

Making custom UI in swing


I need to make a custom ui which looks like the following image :-

enter image description here

I know how to change the button to that arrow shape and everything else.But I can't understand how to move those close ,restore and minimize buttons to the center and give them round shape (on Windows).

On Googling ,I found how to make custom shape windows but it doesn't meet my requirements. Can anyone please tell me how to do this or any link.??


Solution

  • You will need to create your own title bar as another panel with buttons and then remove the window decoration on the frame.

    JFrame frame = new JFrame(...);    
    frame.setUndecorated(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//This will close the frame and exit
    

    To minimize and maximize, listen for button events and use:

    frame.setState(Frame.ICONIFIED);//minimizes
    
    frame.setState(Frame.NORMAL);//restores
    

    See Frame.setState(int) for details.