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

avec Java Discussion :

Positionnement à gauche avec un BoxLayout


Sujet :

avec Java

  1. #1
    Membre régulier
    Homme Profil pro
    Inscrit en
    Avril 2010
    Messages
    116
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2010
    Messages : 116
    Points : 98
    Points
    98
    Par défaut Positionnement à gauche avec un BoxLayout
    Bonjour,
    impossible de placer mon box layout à gauche...
    je dois mal m'y prendre ...
    Merci pour votre aide !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    // Dans le panneau 7
            JButton button1 = new JButton("Envoyer !");
            //pan7.setLayout(new BorderLayout());
            Box hbox5 = Box.createHorizontalBox();
            pan7.add(hbox5);
            hbox5.setAlignmentX(Component.LEFT_ALIGNMENT);
            hbox5.add(button1);
            //pan7.add(button1, BorderLayout.CENTER);


    Uploaded with ImageShack.us

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    43
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 43
    Points : 48
    Points
    48
    Par défaut
    Quel gestionnaire de placement a Pan7 ?

    Mes boutons sont à gauche.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    JButton button1 = new JButton("Envoyer !");
    JButton button2 = new JButton("Envoyer 2 !");
    Box hbox5 = Box.createHorizontalBox();
     
    hbox5.setAlignmentX(Component.LEFT_ALIGNMENT);
    hbox5.add(button1);
    hbox5.add(button2);
     
    add(hbox5);

  3. #3
    Membre régulier
    Homme Profil pro
    Inscrit en
    Avril 2010
    Messages
    116
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2010
    Messages : 116
    Points : 98
    Points
    98
    Par défaut
    SAlut,
    j'ai mis un BoxLayout également :

    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
     
     
    Box hbox1 = Box.createVerticalBox();
     
    		mafenetre.add(hbox1);
     
     
    		hbox1.add(pan1);
    		hbox1.add(pan2);
    		hbox1.add(pan3);
    		hbox1.add(pan8);
    		hbox1.add(pan4);
    		hbox1.add(pan5);
    		hbox1.add(pan6);
    		hbox1.add(pan7);

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    43
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 43
    Points : 48
    Points
    48
    Par défaut
    Mes boutons sont à gauche

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    JButton button1 = new JButton("Envoyer !");
    JButton button2 = new JButton("Envoyer 2");
    Box hbox1 = Box.createVerticalBox();
    Box hbox5 = Box.createHorizontalBox();
     
    hbox5.setAlignmentX(Component.LEFT_ALIGNMENT);
    hbox5.add(button1);
    hbox5.add(button2);
     
    hbox1.add(hbox5);
    add(hbox1);

  5. #5
    Membre régulier
    Homme Profil pro
    Inscrit en
    Avril 2010
    Messages
    116
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2010
    Messages : 116
    Points : 98
    Points
    98
    Par défaut
    En fait j'ai 8 panel dans un Box vertical,
    puis dans chaque panel j'ai un Box soit vertical soit horizontal.
    Et impossible de les mettre à 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
    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
    public static void main(String[] args) {
     
    		Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    		int hauteur = (int)tailleEcran.getHeight();
     
    		// TODO Auto-generated method stub
    		JFrame mafenetre = new JFrame();
    		mafenetre.setTitle("Fenetre de TEST"); 
    		mafenetre.setSize(500,hauteur-50); 
    		mafenetre.setLocationRelativeTo(null); 
    		mafenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
    		JPanel pan1 = new JPanel();
    		JPanel pan2 = new JPanel();
    		JPanel pan3 = new JPanel();
    		JPanel pan4 = new JPanel();
    		JPanel pan5 = new JPanel();
    		JPanel pan6 = new JPanel();
    		JPanel pan7 = new JPanel();
    		JPanel pan8 = new JPanel();
     
     
    		pan1.setBorder(BorderFactory.createTitledBorder("Test pan1"));
    		pan2.setBorder(BorderFactory.createTitledBorder("Test pan2"));
    		pan3.setBorder(BorderFactory.createTitledBorder("Test pan3"));
    		pan4.setBorder(BorderFactory.createTitledBorder("Test pan4"));
    		pan5.setBorder(BorderFactory.createTitledBorder("Test pan5"));
    		pan6.setBorder(BorderFactory.createTitledBorder("Test pan6"));
    		pan7.setBorder(BorderFactory.createTitledBorder("Test pan7"));
    		pan8.setBorder(BorderFactory.createTitledBorder("Test pan8"));
     
    		//pan1.setAlignmentX(Component.LEFT_ALIGNMENT);
     
    		/*mafenetre.add(pan1);
    		mafenetre.add(pan2);
    		mafenetre.add(pan3);
    		mafenetre.add(pan4);
    		mafenetre.add(pan5);
    		mafenetre.add(pan6);
    		mafenetre.add(pan7);*/
     
    		/*mafenetre.setLayout(new GridLayout(7,1));
            
            mafenetre.getContentPane().add(pan1);
            mafenetre.getContentPane().add(pan2);
            mafenetre.getContentPane().add(pan3);
            mafenetre.getContentPane().add(pan4);
            mafenetre.getContentPane().add(pan5);
            mafenetre.getContentPane().add(pan6);
            mafenetre.getContentPane().add(pan7);*/
     
    		Box hbox1 = Box.createVerticalBox();
    		hbox1.setAlignmentX(Component.LEFT_ALIGNMENT);
    		mafenetre.add(hbox1);
     
    		hbox1.add(pan1);
    		hbox1.add(pan2);
    		hbox1.add(pan3);
    		hbox1.add(pan8);
    		hbox1.add(pan4);
    		hbox1.add(pan5);
    		hbox1.add(pan6);
    		hbox1.add(pan7);
     
      // Dans le panneau 1
    		Box hbox2 = Box.createHorizontalBox();
    		hbox2.setAlignmentX(Component.LEFT_ALIGNMENT);
            JTextField txt1 = new JTextField("entrez le nom ici");
            pan1.add(hbox2);
            hbox2.add(txt1);
     
            // Dans le panneau 2
            Box hbox6 = Box.createVerticalBox();
            hbox6.setAlignmentX(Component.LEFT_ALIGNMENT);
     
            JRadioButton radio4 = new JRadioButton("Voiture");
            JRadioButton radio5 = new JRadioButton("Bus");
            JRadioButton radio6 = new JRadioButton("Velo");
            JRadioButton radio7 = new JRadioButton("Autre");

Discussions similaires

  1. Réponses: 0
    Dernier message: 22/12/2008, 16h25
  2. Problème avec un BoxLayout de bouton
    Par abossica dans le forum Débuter
    Réponses: 4
    Dernier message: 04/11/2008, 11h25
  3. problème de positionnement css avec IE7
    Par rasleboldesid dans le forum Mise en page CSS
    Réponses: 11
    Dernier message: 01/09/2006, 20h11
  4. Remplissage d'une forme gauche avec des rectangles
    Par Aiekick dans le forum Algorithmes et structures de données
    Réponses: 3
    Dernier message: 24/03/2006, 19h00

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