Ricardosis, fiz um exemplo (aproveitando o seu) de como fazer para pintar um JButton. Neste exemplo a escrita do botão não aparece, pois ela também é um desenho e a pintura sobrepoe a escrita. Para fazer a escreita deve-se usar o metodo drawString, do proprio Graphics.
mas acho que desta maneira já da pra vc tirar uma ideia.
Apenas para lembrar, a maioria dos componentes Swing possui um método paintComponent, desta forma é possivel fazer isto com quase todos os componentes.
resumindo…
apenas crie uma subclasse daquela que vc quer pintar, e utilize o metodo paintComponent.
segue o código
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class teste extends JFrame {
private JButton bAbrir,bSalvar;
private ButtonGroup bg;
private JRadioButton fixa,celular;
public teste(){
super("Teste");
painel pane = new painel(this);
setContentPane(pane);
setLayout(null);
setBounds(100,100,328,175);
// setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bAbrir=new NovoBotao();
bAbrir.setBounds(30,30,45,35);
pane.add(bAbrir);
bSalvar=new NovoBotao();
bSalvar.setBounds(85,30,45,35);
pane.add(bSalvar);
fixa=new JRadioButton();
fixa.setBounds(165,40,20,20);
pane.add(fixa);
celular=new JRadioButton();
celular.setBounds(165,60,20,20);
pane.add(celular);
bg=new ButtonGroup();
bg.add(fixa);
bg.add(celular);
setVisible(true);
}
public static void main(String args[]){
JFrame dp=new teste();
}
}
class painel extends JPanel {
JFrame frame;
painel(JFrame frame) {
this.frame = frame;
}
public void paintComponent(Graphics comp) {
Graphics2D graf = (Graphics2D)comp;
Dimension dim = frame.getSize();
float wi = dim.width;
float hei = dim.height;
GradientPaint cor1 = new GradientPaint(0,wi/8,new Color(253,253,253),0,wi/4,new Color(204,206,217));
graf.setPaint(cor1);
graf.fillRect(0,0,(int)wi,(int)hei);
}
}
class NovoBotao extends JButton {
public void paintComponent(Graphics comp) {
Graphics2D graf = (Graphics2D)comp;
Dimension dim = this.getSize();
float wi = dim.width;
float hei = dim.height;
GradientPaint cor1 = new GradientPaint(0,wi/8,Color.green,0,wi/4,Color.yellow);
graf.setPaint(cor1);
graf.fillRect(0,0,(int)wi,(int)hei);
}
}