Seguinte … Meu problema eh simples porem estranho!!
Eu abro um JDialog com varios TextField`s porem ele nao funcionam corretamente… recebem focu… mas no listener nao mostra… Da pra selecionar o tesmo… mas voce nao visualiza o selecao (nao fica azul) dai tu tem q imaginar de onde ateh onde vai a sua selecao… e o pior de tudo… quando eu clico nao fica o a barrinha piscando mostrando que o focu esta ali… muito sinistro… alguem sabe de algo… eh a segunda vez q tenho esse problema…
Vou colocar o código junto q falvez possa ajudar…
public class ListaColunas extends javax.swing.JDialog implements java.awt.event.ActionListener {
public JCheckBox[] jColunas;
public STextField[] hTCaptions;
private JPanel pLista;
private JScrollPane scrolLista;
private SButton bTodos = new br.com.samuelherrmann.gui.SButton(“All”);
private SButton bNenhum = new br.com.samuelherrmann.gui.SButton(“None”);
private SButton bOk = new br.com.samuelherrmann.gui.SButton(“OK”);
private SButton bCancel = new br.com.samuelherrmann.gui.SButton(“Cancel”);
private HdbTable tabela;
private SLabel[] lTitles = new SLabel[2];
public ListaColunas(DefaultListModel dCOLUNASNAME,DefaultListModel dCOLUNAS,HdbTable TABELA) {
super();
super.setTitle("Field's Configuration");
super.getContentPane().setLayout(new java.awt.GridBagLayout());
tabela = TABELA;
bTodos.addActionListener(this);
bNenhum.addActionListener(this);
bOk.addActionListener(this);
bCancel.addActionListener(this);
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
getContentPane().add(bTodos, gridBagConstraints);
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 9);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
getContentPane().add(bNenhum, gridBagConstraints);
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(4, 9, 4, 4);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
getContentPane().add(bOk, gridBagConstraints);
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
getContentPane().add(bCancel, gridBagConstraints);
lTitles[0] = new SLabel(" Fields");
lTitles[1] = new SLabel(" Caption");
lTitles[0].setBorder(new javax.swing.border.EtchedBorder());
lTitles[1].setBorder(new javax.swing.border.EtchedBorder());
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.insets = new java.awt.Insets(7, 6, 0, 0);
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
getContentPane().add(lTitles[0], gridBagConstraints);
gridBagConstraints.insets = new java.awt.Insets(7, 0, 0, 7);
gridBagConstraints.gridx = 2;
gridBagConstraints.gridwidth = 2;
getContentPane().add(lTitles[1], gridBagConstraints);
jColunas = new javax.swing.JCheckBox[dCOLUNAS.getSize()];
hTCaptions = new STextField[dCOLUNAS.getSize()];
pLista = new javax.swing.JPanel();
pLista.setLayout(new java.awt.GridBagLayout());
pLista.setBackground(Color.white);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 0);
gridBagConstraints.weightx = 50.0;
for(int x = 0; x < dCOLUNAS.getSize(); x++) {
hTCaptions[x] = new br.com.samuelherrmann.gui.STextField((String)dCOLUNAS.getElementAt(x));
//hTCaptions[x].setBorder(new javax.swing.border.LineBorder(new java.awt.Color(212, 208, 200), 1, true));
hTCaptions[x].setPreferredSize(new java.awt.Dimension(120,17));
//hTCaptions[x].setSelectionColor(new java.awt.Color(212, 208, 200));
//hTCaptions[x].setSelectedTextColor(new java.awt.Color(212, 208, 200));
hTCaptions[x].addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(FocusEvent FE) {
System.out.println("Focus");
((SLabel)(FE.getSource())).setForeground(Color.black);
}
public void focusLost(FocusEvent FE){
System.out.println("Lost");
((SLabel)(FE.getSource())).setForeground(new java.awt.Color(212, 208, 200));
}
}
);
jColunas[x] = new javax.swing.JCheckBox((String)dCOLUNASNAME.getElementAt(x));
jColunas[x].setBackground(Color.white);
jColunas[x].setHorizontalAlignment(javax.swing.JCheckBox.LEFT);
jColunas[x].setSelected(true);
jColunas[x].setPreferredSize(new java.awt.Dimension(112,17));
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = x;
if (x + 1 == dCOLUNAS.getSize()) {
gridBagConstraints.weighty = 100.0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
}
pLista.add(jColunas[x], gridBagConstraints);
gridBagConstraints.gridx = 1;
pLista.add(hTCaptions[x], gridBagConstraints);
}
scrolLista = new javax.swing.JScrollPane(pLista);
gridBagConstraints.insets = new java.awt.Insets(0, 6, 6, 7);
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 4;
gridBagConstraints.gridheight = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 100.0;
gridBagConstraints.weighty = 100.0;
getContentPane().add(scrolLista, gridBagConstraints);
super.setSize(260 ,280);
}
//EVENTOS DOS BOTOES
public void actionPerformed(java.awt.event.ActionEvent AE) {
Object oTemp = AE.getSource();
if (oTemp.equals(bNenhum) || oTemp.equals(bTodos)) {
for (int x = 0; x < jColunas.length; x++)
jColunas[x].setSelected(oTemp.equals(bTodos));
}else if (oTemp.equals(bOk)) {
boolean bValid = false;
for (int x = 0; x < jColunas.length; x++) {
if (jColunas[x].isSelected()) {
bValid = true;
break;
}
}
if (!bValid) {
Alert alertaMinimo = new br.com.samuelherrmann.gui.Alert("Atenção");
int s = alertaMinimo.showInfo("Pelo menos um field deve estar selecionado !");
//alertaMinimo = null;
}
for (int x = 0; x < jColunas.length && bValid; x++) {
dColunas.setElementAt(hTCaptions[x].getText(),x);
tableColunas[x].setHeaderValue(hTCaptions[x].getText());
if (bVisiveis[x]) {
if (!jColunas[x].isSelected()) {
tabela.removeColumn(tableColunas[x]);
bVisiveis[x] = false;
int iValorRemovido = iColField[x];
iColField[x] = -1;
for (int xUpdate = 0; xUpdate < iColField.length; xUpdate++) {
if (iColField[xUpdate] > iValorRemovido)
iColField[xUpdate] = iColField[xUpdate] - 1;
}
}
}else if (jColunas[x].isSelected()) {
tabela.addColumn(tableColunas[x]);
iColField[x] = tabela.getColumnCount() - 1;
bVisiveis[x] = true;
}
}
listaColunas.dispose();
updateMedidas();
}else if (oTemp.equals(bCancel)) {
for (int x = 0; x < jColunas.length; x++) {
jColunas[x].setSelected(bVisiveis[x]);
hTCaptions[x].setText((String)dColunas.getElementAt(x));
}
listaColunas.dispose();
}
}
}