package application;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class MainMenu extends JFrame {
MainMenu() {
JLabel background;
setExtendedState(JFrame.MAXIMIZED_BOTH);
setLayout(null);
setUndecorated(true);
ImageIcon image = new ImageIcon(this.getClass().getResource("main-bg.png"));
background = new JLabel("", image, JLabel.CENTER);
background.setBounds(0, 0, JFrame.MAXIMIZED_HORIZ, JFrame.MAXIMIZED_VERT);
this.add(background);
setVisible(true);
}
public static void main(String[] args) {
new MainMenu();
}
}
#Why this doesn't display image
9 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @opal moss! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
delete setLayout(null);
omg thanks
also is there a way to keep image resolution?
image displayed was zoomed a bit
Im not sure, but I guess you need to set the bounds of JLabel according to the image, not to the window. That's my assumption
okie i'll try thanks a lot