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 :

gridbagLayout et poids


Sujet :

AWT/Swing Java

  1. #1
    Membre éclairé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2007
    Messages
    697
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2007
    Messages : 697
    Par défaut gridbagLayout et poids
    Bonsoir,
    j'ai codé une application utilisant le gridBagLayout et j'ai apparement un problème de poids.
    J'ai un composant qui prend plus de place que je lui en ai "fourni".Ci-joint deux screen qui montre mon problème:
    -Le premier montre l'application tel quelle est actuellement
    -Le second tel que je la veux
    Dans le deuxieme, j'ai enlever tous les composant que j'ajoutais à mon panel en bas à gauche.Et là il occupe bien la place que je veux. Apparemment ça dois etre lié au bouton qui sont pas redimensionner.
    Le code de mon panel en bas à gauche
    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
     
            setBackground(Color.DARK_GRAY);
            setLayout(new GridBagLayout());
     
            GBC gbcScoreNom = new GBC(0,0,1,1).setWeight(7, 1)
            .setFill(GBC.BOTH).setInsets(10);
            GBC gbcChevalet = new GBC(0,1,1,2).setWeight(7, 1)
            .setFill(GBC.BOTH).setInsets(0,10,10,10);
            GBC gbcPanelJocker = new GBC(1,0,2,1).setWeight(1, 1)
            .setFill(GBC.BOTH).setInsets(10, 0,10,10);
     
            GBC gbcBoutonJocker = new GBC(1,1,1,1).setWeight(1, 0).setInsets(30,0,0,0);
            GBC gbcBoutonPiocher = new GBC(2,1,1,1).setWeight(1, 0).setInsets(30,0,0,0);
            GBC gbcBoutonEchanger = new GBC(2,2,1,1).setWeight(1, 0).setInsets(0,0,0,0);
            GBC gbcBoutonFinTour = new GBC(1,2,1,1).setWeight(1, 0).setInsets(0,0,0,0);
     
            this.scorePanel = new TextPanel();
            this.chevaletView = new RackView();
            this.panelJocker = new JockerPanel();
            this.boutonJocker = new RoundButton("Jocker",this);
            this.boutonPiocher = new RoundButton("Piocher",this);
            this.boutonEchanger = new RoundButton("Echanger",this);
            this.boutonFinTour = new RoundButton("Fin du tour",this);
     
            //this.add(scorePanel,gbcScoreNom);
            //this.add(chevaletView,gbcChevalet);
            //this.add(panelJocker, gbcPanelJocker);
            //this.add(boutonJocker, gbcBoutonJocker);
            //this.add(boutonPiocher, gbcBoutonPiocher);
            //this.add(boutonEchanger, gbcBoutonEchanger);
            //this.add(boutonFinTour, gbcBoutonFinTour);
     
            boutonJocker.setEnabled(false);
            boutonPiocher.setEnabled(false);
            boutonEchanger.setEnabled(false);
            boutonFinTour.setEnabled(false);
    Le code de mon panel principal:
    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
     
    this.controller = controller;
            this.model = model;
     
            this.actionPanel = new ActionPanel();
            this.infoPanel = new StatistiquePanel();
            Board board = model.getBoard();
            this.boardView = new BoardView(board);        
            board.addObserver(boardView);
            this.laPiochePanel = new PiochePanel();
     
            this.setLayout(new GridBagLayout());
            GBC gbcAction = new GBC(0, 1, 2,1).setWeight(0, 1).setFill(GBC.BOTH); 
            GBC gbcPioche = new GBC(0, 0, 1,1).setWeight(3, 3).setFill(GBC.BOTH);
            GBC gbcPlateau = new GBC(1, 0, 1,1).setWeight(7, 3).setFill(GBC.BOTH);
            GBC gbc1nfo = new GBC(2, 0, 1,2).setWeight(4, 1).setFill(GBC.BOTH);
            this.add(infoPanel, gbc1nfo);    
            this.add(laPiochePanel,gbcPioche);
            this.add(boardView,gbcPlateau);    
            this.add(actionPanel,gbcAction);
    Si quelqu'un arrive à comprendre mon problème je l'en remerci d'avance
    Images attachées Images attachées   

  2. #2
    Membre chevronné Avatar de xixi31
    Inscrit en
    Juin 2005
    Messages
    423
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Juin 2005
    Messages : 423
    Par défaut
    j'imagine que GBC est une classe à toi qui facilite la manipulation de GridBagConstraints?

  3. #3
    Membre éclairé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2007
    Messages
    697
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2007
    Messages : 697
    Par défaut
    En faite elle n'est pas à moi, je crois quelle est disponible sur ce site. En tout cas la voilà
    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
    /**
       This class simplifies the use of the GridBagConstraints
       class.
    */
    public class GBC extends GridBagConstraints
    {
       /**
          Constructs a GBC with a given gridx and gridy position and
          all other grid bag constraint values set to the default.
          @param gridx the gridx position
          @param gridy the gridy position
       */
       public GBC(int gridx, int gridy)
       {
          this.gridx = gridx;
          this.gridy = gridy;
       }
     
       /**
          Constructs a GBC with given gridx, gridy, gridwidth, gridheight
          and all other grid bag constraint values set to the default.
          @param gridx the gridx position
          @param gridy the gridy position
          @param gridwidth the cell span in x-direction
          @param gridheight the cell span in y-direction
       */
       public GBC(int gridx, int gridy, int gridwidth, int gridheight)
       {
          this.gridx = gridx;
          this.gridy = gridy;
          this.gridwidth = gridwidth;
          this.gridheight = gridheight;
       }
     
       /**
          Sets the anchor.
          @param anchor the anchor value
          @return this object for further modification
       */
       public GBC setAnchor(int anchor)
       {
          this.anchor = anchor;
          return this;
       }
     
       /**
          Sets the fill direction.
          @param fill the fill direction
          @return this object for further modification
       */
       public GBC setFill(int fill)
       {
          this.fill = fill;
          return this;
       }
     
       /**
          Sets the cell weights.
          @param weightx the cell weight in x-direction
          @param weighty the cell weight in y-direction
          @return this object for further modification
       */
       public GBC setWeight(double weightx, double weighty)
       {
          this.weightx = weightx;
          this.weighty = weighty;
          return this;
       }
     
       /**
          Sets the insets of this cell.
          @param distance the spacing to use in all directions
          @return this object for further modification
       */
       public GBC setInsets(int distance)
       {
          this.insets = new Insets(distance, distance, distance, distance);
          return this;
       }
     
       /**
          Sets the insets of this cell.
          @param top the spacing to use on top
          @param left the spacing to use to the left
          @param bottom the spacing to use on the bottom
          @param right the spacing to use to the right
          @return this object for further modification
       */
       public GBC setInsets(int top, int left, int bottom, int right)
       {
          this.insets = new Insets(top, left, bottom, right);
          return this;
       }
     
       /**
          Sets the internal padding
          @param ipadx the internal padding in x-direction
     
          @param ipady the internal padding in y-direction
          @return this object for further modification
       */
       public GBC setIpad(int ipadx, int ipady)
       {
          this.ipadx = ipadx;
          this.ipady = ipady;
          return this;
       }
    }

Discussions similaires

  1. [Swing] probleme de GridBagLayout
    Par calypso dans le forum Agents de placement/Fenêtres
    Réponses: 4
    Dernier message: 13/04/2005, 17h26
  2. [débutant]GridBagLayout
    Par pingoui dans le forum Agents de placement/Fenêtres
    Réponses: 4
    Dernier message: 13/12/2004, 17h43
  3. Réponses: 2
    Dernier message: 07/10/2004, 14h16
  4. [MX]optimisation poids swf
    Par Dra_Gun dans le forum Flash
    Réponses: 5
    Dernier message: 03/03/2004, 09h30
  5. [Antialiasing][Wu][poids]
    Par JHelp dans le forum Algorithmes et structures de données
    Réponses: 8
    Dernier message: 22/12/2002, 00h17

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