So I am new in Java, and I want to create a menu. The first thing I have to do is a JLabel with the game name in it. I did everything, but I can't figure out how to center the JLabel to be in the center of the screen, and not on the side
My friend gave me a code, but It doesn't work very well, here it is:
public static String gameName = "Game Name Placeholder";
JLabel label = new JLabel(gameName);
label.setBounds(this.getWidth()/2-100,this.getHeight()/2-150,1000,100);
label.setFont(new Font("Dialog", Font.PLAIN, 34));
panel.add(label);
add(panel);
And here you can see clearly it is not centered:
Sorry, I may look dumb. I just started learning Java 2 days ago on my own, so if someone could help me out I would appreciate it a lot!