IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SWT/JFace Java Discussion :

ExpandBar dans un wizard


Sujet :

SWT/JFace Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 108
    Points : 57
    Points
    57
    Par défaut ExpandBar dans un wizard
    Bonjour a tous,

    je viens de creer un expandBar en SWT/jface et je veux savoir comment personaliser celui-ci.
    Je veux changer le style mais je ne sais pas comment faire. J'arrive a changer la couleur mais seulement en rouge ou bleu ect... mais c'est pas très beau a voir

    merci de votre aide

  2. #2
    Membre averti

    Profil pro
    Inscrit en
    Août 2006
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Août 2006
    Messages : 218
    Points : 305
    Points
    305
    Par défaut
    Bonjour

    Que veux-tu dire par "personnaliser" ? Car à part changer la couleur, la police de caractères, l'icône, on ne peut pas faire grand'chose.

    Laurent

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 108
    Points : 57
    Points
    57
    Par défaut
    Citation Envoyé par meddle Voir le message
    Bonjour

    Que veux-tu dire par "personnaliser" ? Car à part changer la couleur, la police de caractères, l'icône, on ne peut pas faire grand'chose.

    Laurent
    Bonjour laurent,

    c'est exactement ce que je veux!!! changer la police, l'icone et la couleur( une couleur degradé ci possible parce que les couleurs proposées ne sont pas très beau a voir)
    Quelles sont les methodes pour cela?
    merci

  4. #4
    Membre averti

    Profil pro
    Inscrit en
    Août 2006
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Août 2006
    Messages : 218
    Points : 305
    Points
    305
    Par défaut
    Bonjour,

    Toutes mes excuses, j'ai confondu ExpandBar et Pgroup

    Sur expandbar, on peut simplement changer l'image sur le titre de l'item.

    Par contre, avec pgroup (http://www.eclipse.org/nebula/widgets/pgroup/pgroup.php) tu peux t'amuser !

    Laurent

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 108
    Points : 57
    Points
    57
    Par défaut
    merci laurent


    est ce que tu peux me dire si on peut bloquer l'ouverture ou la fermeture d'un ExpandBar??

    A part la methode "setExpanded();" je vois pas trop

    je veux que si un evenement(entree clavier) se produit mon expandBar se ferme mais reste fermé c'est a dire qu'on peut plus le derouler!!

    j'ai essayé la methode "dispose()" mais je narrive pas a faire le contraire de cette methode!! je suis obligé de creer a nouveau le expandBar dc c pas interessant!!
    merci d'avance

  6. #6
    Membre averti

    Profil pro
    Inscrit en
    Août 2006
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Août 2006
    Messages : 218
    Points : 305
    Points
    305
    Par défaut
    Alors c'est possible en mettant un listener sur l'événement SWT.Expand.
    En toute logique on devrait faire ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
            bar.addListener(SWT.Expand, new Listener() {
     
                @Override
                public void handleEvent(Event e) {
                    if (e.item != item1) {
                        return;
                    }
                    if (lock) {
                        e.doit=false;
                    }
                }
            });
    Mais il y a un bug dans SWT (sous windows en tout cas), ca ne fonctionne pas. Il faut feinter en lui disant d'ouvrir l'Expanditem, car ensuite il va le fermer (c'est bien l'Open Source, on voit tout de suite les problèmes) :

    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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
     
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.ExpandBar;
    import org.eclipse.swt.widgets.ExpandItem;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Shell;
     
    public class Test {
        protected static boolean lock = false;
     
        public static void main(String[] args) {
            Display display = new Display();
            Shell shell = new Shell(display);
            shell.setLayout(new GridLayout(1, true));
            shell.setText("ExpandBar Example");
            ExpandBar bar = new ExpandBar(shell, SWT.V_SCROLL);
            bar.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
     
            Image image = display.getSystemImage(SWT.ICON_QUESTION);
     
            // First item
            Composite composite = new Composite(bar, SWT.NONE);
            GridLayout layout = new GridLayout();
            layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
            layout.verticalSpacing = 10;
            composite.setLayout(layout);
            Button button = new Button(composite, SWT.PUSH);
            button.setText("SWT.PUSH");
            button = new Button(composite, SWT.RADIO);
            button.setText("SWT.RADIO");
            button = new Button(composite, SWT.CHECK);
            button.setText("SWT.CHECK");
            button = new Button(composite, SWT.TOGGLE);
            button.setText("SWT.TOGGLE");
     
            ExpandItem item0 = new ExpandItem(bar, SWT.NONE, 0);
            item0.setText("What is your favorite button");
            item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
            item0.setControl(composite);
     
            // Modification de l'image
            item0.setImage(image);
     
            // Second item
            composite = new Composite(bar, SWT.NONE);
            layout = new GridLayout(2, false);
            layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
            layout.verticalSpacing = 10;
            composite.setLayout(layout);
            Label label = new Label(composite, SWT.NONE);
            label.setImage(display.getSystemImage(SWT.ICON_ERROR));
            label = new Label(composite, SWT.NONE);
            label.setText("SWT.ICON_ERROR");
            label = new Label(composite, SWT.NONE);
            label.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
            label = new Label(composite, SWT.NONE);
            label.setText("SWT.ICON_INFORMATION");
            label = new Label(composite, SWT.NONE);
            label.setImage(display.getSystemImage(SWT.ICON_WARNING));
            label = new Label(composite, SWT.NONE);
            label.setText("SWT.ICON_WARNING");
            label = new Label(composite, SWT.NONE);
            label.setImage(display.getSystemImage(SWT.ICON_QUESTION));
            label = new Label(composite, SWT.NONE);
            label.setText("SWT.ICON_QUESTION");
     
            final ExpandItem item1 = new ExpandItem(bar, SWT.NONE, 1);
            item1.setText("What is your favorite icon");
            item1.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
            item1.setControl(composite);
            item1.setImage(image);
     
            item1.setExpanded(true);
            bar.setSpacing(8);
     
            final Button bouton = new Button(shell, SWT.TOGGLE);
            bouton.setText(" Lock ");
            bouton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
            bouton.addSelectionListener(new SelectionAdapter() {
     
                /**
                 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
                 */
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (item1.getExpanded() && bouton.getSelection()) {
                        item1.setExpanded(false);
                    }
                    lock = bouton.getSelection();
                }
            });
     
            bar.addListener(SWT.Expand, new Listener() {
     
                @Override
                public void handleEvent(Event e) {
                    if (e.item != item1) {
                        return;
                    }
                    if (lock) {
                        item1.setExpanded(true);
                    }
                }
            });
            shell.setSize(400, 350);
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    display.sleep();
                }
            }
            image.dispose();
            display.dispose();
        }
     
    }
    Voilà,

    Laurent

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 108
    Points : 57
    Points
    57
    Par défaut
    Merci bcp laurent t'es trop fort!!!

  8. #8
    Membre averti

    Profil pro
    Inscrit en
    Août 2006
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Août 2006
    Messages : 218
    Points : 305
    Points
    305
    Par défaut
    N'oublie pas de mettre le post en résolu

  9. #9
    Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 108
    Points : 57
    Points
    57
    Par défaut
    c'est fait

    derniere question::


    je veux creer plein de ExpandBar dans mon wizard
    et je veux mettre dans chaque expandbar une liste( ou je peux ajouter des item et en effacer) et juste a coté de cette liste des expandBar en relation avec les liste!!!
    c'est possible de mettre des expandBar dans des expandBar?? si oui commen faire?


    je veux aussi etre conseillé sur les agent de placement a utiliser et si il ya des exemple je suis preneur =)

    merci bcp

  10. #10
    Membre averti

    Profil pro
    Inscrit en
    Août 2006
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Août 2006
    Messages : 218
    Points : 305
    Points
    305
    Par défaut
    Bonjour,

    Oui c'est possible :
    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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
     
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.ExpandBar;
    import org.eclipse.swt.widgets.ExpandItem;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Shell;
     
    public class Test {
     
        public static void main(String[] args) {
            Display display = new Display();
            Shell shell = new Shell(display);
            shell.setLayout(new GridLayout(1, true));
            shell.setText("ExpandBar Example");
            ExpandBar bar = new ExpandBar(shell, SWT.V_SCROLL);
            bar.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
     
            Image image = display.getSystemImage(SWT.ICON_QUESTION);
     
            // First item
            Composite composite = new Composite(bar, SWT.NONE);
            GridLayout layout = new GridLayout();
            layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
            layout.verticalSpacing = 10;
            composite.setLayout(layout);
            Button button = new Button(composite, SWT.PUSH);
            button.setText("SWT.PUSH");
            button = new Button(composite, SWT.RADIO);
            button.setText("SWT.RADIO");
            button = new Button(composite, SWT.CHECK);
            button.setText("SWT.CHECK");
            button = new Button(composite, SWT.TOGGLE);
            button.setText("SWT.TOGGLE");
     
            ExpandItem item0 = new ExpandItem(bar, SWT.NONE, 0);
            item0.setText("What is your favorite button");
            item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
            item0.setControl(composite);
     
            // Modification de l'image
            item0.setImage(image);
     
            // Second item : Création de l'expand bar...
            composite = new Composite(bar, SWT.NONE);
            composite.setLayout(new FillLayout());
            ExpandBar bar2 = new ExpandBar(composite, SWT.V_SCROLL);
     
     
            final ExpandItem item1 = new ExpandItem(bar, SWT.NONE, 1);
            item1.setText("Item 2");
            item1.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
            item1.setControl(composite);
            item1.setImage(image);              
     
     
            // Et création de l'item dans l'expand bar
            composite = new Composite(bar2, SWT.NONE);
            layout = new GridLayout(2, false);
            layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
            layout.verticalSpacing = 10;
            composite.setLayout(layout);
            Label label = new Label(composite, SWT.NONE);
            label.setText("SWT.ICON_ERROR");
     
            final ExpandItem itemInside = new ExpandItem(bar2, SWT.NONE, 0);
            itemInside.setText("Item inside");
            itemInside.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
            itemInside.setControl(composite);
            itemInside.setImage(image);              
     
     
     
            item1.setExpanded(true);
            bar.setSpacing(8);
     
            shell.setSize(400, 350);
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    display.sleep();
                }
            }
            image.dispose();
            display.dispose();
        }
     
    }
    Pour les gestionnaires de placement, mon préféré est le gridlayout, mais le rowLayout est très bien aussi

    Laurent

  11. #11
    Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 108
    Points : 57
    Points
    57
    Par défaut
    merci bcp laurent
    il ya juste le item inside qui ne s'affiche pas en entier(il ya le scroll mais c'est moche qd il ya pas bcp d'element a l'interieur)
    comment afficher le item inside en entier ?

  12. #12
    Membre averti

    Profil pro
    Inscrit en
    Août 2006
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Août 2006
    Messages : 218
    Points : 305
    Points
    305
    Par défaut
    Décidément, tu es insatiable !)

    Pour afficher le itemInside en entier, il te faut forcer la taille du parent :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    item1.setHeight(200); // Hauteur de 200 pixels
    Laurent

  13. #13
    Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 108
    Points : 57
    Points
    57
    Par défaut
    Citation Envoyé par meddle Voir le message
    Décidément, tu es insatiable !)

    Laurent

    je veux que ca soit parfait c'est pour ca
    merci bcp laurent t'assure

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. scroll vertical dans un wizard
    Par doudoubens dans le forum SWT/JFace
    Réponses: 16
    Dernier message: 12/04/2009, 22h06
  2. [2.0] Impossible d'ajouter des contrôles dans un Wizard
    Par franculo_caoulene dans le forum ASP.NET
    Réponses: 1
    Dernier message: 21/09/2008, 13h03
  3. [NB Platform 5.5] Touche F1 dans un wizard?
    Par hobstad dans le forum NetBeans
    Réponses: 1
    Dernier message: 10/09/2007, 15h16
  4. methode isValid dans le wizard API de netbeans
    Par mhamedbj dans le forum NetBeans
    Réponses: 5
    Dernier message: 03/06/2007, 18h47
  5. Sauter des étapes dans un Wizard
    Par maXrez dans le forum ASP.NET
    Réponses: 2
    Dernier message: 27/04/2007, 10h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo