Can i create GUI in round shape wihtout title bar by extending JFrame class in java.

I want circular shape instead of default rectangle.
How can i do this?

Plz give solution as soon as possible.

Java swing and the look and feel library have a number of features that would be useful for this sort of development. It is also useful to look into overriding the Jframe class that makes standard JFrame for your application and reset its background opacity etc to match your needs.

public class JFrame2 extends JPanel {

    public JFrame2() {
        setSize(200, 100);
        setBackground(Color.BLACK);
    }

    @Override public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.red);
        g.fillRect(0, 0, 100, 100);
    }
}

Something alone those lines might be useful, however i have not tried it. I know it to be possible as i have seen it done in examples. Also noteworthy is that you should look into using event listeners to add basic open and close functionality to your custom frame using something like this :

frame.addWindo wListener(new WindowAdapter(){

      public void windowIconified(WindowEvent e){
            frame.setVisible(false);
      }
});


Other useful links maybe :
http://www.devdaily.com/blog/post/jfc-swing/transparent-translucent-java-frame-jframe-mac-slider http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/synth.html http://www.codeproject.com/Articles/117047/Arbitrary-Shaped-Transparent-JFrame-in-Java-Swing

The last one is particularly useful, anyway hope this helps.

Edited 4 Years Ago by trishtren

That last ref is very useful - but note that it uses the pre-release methods in AWTUtilities. These methods were "moved" into the mainstream classes with Java 7 (version 1.7), so if yu want to do shaped windows you should be sure to upgrade to 1.7 and stick to released APIs.

No need to create any custom classes, just

myJFrame.setUndecorated(true);
myJFrame.setShape(new Ellipse2D...  <params to define the circle you want>
This article has been dead for over six months. Start a new discussion instead.