我想从图像中制作 JButton。但是当我这样做时:
private void AddMainActionsButtons(Container powZawartosci){
  JPanel mainActionButtons = new JPanel();
  JButton applyButton = createImageButton("obrazki/apply.png");
  mainActionButtons.add(applyButton);
  powZawartosci.add(mainActionButtons);
  mainActionButtons.setBounds(150,530,400,90);
}
private JButton createImageButton(String imagePath){
  ImageIcon icon = uploadImage(imagePath,"");
  JButton button = new JButton(icon);
  return button;
}
JButton 看起来很糟糕,因为图像在按钮组件内,实际上我在图像上得到了图像。如何创建与我的图像一样大的 JButton,以及如何 100% 覆盖它。换句话说:如何使我的图像成为按钮?

