import java.awt.*;
import javax.swing.*;
public class Game
{
MyDrawPanel draw;
public static void main(String[] args)
{
new Game().go();
}
public void go()
{
JFrame frame=new JFrame("Revenge");
JPanel panel=new JPanel();
draw=new MyDrawPanel();
frame.getContentPane().add(BorderLayout.CENTER,draw);
frame.setSize(750,360);
frame.setVisible(true);
}
public class MyDrawPanel extends JPanel
{
@Override
public void paintComponent(Graphics g)
{
Image image=new ImageIcon("C:\\Users\\zep\\Desktop\\title.png").getImage();
g.drawImage(image,0,0,this);
}
}
}
所以基本上我需要帮助来尝试添加一个按钮。我对 java 非常陌生,我需要在课堂上为我的 CPT 做这个。请帮助你成为我的英雄:3