I'm trying to create a title screen and need the title to adjust position depending on the window size. Currently it is central when I initially run the code but the JLabel does not adjust if I go into full screen or change the size at all. How can I change my code so that this isn't the case? This is my code so far for the frame:
public Frame1() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel() {
public void paintComponent(Graphics g) {
Image img = Toolkit.getDefaultToolkit().getImage(Frame1.class.getResource("/images/bg.jpg"));
g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
}
};
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
int width = ((this.getWidth() / 2) - 100);
int height = ((this.getHeight() / 2) - 38);
JLabel lblNewLabel = new JLabel("SCOPA!");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Book Antiqua", Font.ITALIC, 40));
lblNewLabel.setForeground(new Color(51, 255, 255));
lblNewLabel.setBounds(width, height, 200, 75);
contentPane.add(lblNewLabel);
}