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

AWT/Swing Java Discussion :

[mise en page] Comment obtenir cette interface ?


Sujet :

AWT/Swing Java

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    260
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 260
    Points : 131
    Points
    131
    Par défaut [mise en page] Comment obtenir cette interface ?
    Bonjour,

    J'essaie depuis quelques jours, d'obtenir une interface ressemblant à celle ci

    Mais je n'arrive pas à dimensionner les composant de la bonne manière...

    J'utilise un gridbaglayout et plusieurs sous gridbaglayout (un pour la partie gauche, un pour la partie droite et un pour la partie du bas)

    Malheureusement je n'arrive pas à obtenir un résultat acceptable car je n'arrive pas a faire fonctionner les setSize, setPrefferedSize, et autres setMinimumSize etc...

    Par exemple mes deux instance de Class (appellons la plutot A) sont à la bonne taille (enfin à peu près) tant que je n'ajoute pas mes radiobutton, mais dès lors, mes deux instance de A prennent une taille quasi nulle en largeur...

    Donc je voudrais avoir vos conseils pour réussir à obtenir cette interface.

    Merci !

  2. #2
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    essaye ca :-)


    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 java.awt.Color;
    import java.awt.Dimension;
     
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
     
    import java.awt.Insets;
     
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
     
    public class AnotherGridBagLayoutPanel extends JPanel {
        private GridBagLayout gridBagLayout1 = new GridBagLayout();
        private JPanel topLeftPanel = new JPanel();
        private JPanel topRightPanel = new JPanel();
        private JPanel centerPanel = new JPanel();
        private GridBagLayout gridBagLayout2 = new GridBagLayout();
        private JPanel jPanel1 = new JPanel();
        private JRadioButton jRadioButton1 = new JRadioButton();
        private JRadioButton jRadioButton2 = new JRadioButton();
        private JPanel jPanel2 = new JPanel();
        private JRadioButton jRadioButton3 = new JRadioButton();
        private JRadioButton jRadioButton4 = new JRadioButton();
        private JButton jButton1 = new JButton();
        private JButton jButton2 = new JButton();
        private JButton jButton3 = new JButton();
        private JButton jButton4 = new JButton();
        private JPanel jPanel3 = new JPanel();
        private JButton jButton5 = new JButton();
        private JButton jButton6 = new JButton();
     
        public AnotherGridBagLayoutPanel() {
            try {
                jbInit();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
     
        private void jbInit() throws Exception {
            this.setSize(new Dimension(640, 480));
            this.setLayout(gridBagLayout1);
            topLeftPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
            topRightPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
            centerPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
            centerPanel.setLayout(gridBagLayout2);
            jPanel1.setPreferredSize(new Dimension(10, 50));
            jPanel1.setMinimumSize(new Dimension(10, 50));
            jPanel1.setBorder(BorderFactory.createLineBorder(Color.black, 1));
            jRadioButton1.setText("jRadioButton1");
            jRadioButton2.setText("jRadioButton2");
            jPanel2.setMinimumSize(new Dimension(10, 50));
            jPanel2.setSize(new Dimension(520, 50));
            jPanel2.setBorder(BorderFactory.createLineBorder(Color.black, 1));
            jPanel2.setPreferredSize(new Dimension(12, 50));
            jRadioButton3.setText("jRadioButton3");
            jRadioButton4.setText("jRadioButton4");
            jButton1.setText("jButton1");
            jButton1.setPreferredSize(new Dimension(125, 22));
            jButton2.setText("jButton2");
            jButton2.setPreferredSize(new Dimension(125, 22));
            jButton3.setText("jButton3");
            jButton3.setPreferredSize(new Dimension(125, 22));
            jButton4.setText("jButton4");
            jButton4.setPreferredSize(new Dimension(125, 22));
            jPanel3.setBorder(BorderFactory.createLineBorder(Color.black, 1));
            jPanel3.setPreferredSize(new Dimension(12, 50));
            jPanel3.setMinimumSize(new Dimension(12, 50));
            jButton5.setText("jButton5");
            jButton6.setText("jButton6");
            this.add(topLeftPanel,
                     new GridBagConstraints(0, 0, 1, 1, 0.2, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                                            new Insets(5, 5, 5, 5), 0, 0));
            this.add(topRightPanel,
                     new GridBagConstraints(1, 0, GridBagConstraints.REMAINDER,
                                            1, 0.8, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                                            new Insets(5, 5, 5, 5), 0, 0));
            centerPanel.add(jPanel1,
                            new GridBagConstraints(0, 0, 3, 2, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                                                   new Insets(5, 5, 5, 5), 0, 0));
            centerPanel.add(jRadioButton1,
                            new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 0, 10), 0, 0));
            centerPanel.add(jRadioButton2,
                            new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 0, 10), 0, 0));
            centerPanel.add(jPanel2,
                            new GridBagConstraints(0, 2, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                                                   new Insets(5, 5, 5, 5), 0, 0));
            centerPanel.add(jRadioButton3,
                            new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 0, 10), 0, 0));
            centerPanel.add(jRadioButton4,
                            new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 0, 10), 0, 0));
            centerPanel.add(jButton1,
                            new GridBagConstraints(0, 4, 1, 1, 0.25, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 0, 0), 0, 0));
            centerPanel.add(jButton2,
                            new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 5, 5), 0, 0));
            centerPanel.add(jButton3,
                            new GridBagConstraints(2, 4, 1, 1, 0.25, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 0, 0), 0, 0));
            centerPanel.add(jButton4,
                            new GridBagConstraints(1, 4, 1, 1, 0.25, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
                                                   new Insets(5, 5, 0, 0), 0, 0));
            centerPanel.add(jPanel3,
                            new GridBagConstraints(0, 5, 3, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                                                   new Insets(5, 5, 5, 5), 0, 0));
            centerPanel.add(jButton5,
                            new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                                                   new Insets(5, 5, 5, 5), 0, 0));
            centerPanel.add(jButton6,
                            new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                                                   new Insets(5, 5, 5, 5), 0, 0));
            this.add(centerPanel,
                     new GridBagConstraints(0, 1, GridBagConstraints.REMAINDER, 1,
                                            0.0, 0.5, GridBagConstraints.CENTER,
                                            GridBagConstraints.BOTH,
                                            new Insets(5, 5, 5, 5), 0, 0));
        }
    }
    fais tres tres rapidement et pas avec idea.


    ca donne ca
    http://www.developpez.net/forums/att...1&d=1153558899
    Images attachées Images attachées  

  3. #3
    Membre averti Avatar de nicotine002
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    577
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 577
    Points : 409
    Points
    409
    Par défaut
    Allez c'est décider je me met à JDev Bbclone

  4. #4
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    c'est juste, c'est fait avec jdev :-)
    mais tu devrais faire comme moi, j'ai une liste d'ide installer sur ma machine. je peut me debrouiller avec tous mais celui que je prefere est de loin idea.

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    260
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 260
    Points : 131
    Points
    131
    Par défaut
    idea ?? Je connait pas. En tout cas merci beaucoup ca va beaucoup me servir

  6. #6
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Par contre à moins que tu bosses sur un projet open source c'est 500$ la license, avec un grosse réduction si tu es étudiant...

  7. #7
    Expert éminent sénior
    Avatar de Baptiste Wicht
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2005
    Messages
    7 431
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2005
    Messages : 7 431
    Points : 21 324
    Points
    21 324
    Par défaut
    Citation Envoyé par sinok
    Par contre à moins que tu bosses sur un projet open source c'est 500$ la license, avec un grosse réduction si tu es étudiant...
    Il y a une réduction si on est étudiant ? Ca m'intéresserait pas mal si la réduction vaut la peine...

  8. #8
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Pour la license étudiante(99$)
    http://www.jetbrains.com/idea/buy/academic.html

    Pour la license perso (249$)
    http://www.jetbrains.com/idea/buy/personal.html

    Et la license Open Source (gratuite):
    http://www.jetbrains.com/idea/openso...pensource.html

  9. #9
    Expert éminent sénior
    Avatar de Baptiste Wicht
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2005
    Messages
    7 431
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2005
    Messages : 7 431
    Points : 21 324
    Points
    21 324
    Par défaut
    Citation Envoyé par sinok
    Pour la license étudiante(99$)
    http://www.jetbrains.com/idea/buy/academic.html

    Pour la license perso (249$)
    http://www.jetbrains.com/idea/buy/personal.html

    Et la license Open Source (gratuite):
    http://www.jetbrains.com/idea/openso...pensource.html
    Merci beaucoup, je vais aller voir ça

  10. #10
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    je voit que plusieurs developeur swing cherche encore le bon ide pour eux :-)))

    commencer par jdev qui supporte aussi le FormLayout (JGoodies). son gui builder est simple a maitriser. on peut voir le resultat des modification directement a l'ecran, on peut deplacer des composant et il adapte automatiquement le reste de l'interface...

    c'est un bon debut je trouve.
    en plus vous pourrer essayer de comprendre avec le code generer qui n'est pas affreux lui (comparer a d'autre outils)

  11. #11
    Gfx
    Gfx est déconnecté
    Expert éminent
    Avatar de Gfx
    Inscrit en
    Mai 2005
    Messages
    1 770
    Détails du profil
    Informations personnelles :
    Âge : 42

    Informations forums :
    Inscription : Mai 2005
    Messages : 1 770
    Points : 8 178
    Points
    8 178
    Par défaut
    On peut aussi utiliser des outils externes specialises, comme Abeille ou l'excellent JFormDesigner (qui peut generer les fenetres sous forme de fichiers a charger dans l'application, cela ne passe donc pas par de la generation de code; c'est au choix). JFormDesigner a des fonctionnalites assez geniales, notamment pour le support de FormLayout et de GridBagLayout. Aucun outil n'est parfait, n'hesitez pas a en utiliser plusieurs.

  12. #12
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    Ici les outil payant sont mal accepter ;-))
    [juste un sentiment que j'ai en lisant des sujet ici].

  13. #13
    Gfx
    Gfx est déconnecté
    Expert éminent
    Avatar de Gfx
    Inscrit en
    Mai 2005
    Messages
    1 770
    Détails du profil
    Informations personnelles :
    Âge : 42

    Informations forums :
    Inscription : Mai 2005
    Messages : 1 770
    Points : 8 178
    Points
    8 178
    Par défaut
    J'ai la meme impression mais ce n'est pas une raison pour passer a cote :p Pour un usage personnel, je comprends. Quand on travaille pour une entreprise, le prix de ces outils justifie largement la difference de productivite (au prix d'une journee ingenieur par exemple, une licence de 200$ pour JFormDesigner est derisoire). Et puis autant faire un choix en connaissant toutes les possibilites.

Discussions similaires

  1. Réponses: 2
    Dernier message: 20/08/2009, 08h58
  2. Réponses: 3
    Dernier message: 10/11/2007, 18h09
  3. Comment obtenir l'interface de mon programme façon windows XP ?
    Par 21247692 dans le forum Composants VCL
    Réponses: 8
    Dernier message: 26/09/2007, 00h09
  4. [Mise en page] Comment formatter un XML
    Par pmartin8 dans le forum Format d'échange (XML, JSON...)
    Réponses: 2
    Dernier message: 21/09/2006, 18h37
  5. Comment obtenir cette fenetre me permettant de chercher quelque chose sur mon disque
    Par budylove dans le forum Balisage (X)HTML et validation W3C
    Réponses: 11
    Dernier message: 15/05/2006, 15h27

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