The button is not being initialized correctly because you set the
attributes of a local JButton which gets destroyed as soon as the
c'tor exits. Instead, use the super() function to call the appropriate
superclass c'tor and then set the remaining attributes as necessary
for the object being constructed.
class mybutton extends JButton {
mybutton(String name) {
super(name);
setBackground(Color.red);
setForeground(Color.white);
setBorder(
new javax.swing.border.CompoundBorder(
new javax.swing.border.SoftBevelBorder(
javax.swing.border.BevelBorder.RAISED),
new javax.swing.border.BevelBorder(
javax.swing.border.BevelBorder.RAISED)));
setBackground(Color.blue);
setForeground(Color.white);
}
}
This uses the JButton(String) c'tor to set the button name, then sets
the attributes of the mybutton being created. Since mybutton
subclasses JButton, all JButton functions will work on mybutton.