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

Agents de placement/Fenêtres Java Discussion :

[JDialog] largeur non modifiable ?


Sujet :

Agents de placement/Fenêtres Java

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut [JDialog] largeur non modifiable ?
    Bonjour,
    Je reprend le travail de quelqu'un qui a créer une JDialog pour réaliser unToolBar, (je ne sais pas pourquoi il n'a pas utilisé directement une JToolBar), bref, il a donc créer des JRadioButton formé d'une icone, et ces boutons font partis d'un ButtonGroup.

    le truc c'est que visuellement voila le résultat :
    il y a de gros espace entre les boutons, j'ai esayé de faire des resize dessus, en faisant des setSize, mais rien a faire la largeur ne veut pas diminuer, si je met la fenetre a setResizable(true); je ne peut pas aller au dela de cette largeur critique. pourtant j'ai bo voir le code je ne comprends pas.
    j'insere mes composant dans un GridBagLayout, et aucun inset n'est définit...
    je vous joint le code , si vous voyez d'ou cela peut venir :
    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
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
     
    public class DesignBar extends JDialog {
      public final static Dimension     DESIGN_BUTTON_SIZE                = new Dimension(30, 30);
     
      private JPanel jContentPane = null;
      private JRadioButton selectButton = null;
    ...  private JRadioButton analogButton = null;
     
      public DesignBar(...) {
        super();
        initialize();
     
    // Les 14 boutons sont inséré dans le ButtonGroup.
        ButtonGroup group = new ButtonGroup();
        group.add(selectButton);
    ...    group.add(analogButton);
      }
     
      private void initialize() {
        //this.setSize(new java.awt.Dimension(110,245));
        //this.setSize(new java.awt.Dimension(110,245));
        this.setSize(new java.awt.Dimension(70,245));
        this.setTitle(ParameterUI.DESIGN_BAR_TITLE);
        this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        this.setAlwaysOnTop(true);
        this.setResizable(false);
        this.setContentPane(getJContentPane());
      }
     
      private JPanel getJContentPane() {
        if (jContentPane == null) {
          GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
          gridBagConstraints13.gridy = 6;
          gridBagConstraints13.gridx = 1;
          gridBagConstraints13.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
          gridBagConstraints12.gridy = 6;
          gridBagConstraints12.gridx = 0;
          gridBagConstraints12.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
          gridBagConstraints11.gridy = 5;
          gridBagConstraints11.gridx = 1;
          gridBagConstraints11.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
          gridBagConstraints10.gridx = 0;
          gridBagConstraints10.gridy = 5;
          gridBagConstraints10.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
          gridBagConstraints9.gridy = 4;
          gridBagConstraints9.gridx = 1;
          gridBagConstraints9.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
          gridBagConstraints8.gridx = 0;
          gridBagConstraints8.gridy = 4;
          gridBagConstraints8.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
          gridBagConstraints7.gridy = 3;
          gridBagConstraints7.gridx = 1;
          gridBagConstraints7.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
          gridBagConstraints6.gridx = 0;
          gridBagConstraints6.gridy = 3;
          gridBagConstraints6.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
          gridBagConstraints5.gridy = 2;
          gridBagConstraints5.gridx = 1;
          gridBagConstraints5.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
          gridBagConstraints4.gridx = 0;
          gridBagConstraints4.gridy = 2;
          gridBagConstraints4.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
          gridBagConstraints3.gridy = 1;
          gridBagConstraints3.gridx = 1;
          gridBagConstraints3.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
          gridBagConstraints2.gridx = 0;
          gridBagConstraints2.gridy = 1;
          gridBagConstraints2.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
          gridBagConstraints1.gridy = 0;
          gridBagConstraints1.weightx = 1.0D;
          gridBagConstraints1.gridx = 1;
          gridBagConstraints1.insets = new Insets(0,0,0,0);
          GridBagConstraints gridBagConstraints = new GridBagConstraints();
          gridBagConstraints.gridx = 0;
          gridBagConstraints.weightx = 1.0D;
          gridBagConstraints.gridy = 0;
          gridBagConstraints.insets = new Insets(0,0,0,0);
          jContentPane = new JPanel();
          //jContentPane.setPreferredSize(new java.awt.Dimension(0,0));
          jContentPane.setLayout(new GridBagLayout());
    // Les 14 boutons sont inséré de la meme facon.
          jContentPane.add(getSelectButton(), gridBagConstraints);
          jContentPane.add(getLineButton(), gridBagConstraints1);
    ....      jContentPane.add(getAnalogButton(), gridBagConstraints13);
        }
        return jContentPane;
      }
     
      public JRadioButton getSelectButton() {
        if (selectButton == null) {
          selectButton = new JRadioButton();
          selectButton.setIcon(ParameterUI.createImageIcon(ParameterUI.DESIGN_UNSELECTED_SELECT));
          selectButton.setSelectedIcon(ParameterUI.createImageIcon(ParameterUI.DESIGN_SELECTED_SELECT));
          selectButton.setSelected(true);
          selectButton.setPreferredSize(DESIGN_BUTTON_SIZE);
          selectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
              pac7000UI.getSelectionButtonMenuItem().setSelected(selectButton.isSelected());
              if (selectButton.isSelected()) {
                setType(DesignPanel.SELECT);
              }
            }
          });
        }
        return selectButton;
      }
     
      public JRadioButton getLineButton() {
        if (lineButton == null) {
          lineButton = new JRadioButton();
          lineButton.setIcon(ParameterUI.createImageIcon(ParameterUI.DESIGN_UNSELECTED_LINE));
          lineButton.setSelectedIcon(ParameterUI.createImageIcon(ParameterUI.DESIGN_SELECTED_LINE));
          lineButton.setPreferredSize(DESIGN_BUTTON_SIZE);
          lineButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
              pac7000UI.getLineRadioButtonMenuItem().setSelected(lineButton.isSelected());
              if (lineButton.isSelected()) {
                setType(DesignPanel.LINE);
              }
            }
          });
        }
        return lineButton;
      }
    ...
      public JRadioButton getAnalogButton() {
        if (analogButton == null) {
          analogButton = new JRadioButton();
          analogButton.setIcon(ParameterUI.createImageIcon("design/u_analog.jpg"));
          analogButton.setSelectedIcon(ParameterUI.createImageIcon("design/s_analog.jpg"));
          analogButton.setPreferredSize(DESIGN_BUTTON_SIZE);
          analogButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
              pac7000UI.getAnalogBarRadioButtonMenuItem().setSelected(analogButton.isSelected());
            }
          });
        }
        return analogButton;
      }
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
      public static ImageIcon createImageIcon(String name) {
        String path = RESOURCE_PATH + PICTURES_PATH + name;
        URL imgURL = ParameterUI.class.getResource(path);
        if (imgURL != null) {
          return new ImageIcon(imgURL);
        } else {
          System.err.println("Couldn't find file: " + path);
          return null;
        }
      }
    merci d'avance

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    up

  3. #3
    Membre actif Avatar de aDamas
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    260
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Décembre 2004
    Messages : 260
    Points : 288
    Points
    288
    Par défaut
    Pourquoi ne pas utiliser trois Box, une horizontale dans la quelle tu met deux box verticales et une Glue.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Box boxHorizontale = Box.createHorizontalBox();
    Box boxVerticale1 = Box.createVerticalBox();
    Box boxVerticale2 = Box.createVerticalBox();
     
    boxHorizontale.add(boxVerticale1);
    boxHorizontale.add(boxVerticale2);
    boxHorizontale.add(Box.createHorizontalGlue());
     
    ----ajout de tes boutons
     
    boxVerticale1.add(Box.createVerticalGlue());
    boxVerticale2.add(Box.createVerticalGlue());
    Par contre, tu devra définir la taille minimum, maximum et preferée de tes boutons. Personnelement c'est comme ça qu j'ai fait et ça fonctionne parfaitement. En espérant aroir pu t'aider. Bonne journée.

  4. #4
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    ok, merci, mais je ne voulais pas changer tout ce que la personne avait réaliser... mais si je suis obligé s'est ce que je ferais.
    Pour l'instant je vais essayer de trouver d'ou bien ces espaces au niveau de la largeur... je ne comprends vraiment pas.
    si qq'1 voit l'erreur...

  5. #5
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    up

  6. #6
    BiM
    BiM est déconnecté
    Expert éminent sénior
    Avatar de BiM
    Femme Profil pro
    Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
    Inscrit en
    Janvier 2005
    Messages
    7 796
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 38
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

    Informations forums :
    Inscription : Janvier 2005
    Messages : 7 796
    Points : 10 765
    Points
    10 765
    Par défaut
    Remplace ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    this.setSize(new java.awt.Dimension(70,245));
    Par :

  7. #7
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    non, ton pack me fait une tout petite fenetre ou rien n'est visible mais on voit comme meme le haut des boutons qui n'ont pas changer de place eux... la fenetre a rétréci mais ces composant sont comme encré.... leur taille n'a apparemment pas bougé

  8. #8
    BiM
    BiM est déconnecté
    Expert éminent sénior
    Avatar de BiM
    Femme Profil pro
    Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
    Inscrit en
    Janvier 2005
    Messages
    7 796
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 38
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

    Informations forums :
    Inscription : Janvier 2005
    Messages : 7 796
    Points : 10 765
    Points
    10 765
    Par défaut
    Ceci dit, tu devrais refaire la fenetre en entier parce qu'elle est particulièrement mal écrite...

  9. #9
    Membre actif
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    504
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 504
    Points : 288
    Points
    288
    Par défaut
    c'est c que je disais c un gars qui es parti qui l'a fait mais j'ai pas vraiment envie d'y retoucher sauf si je ne trouve pas de solution pour la rétrécir je passerais pas des ToolBar...

Discussions similaires

  1. Table liée non modifiable !?
    Par Maludi dans le forum Access
    Réponses: 15
    Dernier message: 30/01/2006, 15h33
  2. [2.0][C#]UserControl, Groupe de proprieté non modifiable !!
    Par chnew dans le forum Windows Forms
    Réponses: 4
    Dernier message: 07/01/2006, 00h30
  3. Rendre un champ non modifiable sur un onclick
    Par damjal dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 12/10/2005, 01h16
  4. Réponses: 5
    Dernier message: 30/09/2005, 16h42
  5. Attributs d'un record en property non modifiables
    Par WebPac dans le forum Langage
    Réponses: 15
    Dernier message: 11/04/2005, 12h59

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