This is the result i want : https://i.stack.imgur.com/N9xWD.jpg , but centered using BorderLayout. Instead, i get this :https://i.stack.imgur.com/mXJgp.jpg . So, basically setting a layout resets my background and puts the button on the whole frame:
frame.setContentPane(new Pane());
frame.getContentPane().setBackground(Color.GRAY);
I've also tried this:
JPanel panel = new JPanel();
panel.add(bStart);
add(panel, BorderLayout.CENTER);
But it doesn't work.
public class Pane extends JPanel{
public Pane(){
ImageIcon start = new ImageIcon("Start.png");
ImageIcon startroll = new ImageIcon("Start-Hover.png");
ImageIcon startselect = new ImageIcon("Start-Pressed.png");
JButton bStart = new JButton(start);
Insets margin = new Insets(-10,-10,-10,-10);
bStart.setMargin(margin);
bStart.setRolloverEnabled(true);
bStart.setRolloverIcon(startroll);
bStart.setPressedIcon(startselect);
bStart.setBorderPainted(false);
setLayout(new BorderLayout());
add(bStart, BorderLayout.CENTER);