我正在开发一个程序的主菜单,我发现很难将 .png 文件应用到我的 JButton,这就是我到达的地方
public class Menu extends JFrame implements ActionListener {
public static void main(String[] args) {
Color b = new Color(0,89,255);
Color t = new Color(255,0,0);
Color bttn = new Color (255,255,0);
final JFrame frame = new JFrame ("Main Menu");
frame.setVisible(true);
frame.setSize(1000,750);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setLayout(null);
frame.setBackground(b);
JButton start = new JButton ("Start");
start.setBounds(300, 300, 150, 75);
start.setForeground(t);
JButton exit = new JButton ("Exit");
exit.setBounds(550, 300, 150, 75);
exit.setBackground(bttn);
exit.setForeground(t);
请留下任何答案,因为我想快点