Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Samual Sam

To create a JFrame with no border and title bar, use setUndecorated() −

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400, 300));
frame.setUndecorated(true);

The following is an example to create JFrame with no border and title bar −

Example

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setPreferredSize(new Dimension(400, 300)); frame.setUndecorated(true);
      JPanel panel = new JPanel();
      panel.add(new JLabel("Demo!"));
      panel.add(new JButton(new AbstractAction("Close") {
         @Override
         public void actionPerformed(ActionEvent e) {
            System.exit(0);
         }
      }));
      frame.add(panel);
      frame.pack();
      frame.setVisible(true);
   }
}

Output

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.