in this code, "loginPanel" dont respect the dimensions i gave to it(300x450), but it fits in all the screen like the backgroundLabel.
so then the loginPanel goes to cover the background.
this is the code:
package gui;
import javax.swing.*;
import java.awt.*;
public class LoginGUI extends JFrame {
private static JLabel backgroundLabel;
public LoginGUI() {
super("LoginApp2");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setLayout(new BorderLayout());
setExtendedState(JFrame.MAXIMIZED_BOTH);
backgroundImage();
loginPanel();
}
public void backgroundImage() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = (int) screenSize.getWidth();
int height = (int) screenSize.getHeight();
ImageIcon backgroundImage = new ImageIcon("C://Users//***//Downloads//Applicazione4BK.png");
Image img = backgroundImage.getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT);
backgroundLabel = new JLabel(new ImageIcon(img));
add(backgroundLabel, BorderLayout.CENTER);
}
public void loginPanel(){
JPanel blurPanel = new JPanel();
blurPanel.setPreferredSize(new Dimension(30, 50));
blurPanel.setBackground(new Color(11, 192, 239, 0));
add(blurPanel, BorderLayout.CENTER);
}
}```