public void initComponents() { /** ******************** The main container *************************** */ Container container = this.getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.black); this.setSize(650, 600); this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) {} }); /** ************************* MAIN PANEL ******************************* */ mainPanel = new JPanel(); // If put to False: we see the container's background mainPanel.setOpaque(false); mainPanel.setLayout(new BorderLayout()); container.add(mainPanel, BorderLayout.CENTER); allmessagesTextArea = new TextArea(); allmessagesTextArea.setEditable(false); allmessagesTextArea.setFont(new Font("Dialog", 1, 12)); allmessagesTextArea.setForeground(Color.black); allmessagesTextArea.append("Select a session in the list to view its messages"); mainPanel.add(allmessagesTextArea, BorderLayout.CENTER); sessionsList = new List(); sessionsList.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { showMessages(e); } }); sessionsList.setForeground(Color.black); sessionsList.setFont(new Font("Dialog", 1, 14)); mainPanel.add(sessionsList, BorderLayout.WEST); okButton = new JButton(" OK "); okButton.setToolTipText("Returns to the main frame"); okButton.setFont(new Font("Dialog", 1, 16)); okButton.setFocusPainted(false); okButton.setBackground(Color.lightGray); okButton.setBorder(new BevelBorder(BevelBorder.RAISED)); okButton.setVerticalAlignment(SwingConstants.CENTER); okButton.setHorizontalAlignment(SwingConstants.CENTER); container.add(okButton, BorderLayout.SOUTH); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setVisible(false); } }); }
// Item Listener stuff public void showMessages(ItemEvent e) { int index = 0; if (e != null) index = ((Integer) e.getItem()).intValue(); allmessagesTextArea.setText(""); TracesSession tS = tracesSessions.elementAt(index); for (int i = 0; i < tS.size(); i++) { TracesMessage tM = tS.elementAt(i); // allmessagesTextArea.setForeground(Color.red); // allmessagesTextArea.setFont(new Font ("Dialog", 1, 18)); allmessagesTextArea.append( "Message " + (i + 1) + " from " + tM.getFrom() + " to " + tM.getTo()); allmessagesTextArea.append("\n\n"); // allmessagesTextArea.setForeground(Color.black); // allmessagesTextArea.setFont(new Font ("Dialog", 1, 14)); allmessagesTextArea.append(tM.getMessageString()); allmessagesTextArea.append("\n"); } allmessagesTextArea.select(0, 0); }