我似乎无法弄清楚这一点。
请帮助我需要这个来解决我的项目。
呀我要补充这让我张贴JLabel作为背景图片
import javax.swing.*;
import java.awt.*;
@SuppressWarnings("serial")
public class MainFrame extends JFrame {
public static void Draw(){
DrawFrame();
}
public static void DrawFrame(){
int h = 600;
int w = 340;
JFrame frame = new JFrame();
JLabel background1 = new JLabel(new ImageIcon("/res/mariocraft_main.png"));
frame.setResizable(false);
frame.setSize(h, w);
frame.setTitle("MarioCraft");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.add(background1);
background1.setVisible(true);
background1.setIcon(new ImageIcon("/res/mariocraft_main.png"));
background1.setText("Background failed to load");
}
}
-1什么是你的问题的样本代码片段?而不是添加无意义的文本,也许你应该尝试解释你想做什么更彻底 – PTBG
我的意思是我尝试使用JLabel作为背景。问题在标题 – Alek345
你在问什么?你的代码有什么问题?请不要将代码转储到问题中,然后说:“修复它”,解释你想说的话。 –