/** *********************************************************************** */ private void initComponents() { /** ******************** The main container *************************** */ Container container = this.getContentPane(); container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); // container.setLayout( new PercentLayout() ); container.setBackground(Color.black); addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("Trace viewer closed!"); // System.exit(0); } }); /** ******************** Menu bar ************************************* */ menuBar = new JMenuBar(); setJMenuBar(menuBar); // Build a second menu in the menu bar. optionsMenu = new JMenu(" Options "); optionsMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); optionsMenu.setToolTipText("Some options related to the GUI"); animationMenuItem = new JMenuItem(" Animation "); animationMenuItem.setToolTipText("Animation of the entire selected session"); animationMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { listenerTracesViewer.animationActionPerformed(evt); } }); optionsMenu.add(animationMenuItem); menuBar.add(optionsMenu); // create a menu and add it to the menubar displayAllSessionsMenu = new JMenu(" Display Sessions "); displayAllSessionsMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); displayAllSessionsMenu.setToolTipText( "Display all the retrieved sessions in a separate windows"); displayAllSessionsMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.displayAllSessionsMouseEvent(evt); } }); // add the Controls menu to the menu bar menuBar.add(displayAllSessionsMenu); // create a menu and add it to the menubar refreshMenu = new JMenu(" Refresh "); refreshMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); refreshMenu.setBackground(new Color(51, 153, 255)); refreshMenu.setToolTipText("Get the new traces"); refreshMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.refreshActionPerformed(evt); } }); // add the Controls menu to the menu bar menuBar.add(refreshMenu); // ...create and add some menus... menuBar.add(Box.createHorizontalGlue()); helpMenu = new JMenu(" Help "); helpMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); helpMenu.setToolTipText("Some useful notes about this tool"); helpMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.helpMenuMouseEvent(evt); } }); menuBar.add(helpMenu); aboutMenu = new JMenu(" About "); aboutMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); aboutMenu.setToolTipText("Some advertises about the creators!"); aboutMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.aboutMenuMouseEvent(evt); } }); menuBar.add(aboutMenu); quitMenu = new JMenu(" Quit "); quitMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); quitMenu.setToolTipText("Quit the traces viewer"); quitMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { close(); } }); menuBar.add(quitMenu); /** ****************** FIRST PANEL ******************************* */ firstPanel = new JPanel(); // If put to False: we see the container's background firstPanel.setOpaque(false); firstPanel.setLayout(new PercentLayout()); // firstPanel.setLayout( new BorderLayout() ); container.add(firstPanel); // Sub right panel: // topx %, topy %, width %, height % 73, 100-> 65, 95 PercentLayoutConstraint firstPanelConstraint = new PercentLayoutConstraint(30, 0, 70, 100); tracesSessionsList = new TracesSessionsList(); tracesSessionsList.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { listenerTracesViewer.tracesSessionsListStateChanged(e); } }); tracesSessionsList.setForeground(Color.black); tracesSessionsList.setFont(new Font("Dialog", 1, 14)); ScrollPane scroll = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); TracesSession tracesSession = tracesSessions.firstElement(); String name = tracesSession.getName(); String logDescription = tracesSession.getLogDescription(); String callId = tracesSessionsList.getCallId(name); String origin = tracesSessionsList.getOrigin(name); // Warning: to put before for the canvas!!!! TextArea messageContentTextArea = new TextArea(); messageContentButton = new JButton("SIP Message:"); if (name.equals("No available session, refresh")) { tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, "unknown", this); } else if (logDescription == null || logDescription.trim().equals("")) { tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, origin, this); } else { // System.out.println("logDesc44:"+logDescription); tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, logDescription, this); } tracesSessionsList.setTracesCanvas(tracesCanvas); // The ScrollPane for the Canvas scroll.add(tracesCanvas); firstPanel.add(scroll, firstPanelConstraint); /** ************************* SECOND PANEL ******************************* */ // left panel: secondPanel = new JPanel(); secondPanel.setBackground(Color.black); // rows, columns // secondPanel.setLayout(new GridLayout(3,1,0,0) ); secondPanel.setLayout(new BorderLayout()); // topx %, topy %, width %, height % PercentLayoutConstraint secondPanelConstraint = new PercentLayoutConstraint(0, 0, 30, 100); firstPanel.add(secondPanel, secondPanelConstraint); /** **************************** FIRST SUB PANEL ********************************* */ // Sub left panel: firstSubPanel = new JPanel(); firstSubPanel.setBackground(Color.black); // Top, left, bottom, right firstSubPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 7, 5)); if (!standaloneViewer) { // rows, columns, gap, gap firstSubPanel.setLayout(new GridLayout(2, 1, 3, 6)); secondPanel.add(firstSubPanel, BorderLayout.NORTH); JPanel panelGrid = new JPanel(); panelGrid.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panelGrid.setLayout(new GridLayout(2, 1, 0, 0)); JPanel panelBox = new JPanel(); panelBox.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); panelBox.setLayout(new BorderLayout()); JLabel scriptLabel = new JLabel("Display the event script:"); scriptLabel.setToolTipText("Display the content of the selected script"); scriptLabel.setHorizontalAlignment(SwingConstants.CENTER); scriptLabel.setForeground(Color.black); scriptLabel.setFont(new Font("Dialog", 1, 14)); // If put to true: we see the label's background scriptLabel.setOpaque(true); panelGrid.add(scriptLabel); choice = new Choice(); panelBox.add(choice, BorderLayout.CENTER); scriptButton = new JButton("Open"); scriptButton.setToolTipText("Get the script controlling the current session"); scriptButton.setFont(new Font("Dialog", 1, 14)); scriptButton.setFocusPainted(false); scriptButton.setBackground(new Color(186, 175, 175)); scriptButton.setBorder(new BevelBorder(BevelBorder.RAISED)); scriptButton.setVerticalAlignment(SwingConstants.CENTER); scriptButton.setHorizontalAlignment(SwingConstants.CENTER); panelBox.add(scriptButton, BorderLayout.EAST); scriptButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { listenerTracesViewer.scriptActionPerformed(evt); } }); panelGrid.add(panelBox); firstSubPanel.add(panelGrid); // initComboBox(); /* refreshButton=new JButton("Refresh"); refreshButton.setToolTipText("Refresh all the sessions"); refreshButton.setFont(new Font ("Dialog", 1, 14)); refreshButton.setFocusPainted(false); //refreshButton.setBackground(new Color(186,175,175)); refreshButton.setBackground( new Color(51,153,255)); refreshButton.setBorder(new BevelBorder(BevelBorder.RAISED)); refreshButton.setVerticalAlignment(AbstractButton.CENTER); refreshButton.setHorizontalAlignment(AbstractButton.CENTER); firstSubPanel.add(refreshButton); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { listenerTracesViewer.refreshActionPerformed(evt); } } ); */ ImageIcon icon; if (logoNist != null) { icon = new ImageIcon(logoNist); JLabel label = new JLabel(icon); label.setVisible(true); label.setToolTipText("The NIST logo!!!"); // label.setHorizontalAlignment(AbstractButton.CENTER); label.setForeground(Color.black); // label.setFont(new Font ("Dialog", 1, 14)); label.setOpaque(false); firstSubPanel.add(label); } } else { // rows, columns, gap, gap firstSubPanel.setLayout(new GridLayout(1, 1, 3, 6)); secondPanel.add(firstSubPanel, BorderLayout.NORTH); ImageIcon icon; if (logoNist != null) { icon = new ImageIcon(logoNist); JLabel label = new JLabel(icon); label.setVisible(true); label.setToolTipText("The NIST logo!!!"); label.setHorizontalAlignment(SwingConstants.CENTER); label.setForeground(Color.black); label.setFont(new Font("Dialog", 1, 14)); label.setOpaque(false); firstSubPanel.add(label); } } /** **************** SECOND SUB PANEL *************************************** */ JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1, 0, 0)); secondPanel.add(panel, BorderLayout.CENTER); secondSubPanel = new JPanel(); secondSubPanel.setBackground(Color.black); secondSubPanel.setLayout(new BorderLayout()); // secondPanel.add(secondSubPanel); panel.add(secondSubPanel); sessionsLabel = new JLabel("Sessions available:"); sessionsLabel.setToolTipText("All the sessions currently available"); // Alignment of the text sessionsLabel.setHorizontalAlignment(SwingConstants.CENTER); // Color of the text sessionsLabel.setForeground(Color.black); // Size of the text sessionsLabel.setFont(new Font("Dialog", 1, 14)); // If put to true: we see the label's background sessionsLabel.setOpaque(true); sessionsLabel.setBackground(Color.lightGray); sessionsLabel.setBorder(BorderFactory.createLineBorder(Color.darkGray)); secondSubPanel.add(sessionsLabel, BorderLayout.NORTH); ScrollPane scrollList = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); scrollList.add(tracesSessionsList); // secondSubPanel.add(scrollList,BorderLayout.CENTER); secondSubPanel.add(tracesSessionsList, BorderLayout.CENTER); /** ****************** THIRD SUB PANEL *************************************** */ thirdSubPanel = new JPanel(); thirdSubPanel.setBackground(Color.black); thirdSubPanel.setLayout(new BorderLayout()); // secondPanel.add(thirdSubPanel); panel.add(thirdSubPanel); messageContentButton.setToolTipText("Display all the content of the current SIP message"); // Alignment of the text messageContentButton.setHorizontalAlignment(SwingConstants.CENTER); // Color of the text messageContentButton.setForeground(Color.black); // Size of the text messageContentButton.setFont(new Font("Dialog", 1, 14)); // If put to true: we see the label's background messageContentButton.setOpaque(true); messageContentButton.setBackground(Color.lightGray); messageContentButton.setBorder(BorderFactory.createLineBorder(Color.darkGray)); messageContentButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { listenerTracesViewer.debugActionPerformed(evt); } }); messageContentTextArea.setBackground(Color.white); messageContentTextArea.setEditable(false); messageContentTextArea.setFont(new Font("Dialog", 1, 12)); messageContentTextArea.setForeground(Color.black); thirdSubPanel.add(messageContentButton, BorderLayout.NORTH); thirdSubPanel.add(messageContentTextArea, BorderLayout.CENTER); validateTree(); }