Fala pessoal eu aquiii mais uma vez para atormentar voces, estou com mais um problema, que é o fundo do botao…
Bom tenho um fundo degradê no formato PNG, porém oq eu escrevi no JButton simplesmente nao aparece, como posso fazer isso ??
[code]package projeto_vinny;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.event.*;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
public class Interface extends JFrame implements ActionListener, MouseListener {
JPanel PnlFundo;
Color CorFundo, CorBotao;
JButton BtnCredito;
String StrPath = System.getProperty("user.dir");
ImageIcon ImgBotao;
public Interface() {
/*Instanciar coisas*/
BtnCredito = new JButton();
CorBotao = new Color(61, 61, 61);
CorFundo = new Color(102, 102, 102);
PnlFundo = new JPanel();
ImgBotao = new ImageIcon(StrPath + "/src/Imagens/Button.png");
/*Setar propriedades JFrame*/
setBounds(0, 0, 400, 300);
setTitle("Menu Principal");
/*Setar propriedades PnlFundo*/
PnlFundo.setLayout(null);
PnlFundo.setBackground(CorFundo);
PnlFundo.setBounds(0, 0, getWidth(), getHeight());
/*Setar propriedades BtnCredito*/
BtnCredito.setBackground(null);
BtnCredito.setForeground(Color.WHITE);
//BtnCredito.setBorder(null);
BtnCredito.setIcon(ImgBotao);
BtnCredito.setBounds(0, 0,100,100);
BtnCredito.setText("Adicionar crédito");
BtnCredito.addActionListener(this);
BtnCredito.addMouseListener(this);
/*Adicionar componentes na janela*/
PnlFundo.add(BtnCredito);
getContentPane().add(PnlFundo);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void mouseClicked(MouseEvent e) {
}
public void mouseExited(MouseEvent Evento) {
Object ObjEvento;
ObjEvento = Evento.getSource();
if (ObjEvento == BtnCredito) {
BtnCredito.setBackground(CorBotao);
}
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent Evento) {
Object ObjEvento;
ObjEvento = Evento.getSource();
if (ObjEvento == BtnCredito) {
BtnCredito.setBackground(CorBotao);
}
}
public void actionPerformed(ActionEvent Evento) {
Object objetoRecebeuEvento;
objetoRecebeuEvento = Evento.getSource();
//Caso aperte no botao cancelar
if (objetoRecebeuEvento == BtnCredito) {
this.dispose(); // desalocar objetos da memoria
System.exit(0); // retorna ao Sistema Operacional
}
}
}
[/code]