示例#1
0
  public ViewPane(GameSessionViewer gsv) {
    _gameSessionViewer = gsv;

    this.setLayout(_layout);

    GridBagConstraints cons = new GridBagConstraints();
    cons.insets = new Insets(5, 5, 5, 5);
    cons.weightx = 0.5;
    cons.gridy = 0;
    cons.gridheight = 5;
    cons.weighty = 0.95;
    cons.fill = GridBagConstraints.BOTH;
    _packetTableModel = new PacketTableModel();
    _packetTable = new JTable(_packetTableModel);
    _packetTable.addMouseListener(new PacketTableMouseListener());
    _packetTable.setDefaultRenderer(Object.class, new PacketTableRenderer(_packetTableModel));
    _packetTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _packetTable.getSelectionModel().addListSelectionListener(new PacketSelectionListener());
    _packetTable.getColumnModel().getColumn(0).setMaxWidth(35);
    _packetTable.getColumnModel().getColumn(1).setMaxWidth(50);
    _packetTable.getColumnModel().getColumn(2).setMaxWidth(90);
    _packetTable.getColumnModel().getColumn(3).setMaxWidth(45);
    JScrollPane scrollPane = new JScrollPane(_packetTable);
    this.add(scrollPane, cons);

    cons.fill = GridBagConstraints.BOTH;
    // cons.anchor = GridBagConstraints.NORTH;
    cons.weightx = 0.5;
    cons.weighty = 0.5;
    cons.gridx = 1;
    cons.gridy = 1;
    cons.gridheight = 1;
    _hexDumpArea = new JTextPane();
    _hexDumpArea.setPreferredSize(new Dimension(100, 317));
    // _hexDumpArea.setDoubleBuffered(true);
    _hexStyledDoc = (DefaultStyledDocument) _hexDumpArea.getStyledDocument();
    addStylesToHexDump(_hexStyledDoc);
    // Font font = new Font("Monospaced", Font.PLAIN, 12);
    // _hexDumpArea.setFont(font);
    // _hexDumpArea.setRows(18);
    // _hexDumpArea.setColumns(20);
    JScrollPane hexDumpScrollPane =
        new JScrollPane(
            _hexDumpArea,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    this.add(hexDumpScrollPane, cons);

    JPanel smallPane = new JPanel();
    smallPane.setLayout(_layout);
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.05;
    cons.weighty = 0.1;
    cons.gridx = 0;
    cons.gridy = 2;
    cons.gridheight = 1;
    JLabel label = new JLabel("Format:");
    _packetFormat = new JTextField();
    _packetFormat.setEditable(false);
    cons.anchor = GridBagConstraints.WEST;
    smallPane.add(label, cons);
    cons.gridx = 1;
    cons.weightx = 0.95;
    cons.fill = GridBagConstraints.HORIZONTAL;
    smallPane.add(_packetFormat, cons);
    cons.weightx = 0.5;
    this.add(smallPane, cons);

    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 0.5;
    cons.weighty = 0.4;
    cons.gridx = 1;
    cons.gridy = 4;
    cons.gridheight = 1;
    _packetViewTableModel = new PacketViewTableModel(null);
    _packetViewTable = new JXTreeTable(_packetViewTableModel);
    _packetViewTable.setSelectionModel(new DefaultListSelectionModel());
    _packetViewTable
        .getSelectionModel()
        .addListSelectionListener(new PartSelectionListener(_packetViewTable));
    _packetViewTable.setDefaultRenderer(Object.class, new IconTableRenderer());
    _packetViewTable.addMouseListener(new JTableButtonMouseListener(_packetViewTable));
    _packetViewTable.setTreeCellRenderer(new PacketViewTreeRenderer());
    JScrollPane packetViewScrollPane = new JScrollPane(_packetViewTable);
    this.add(packetViewScrollPane, cons);

    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTH;
    cons.gridx = 1;
    cons.gridy = 0;
    cons.weighty = 0.1;
    cons.gridwidth = 1;
    _detailsPanel = new SessionDetailPanel(_gameSessionViewer.getSession());
    this.add(_detailsPanel, cons);

    this.displaySession();
  }