0

I'm figuring out how to change the font-size of the titlebar on the following window:

enter image description here

This is the code of the JFrame container:

public class MyWindow extends JFrame {

  //Constructor of my window
  public MyWindow() {
      this.setSize(600, 300);
      this.setVisible(true);
      this.setLocationRelativeTo(null);
      this.setDefaultCloseOperation(EXIT_ON_CLOSE);
      this.setTitle("I want to change the font-size of this Title");
      this.initComponents();
  }
  
  //Declaration and deveploment of the components of my window
  private void initComponents() {
      JPanel myPanel = new JPanel();
      this.getContentPane().add(myPanel);
      JLabel myLabel = new JLabel();
      myPanel.add(myLabel);
      myLabel.setText("Hello World!!!");
      myLabel.setFont(new Font("Calibri", Font.BOLD, 32));
      myLabel.setForeground(Color.decode("#1165AA"));
      myPanel.setLayout(null);
      myLabel.setBounds(200, 80, 200, 50);
  }
}

And this is the Main class code that runs the program:

public class Main {
    public static void main(String[] args) {
       MyWindow window = new MyWindow();
    }
}

After reading a lot of posts, I think it is not possible because the titlebar styles would be controlled by the user OS, but I want to explore all the options...

Thanks

HOTOMOL
  • 71
  • 6
  • 2
    You are correct. The title bar style is controlled by the user OS. – Gilbert Le Blanc Sep 20 '20 at 12:59
  • 1
    I don't think there's a way to achieve what you are trying to do because the title bar is rendered by user OS. However, the best and probably, the only way to do is to render your own custom title bar after setting the `JFrame` undecorated. But if you do this, you are going to have to create a custom resizer to allow resizing of your `JFrame` as there will be no default resizer with the default title bar gone. BTW, try checking this : https://stackoverflow.com/questions/2781987/how-can-i-customize-the-title-bar-on-jframe – Miles Morales Sep 20 '20 at 15:35

0 Answers0