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
| import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class ViewClient extends JFrame
{
private JFrame mainFrame = null;
public ViewClient()
{
initWindow();
}
private void initWindow()
{
JPanel jpLogin = new JPanel();
JPanel jpConversation = new JPanel();
JList jlLogin = new JList();
JTextArea jtaConversation = new JTextArea();
//Initialisation de la fenetre principale
mainFrame = new JFrame();
mainFrame.setTitle("Client");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setLayout(new GridBagLayout());
mainFrame.setVisible(true);
mainFrame.setSize(800, 500);
mainFrame.setLocationRelativeTo(null);
mainFrame.setResizable(false);
GridBagConstraints gbc = new GridBagConstraints();
//JPanel participants
jpLogin.setLayout(new BorderLayout());
jpLogin.add(jlLogin);
jpLogin.setBorder(BorderFactory.createTitledBorder("Participant(s)"));
gbc.gridx = gbc.gridy = 0;
gbc.gridheight = gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.PAGE_START;
gbc.weightx = 1.;
gbc.weighty = 1.;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainFrame.add(jpLogin, gbc);
//JPanel conversation
jpConversation.setLayout(new BorderLayout());
jpConversation.add(jtaConversation);
jtaConversation.setEditable(false);
jpConversation.setBorder(BorderFactory.createTitledBorder("Conversation"));
gbc.gridx = 1;
gbc.gridwidth = 3;
gbc.gridheight = 1;
gbc.anchor = GridBagConstraints.PAGE_START;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainFrame.add(jpConversation, gbc);
}
} |
Partager