Clicking the Tabs' button doesn't show the components

133 views Asked by At

There is a Tabs component which has two tab :

private Tabs tabClient = new Tabs();
...
tabClient.addTab("Fiche", cFicheClient); // cFicheClient is a Container
tabClient.addTab("Crédits", cClientEtCredits); // cClientEtCredits is a Container
tabClient.addTabsFocusListener(this);

public void focusGained(Component arg0) {
        String noms = Formatage.getColumnValueAt(String.valueOf(fichesignalitique.elementAt(0)).toUpperCase(), 11);
        if (tabClient.getSelectedIndex() == 0)
        {
            setTitle("Fiche signalétique de " + noms);
            photosBtn.requestFocus();
        }
        else
        {
            setTitle("Liste des crédits de " + noms);
            recapClient.requestFocus();
        }
        repaint();
    }

In runtime I cannot click the "Crédits" tab : the Tabs doesn't show the components of the cClientEtCredits Container ! And also the Form's title is not displayed when the Form is shown but I must click one tab button in order to show the Form's title !

So why ?

1

There are 1 answers

0
Shai Almog On

I'm guessing its because of the request focus call within a focus listener.

You should probably change the tab selection before moving the focus to a different component by using something like setSelectedIndex.