Bonjour,

J'ai un souci d'affichage d'un JToolBar dans un JPanle (voir pièce jointe : mauvaisAffichage.jpg).

je souhaite avoir le combo en haut et les autres juste au dessus (voir pièce jointe : bonAffichage.jpg).

Voici le bout de code que j'ai utilisé pour cette bar qui contient le JComboBox:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
private JToolBar getTopToolBar() {
        if (this.topToolBar == null) {
            initCtHelp();
            // Create the tool bar containing OIS Control functionnalities.
            this.topToolBar = new JToolBar();
            // Set the layout of the tool bar.
            this.topToolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 25, 0));
            // Set the tool bar unfloatable.
            this.topToolBar.setFloatable(false);
 
 
 
            // Initialize the effectivity combo box.
            this.effectivityComboBox = new EffectivityComboBox(
 
                    CTWrapperLPCNGConfigurationLoader.getInstance(),CLASSNAME
                    + IConfigurationLoader.PROPERTY_SEPARATOR
                    + "effectivityComboBox",getHelpBroker(), isHelpActive());
 
            getCtWrapperLPCNG().addCtPropertyChangeListener(CTWrapperLPCNG.CURRENT_DU_KEY,
                    this.effectivityComboBox);
 
//            getCtWrapperLPCNG().add
//            ctWrapper
//                    .addEffectivityChangedFromBasketListener(this.effectivityComboBox);
//
            // Model
            // Initialize the combo box model.
            final EffectivityComboBoxModel comboBoxModel = new EffectivityComboBoxModel(
                    getCtWrapperLPCNG());
 
            // Attach the model to the combo box
            this.effectivityComboBox.setModel(comboBoxModel);
 
            // Action
            final EffectivityAction eAction = new EffectivityAction();
            this.effectivityComboBox.setAction(eAction);
            this.effectivityComboBox.setActionCommand((String) eAction
                    .getValue(Action.ACTION_COMMAND_KEY));
 
            // Add the effectivity combo box to the top tool bar.
            this.topToolBar.add(this.effectivityComboBox);
            // Register the effectivity combo box.
            this.effectivityComboBox.register();
        }
        return this.topToolBar;
    }
et voici le code qui ajoute ce JToolBar au JPanel :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
JPanel jPanel = new JPanel();
 
LpcngToolBar lpcngToolBar = new LpcngToolBar(this);
lpcngToolBar.setVisible(true);
jPanel.add(lpcngToolBar,BorderLayout.NORTH);
Avez-vous uen solution s'il vous plaît?.