I want to make JButton from image. But when i do it like this:
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 looks bad, because image is inside button component, and in fact I got image on image. How can I create as big JButton as my image, and how to cover it by image in 100%. In other words: how to make my image be a Button?