Q: Swing Button Look and Feel Based On Size? I have made a JButton:
JButton button = new JButton("Button");

Then added it to a JPanel:
panel.add(button, BorderLayout.CENTER);

Photo of the Button:

I have noticed 2 different types of JButtons:
 
I like the button titled "OK", is there any way I can set this as the preferred style of the button? Or if this can not be done, is there a way to make a panel with a fixed height, and add it to the center of another panel?
Thanks.

A: Overrride getPreferredSize() method but I never suggest you to use it. It's required only  in case of custom painting in AWT and Swing.
JButton btn = new JButton(){
    @Override
    public Dimension getPreferredSize(){
        return new Dimension(40, 40);
    }
};


A: *

*You could just set the margins of the button, and let the layout manager determine the preferred size for you.
button.setMargin(new Insets(0, 30, 0, 30));
                    // top, left, bottom, right


*Make sure the container you add the button to, has a layout manager that respects preferred sizes of its components. See here to see which layouts will and wont respect the preferred sizes

A: Use a layout that respects the preferred size calculated by the button's UI delegate. In this example, each button is added to a panel having FlowLayout; the button retains its preferred size. In contrast, this example adds buttons to a GridLayout; resize the enclosing container to see the effect. A helpful guide is cited here.

A: This is not a style. You have to define size of JButton.
JButton btn = new JButton(String.valueOf(i));
btn.setPreferredSize(new Dimension(40, 40));

