示例#1
0
  public NetworkPanel() {
    super(new GridBagLayout());

    DefaultTableModel model = new DefaultTableModel();
    model.addColumn("Received");
    model.addColumn("Sent");

    networkTable =
        new JZebraTable(model) {

          @Override
          public boolean isCellEditable(int rowIndex, int colIndex) {
            return false;
          }
        };
    networkTable.setShowHorizontalLines(true);
    networkTable.setShowVerticalLines(true);

    this.add(
        new JScrollPane(
            networkTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            5,
            5));
  }
示例#2
0
 private void observe(PlayerSentMessageEvent event) {
   DefaultTableModel model = (DefaultTableModel) networkTable.getModel();
   model.setValueAt(event.getMessage(), model.getRowCount() - 1, 1);
 }
示例#3
0
 private void observe(PlayerReceivedMessageEvent event) {
   DefaultTableModel model = (DefaultTableModel) networkTable.getModel();
   model.addRow(new String[] {"", ""});
   model.setValueAt(event.getMessage(), model.getRowCount() - 1, 0);
 }