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
| discussionTextArea = new JTextArea();
discussionTextArea.setLineWrap(true);
discussionScrollPane = new JScrollPane(discussionTextArea);
inputTextField = new JTextField();
sendButton = new JButton("Envoyer");
chatPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0; //Position (0,0)
gbc.gridwidth = GridBagConstraints.REMAINDER; //Dernier composant de la ligne
gbc.gridheight = 1; //Une case de haut
gbc.weightx = 1.;
gbc.weighty = 1.; //Extension sur tout l'espace
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.LINE_START; // Anchor à la base
gbc.insets = new Insets(Constants.MARGE, Constants.MARGE, Constants.MARGE, Constants.MARGE); //Définition des marges
chatPanel.add(discussionScrollPane, gbc);
gbc.gridy = 1;
gbc.gridx = 0;
gbc.weightx = 1.;
gbc.weighty = 0.;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, Constants.MARGE, Constants.MARGE, Constants.MARGE);
chatPanel.add(inputTextField, gbc);
gbc.gridy = 1;
gbc.gridx = 1;
gbc.weightx = 0.;
gbc.weighty = 0.;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0, 0, Constants.MARGE, Constants.MARGE);
chatPanel.add(sendButton, gbc); |
Partager