Olá pessoal,
Estou com um problema em meu programa que não consigo identificar c é alguma configuração no Eclipse ou algo no cód,
Quando eu clico sobre um JButton ele fica com aparência de como se eu ainda estivesse com o mouse pressionado sob ele !
Eu tenho q clicar novamente sobre o botão para voltar ao status normal
A interface gráfica eu estou criado com o " Jigloo "
Alguém já teve esse problema ?
Tem alguma acction no botão ?
Tchê…
Tem um JToggleButton q pelo q tenho lido por ai, pode ser a causa do problema,
Ele foi inserido automaticamente pelo JIGLOO q uso para fazer a interface gráfica,
Segue abaixo meu cód:
[code]package view;
import EXEMPLOS.Utils;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import javax.swing.;
import java.awt.;
import java.awt.event.*;
import java.lang.Object;
public class Cad_Func extends JFrame implements ActionListener{
static JFrame painel;
private JLabel lnome;
private JTextField txcidade;
private JTextField txdata;
private JToggleButton bcancela;
private JToggleButton blimpa;
private JToggleButton bgrava;
private JComboBox jcuf;
private ButtonGroup bsexo;
private JLabel luf;
private JLabel ldata;
private JLabel lcidade;
private JLabel lcpf;
private JTextField txcpf;
private JTextField txnome;
JButton botao1 = new JButton(“CADASTRAR”);
JButton botao2 = new JButton(“CONSULTAR”);
JButton botao3 = new JButton(“EDITAR”);
JButton botao4 = new JButton(“EXCLUIR”);
public Cad_Func(){
super("CADASTRO DE FUNCIONÁRIO");
painel = new JFrame();
config_Layout();
}
public void initComponent(){
getContentPane().setLayout(null);
getContentPane().add(botao1, new AnchorConstraint(1, 162, 70, 0, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
botao1.setBounds(0, 0, 105, 33);
getContentPane().add(botao2, new AnchorConstraint(1, 324, 70, 162, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
botao2.setPreferredSize(new java.awt.Dimension(105, 33));
botao2.setBounds(105, 0, 105, 33);
getContentPane().add(botao3, new AnchorConstraint(1, 438, 70, 322, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
botao3.setPreferredSize(new java.awt.Dimension(75, 33));
botao3.setBounds(208, 0, 76, 33);
getContentPane().add(botao4, new AnchorConstraint(1, 566, 70, 438, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
botao4.setPreferredSize(new java.awt.Dimension(83, 33));
botao4.setBounds(284, 0, 83, 33);
{
txnome = new JTextField();
getContentPane().add(txnome, new AnchorConstraint(158, 617, 202, 153, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
txnome.setPreferredSize(new java.awt.Dimension(301, 21));
txnome.setBounds(99, 75, 301, 21);
}
{
lnome = new JLabel();
getContentPane().add(lnome, new AnchorConstraint(154, 104, 198, 11, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
lnome.setText(" NOME: ");
lnome.setFont(new java.awt.Font("Tahoma",1,14));
lnome.setPreferredSize(new java.awt.Dimension(60, 21));
lnome.setBounds(7, 73, 60, 21);
}
{
txcpf = new JTextField();
getContentPane().add(txcpf, new AnchorConstraint(246, 381, 290, 153, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
txcpf.setPreferredSize(new java.awt.Dimension(148, 21));
txcpf.setBounds(99, 117, 148, 21);
}
{
txcidade = new JTextField();
getContentPane().add(txcidade, new AnchorConstraint(324, 478, 368, 153, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
txcidade.setPreferredSize(new java.awt.Dimension(211, 21));
txcidade.setBounds(99, 154, 211, 21);
}
{
lcpf = new JLabel();
getContentPane().add(lcpf, new AnchorConstraint(240, 94, 288, 11, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
lcpf.setText("CPF:");
lcpf.setFont(new java.awt.Font("Tahoma",1,14));
lcpf.setPreferredSize(new java.awt.Dimension(54, 23));
lcpf.setBounds(7, 114, 54, 23);
}
{
lcidade = new JLabel();
getContentPane().add(lcidade, new AnchorConstraint(314, 116, 368, 11, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
lcidade.setText("CIDADE:");
lcidade.setFont(new java.awt.Font("Tahoma",1,14));
lcidade.setPreferredSize(new java.awt.Dimension(68, 26));
lcidade.setBounds(7, 149, 68, 26);
}
{
ldata = new JLabel();
getContentPane().add(ldata, new AnchorConstraint(393, 153, 454, 11, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
ldata.setText("DATA NASC:");
ldata.setFont(new java.awt.Font("Tahoma",1,14));
ldata.setPreferredSize(new java.awt.Dimension(92, 29));
ldata.setBounds(7, 187, 92, 29);
}
{
luf = new JLabel();
getContentPane().add(luf, new AnchorConstraint(501, 73, 551, 11, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
getContentPane().add(getJcuf());
getContentPane().add(getTxdata());
getContentPane().add(getBgrava());
getContentPane().add(getBlimpa());
getContentPane().add(getBcancela());
luf.setText("UF:");
luf.setFont(new java.awt.Font("Tahoma",1,14));
luf.setBounds(7, 237, 40, 24);
}
painel. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
painel.pack();
}
private void config_Layout(){
getContentPane().setLayout(null);
botao1.addActionListener(this);
botao2.addActionListener(this);
botao3.addActionListener(this);
botao4.addActionListener(this);
this.setSize(657, 539);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e){
if (e.getSource()==bgrava){
Object source = e.getSource();
if (source instanceof JComponent) {
JComponent component = (JComponent) source;
Container form = component.getTopLevelAncestor();
Funcoes.Utils2.limpaCampos(form);
}
}
}
private ButtonGroup getBsexo() {
if(bsexo == null) {
bsexo = new ButtonGroup();
}
return bsexo;
}
private JComboBox getJcuf() {
if(jcuf == null) {
ComboBoxModel jcufModel =
new DefaultComboBoxModel(
new String[] {“RS”,“SC”,“PR”,“SP”,“RJ”,“AC”,“AM”,“PE”});
jcuf = new JComboBox();
jcuf.setModel(jcufModel);
jcuf.setBounds(99, 237, 42, 29);
}
return jcuf;
}
private JTextField getTxdata() {
if(txdata == null) {
txdata = new JTextField();
txdata.setBounds(99, 187, 117, 29);
}
return txdata;
}
private JToggleButton getBgrava() {
if(bgrava == null) {
bgrava = new JToggleButton();
bgrava.setText(“GRAVAR”);
bgrava.setBounds(99, 361, 93, 31);
}
return bgrava;
}
private JToggleButton getBlimpa() {
if(blimpa == null) {
blimpa = new JToggleButton();
blimpa.setText(“Limpar Campos”);
blimpa.setBounds(237, 363, 130, 29);
}
return blimpa;
}
private JToggleButton getBcancela() {
if(bcancela == null) {
bcancela = new JToggleButton();
bcancela.setText(“CANCELAR”);
bcancela.setBounds(400, 363, 99, 29);
}
return bcancela;
}
}[/code]
O comportamento de um Toggle Button é exatamente esse que você comentou.
Troque por um JButton.
FUNCIONOU !!!
Muito grato pela ajuda.