/**
  * Implemented to do some tweaks/bookkeeping before/after passing the event to the original
  *
  * <p>- temporarily disallow reordering if hit on first column - calculate the max mouseX that's
  * allowable in dragging to the left
  */
 @Override
 public void mousePressed(MouseEvent e) {
   int index = header.columnAtPoint(e.getPoint());
   boolean reorderingAllowed = header.getReorderingAllowed();
   if (index == 0) {
     // temporarily disable re-ordering
     header.setReorderingAllowed(false);
   }
   mouseDelegate.mousePressed(e);
   header.setReorderingAllowed(reorderingAllowed);
   if (header.getDraggedColumn() != null) {
     Rectangle r = header.getHeaderRect(index);
     maxX = header.getColumnModel().getColumn(0).getWidth() + e.getX() - r.x - 1;
   }
 }
  /** Erzeugt die Tabelle für die Anzeige der Medien. */
  private void erzeugeMedienTable() {
    JScrollPane medienAuflisterScrollPane = new JScrollPane();
    medienAuflisterScrollPane.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Medien",
            TitledBorder.LEADING,
            TitledBorder.DEFAULT_POSITION,
            UIConstants.HEADER_FONT));
    medienAuflisterScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    medienAuflisterScrollPane.getVerticalScrollBar().setBackground(UIConstants.BACKGROUND_COLOR);
    medienAuflisterScrollPane.getHorizontalScrollBar().setBackground(UIConstants.BACKGROUND_COLOR);

    _ausleiheMedienTableModel = new MedienverwaltungMedienTableModel();
    _medienTable = new JTable();
    _medienTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    medienAuflisterScrollPane.setViewportView(_medienTable);
    _medienTable.setModel(_ausleiheMedienTableModel);
    JTableHeader tableHeader = _medienTable.getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _medienTable.setFont(UIConstants.TEXT_FONT);

    _hauptPanel.add(medienAuflisterScrollPane, BorderLayout.CENTER);
  }
  private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    // JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "4dlu, d:grow, 4dlu", // columns
            "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, "
                + // rows
                "p, 2dlu, p, 4dlu"); // btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd"));
    contentPB.add(label, cc.xywh(2, 2, 1, 1));

    mediaTypeModel = new MediaTypeModel();
    mediaTypeTable = new JTable(mediaTypeModel);
    JTableHeader tableHeader = mediaTypeTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    // adjust column witdh of checkbox
    JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class);
    TableColumn column = mediaTypeTable.getColumnModel().getColumn(0);
    column.setMaxWidth(box.getPreferredSize().width + 2);
    column.setMinWidth(box.getPreferredSize().width + 2);
    mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer());
    // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable );
    contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1));

    // button bar
    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    okBtn.setDefaultCapable(true);
    okBtn.setRequestFocusEnabled(true);

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);

    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(okBtn);

    pack();
    setLocationRelativeTo(getParent());
  }
 public static void initializeTable(JTable classLevelTable) {
   JTableHeader tableHeader = classLevelTable.getTableHeader();
   tableHeader.setResizingAllowed(false);
   tableHeader.setReorderingAllowed(false);
   TableColumnModel columnModel = new DefaultTableColumnModel();
   TableCellRenderer headerRenderer = tableHeader.getDefaultRenderer();
   columnModel.addColumn(Utilities.createTableColumn(0, "Level", headerRenderer, false));
   columnModel.addColumn(Utilities.createTableColumn(1, "HP", headerRenderer, false));
   columnModel.addColumn(
       Utilities.createTableColumn(2, "Class (All Levels In Class)", headerRenderer, true));
   classLevelTable.setColumnModel(columnModel);
   classLevelTable.setAutoCreateColumnsFromModel(false);
   classLevelTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
   classLevelTable.setFocusable(false);
   classLevelTable.setCellSelectionEnabled(false);
   classLevelTable.setRowHeight(20);
 }
  /**
   * Updates the column header component in the scroll pane. This depends on the current results
   * view and whether the sponsored results are visible.
   */
  private void syncColumnHeader() {
    Component resultHeader = resultsContainer.getScrollPaneHeader();
    if (resultHeader == null) {
      // If no headers, use nothing special.
      scrollPane.setColumnHeaderView(null);
    } else if (!sponsoredResultsPanel.isVisible()) {
      // If sponsored results aren't visible, just use the actual header.
      scrollPane.setColumnHeaderView(resultHeader);
    } else {
      // Otherwise, create a combined panel that has both sponsored results & header.
      JXPanel headerPanel = new JXPanel();
      // Make sure this syncs with the layout for the results & sponsored results!
      headerPanel.setLayout(new MigLayout("hidemode 3, gap 0, insets 0", "[]", "[grow][]"));
      headerPanel.add(resultHeader, "grow, push, alignx left, aligny top");

      DefaultTableColumnModel model = new DefaultTableColumnModel();
      TableColumn column = new TableColumn();
      model.addColumn(column);
      JTableHeader header = new JTableHeader(model);
      header.setDefaultRenderer(new TableCellHeaderRenderer());
      header.setReorderingAllowed(false);
      header.setResizingAllowed(false);
      header.setTable(new JXTable(0, 1));

      int width = sponsoredResultsPanel.getPreferredSize().width;
      int height = resultHeader.getPreferredSize().height;
      column.setWidth(width);
      Dimension dimension = new Dimension(width, height);
      header.setPreferredSize(dimension);
      header.setMaximumSize(dimension);
      header.setMinimumSize(dimension);

      headerPanel.add(header, "aligny top, alignx right");
      scrollPane.setColumnHeaderView(headerPanel);
    }

    scrollPane.validate();

    // Resize and repaint table header.  This eliminates visual issues due
    // to a change in the table format, which can result in an incorrect
    // header height or header flickering when a category is selected.
    if (resultHeader instanceof JTableHeader) {
      ((JTableHeader) resultHeader).resizeAndRepaint();
    }
  }
Beispiel #6
0
  /** Erzeuge das Tabellen-Panel, in dem die Verleihkarten angezeigt werden. */
  private void erzeugeVerleihkartenauflister() {
    JPanel verleihkartenAuflisterPanel = new JPanel();
    _hauptPanel.add(verleihkartenAuflisterPanel, BorderLayout.CENTER);
    verleihkartenAuflisterPanel.setLayout(new BorderLayout());
    verleihkartenAuflisterPanel.setPreferredSize(new java.awt.Dimension(-1, -1));
    verleihkartenAuflisterPanel.setSize(-1, -1);
    verleihkartenAuflisterPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    JScrollPane verleihkartenAuflisterScrollPane = new JScrollPane();
    verleihkartenAuflisterPanel.add(verleihkartenAuflisterScrollPane, BorderLayout.CENTER);
    verleihkartenAuflisterScrollPane.setPreferredSize(new java.awt.Dimension(-1, -1));
    verleihkartenAuflisterScrollPane.setSize(-1, -1);
    verleihkartenAuflisterScrollPane.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Verleihkarten",
            TitledBorder.LEADING,
            TitledBorder.DEFAULT_POSITION,
            UIConstants.HEADER_FONT));
    verleihkartenAuflisterScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    verleihkartenAuflisterScrollPane
        .getVerticalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);
    verleihkartenAuflisterScrollPane
        .getHorizontalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);

    _verleihkartenAuflisterTableModel = new VerleihkartenTableModel();
    _verleihkartenAuflisterTable = new JTable();
    verleihkartenAuflisterScrollPane.setViewportView(_verleihkartenAuflisterTable);
    _verleihkartenAuflisterTable.setModel(_verleihkartenAuflisterTableModel);
    JTableHeader tableHeader = _verleihkartenAuflisterTable.getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _verleihkartenAuflisterTable.setFont(UIConstants.TEXT_FONT);
  }
  // {{{ InstallPanel constructor
  InstallPanel(PluginManager window, boolean updates) {
    super(new BorderLayout(12, 12));

    this.window = window;
    this.updates = updates;

    setBorder(new EmptyBorder(12, 12, 12, 12));

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.75);
    /* Setup the table */
    table = new JTable(pluginModel = new PluginTableModel());
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setRowHeight(table.getRowHeight() + 2);
    table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setDefaultRenderer(
        Object.class,
        new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)));
    table.addFocusListener(new TableFocusHandler());
    InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap tableActionMap = table.getActionMap();
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward");
    tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack");
    tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin");
    tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager");
    tableActionMap.put(
        "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER));

    TableColumn col1 = table.getColumnModel().getColumn(0);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    TableColumn col3 = table.getColumnModel().getColumn(2);
    TableColumn col4 = table.getColumnModel().getColumn(3);
    TableColumn col5 = table.getColumnModel().getColumn(4);

    col1.setPreferredWidth(30);
    col1.setMinWidth(30);
    col1.setMaxWidth(30);
    col1.setResizable(false);

    col2.setPreferredWidth(180);
    col3.setPreferredWidth(130);
    col4.setPreferredWidth(70);
    col5.setPreferredWidth(70);

    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.addMouseListener(new HeaderMouseHandler());
    header.setDefaultRenderer(
        new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer()));

    scrollpane = new JScrollPane(table);
    scrollpane.getViewport().setBackground(table.getBackground());
    split.setTopComponent(scrollpane);

    /* Create description */
    JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox());
    infoPane.setPreferredSize(new Dimension(500, 100));
    split.setBottomComponent(infoPane);

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            split.setDividerLocation(0.75);
          }
        });

    final JTextField searchField = new JTextField();
    searchField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
              table.dispatchEvent(e);
              table.requestFocus();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              void update() {
                pluginModel.setFilterString(searchField.getText());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int i = table.getSelectedRow(), n = table.getModel().getRowCount();
            if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1)
                || e.getKeyCode() == KeyEvent.VK_UP && i == 0) {
              searchField.requestFocus();
              searchField.selectAll();
            }
          }
        });
    Box filterBox = Box.createHorizontalBox();
    filterBox.add(new JLabel("Filter : "));
    filterBox.add(searchField);
    add(BorderLayout.NORTH, filterBox);
    add(BorderLayout.CENTER, split);

    /* Create buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    buttons.add(new InstallButton());
    buttons.add(Box.createHorizontalStrut(12));
    buttons.add(new SelectallButton());
    buttons.add(chooseButton = new ChoosePluginSet());
    buttons.add(new ClearPluginSet());
    buttons.add(Box.createGlue());
    buttons.add(new SizeLabel());

    add(BorderLayout.SOUTH, buttons);
    String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, "");
    if (!path.isEmpty()) {
      loadPluginSet(path);
    }
  } // }}}
Beispiel #8
0
    @Override
    public void actionPerformed(ActionEvent e) {
      int[] selectedRows = equipmentTable.getSelectedRows();
      MapToList<EquipmentFacade, EquipNode> equipMap =
          new HashMapToList<EquipmentFacade, EquipNode>();
      EquipmentSetFacade equipSet = character.getEquipmentSetRef().getReference();
      List<EquipmentFacade> equipment = new ArrayList<EquipmentFacade>();

      for (int i = 0; i < selectedRows.length; i++) {
        EquipmentFacade equipmentFacade = selectedModel.getValue(selectedRows[i]);
        for (EquipNode path : equipSet.getNodes()) {
          if (equipSet.canEquip(path, equipmentFacade)) {
            equipMap.addToListFor(equipmentFacade, path);
          }
        }
        if (equipMap.containsListFor(equipmentFacade)) {
          equipment.add(equipmentFacade);
        }
      }
      if (!equipment.isEmpty()) {
        Object[][] data = new Object[equipment.size()][3];
        for (int i = 0; i < equipment.size(); i++) {
          EquipmentFacade equipmentFacade = equipment.get(i);
          data[i][0] = equipmentFacade;
          data[i][1] = 1;
          data[i][2] = getInitialNode(equipMap, equipSet, equipmentFacade);
        }
        Object[] columns =
            new Object[] {
              LanguageBundle.getString("in_equipItem"), // $NON-NLS-1$
              LanguageBundle.getString("in_equipQuantityAbbrev"), // $NON-NLS-1$
              LanguageBundle.getString("in_equipContainer") // $NON-NLS-1$
            };
        DefaultTableModel tableModel =
            new DefaultTableModel(data, columns) {

              @Override
              public Class<?> getColumnClass(int columnIndex) {
                if (columnIndex == 1) {
                  return Integer.class;
                }
                return Object.class;
              }

              @Override
              public boolean isCellEditable(int row, int column) {
                return column != 0;
              }
            };
        JTable table = new JTable(tableModel);
        table.setFocusable(false);
        table.setCellSelectionEnabled(false);
        table.setDefaultEditor(Object.class, new ComboEditor(equipMap));
        table.setDefaultRenderer(Integer.class, new TableCellUtilities.SpinnerRenderer());
        table.setDefaultEditor(Integer.class, new SpinnerEditor(unequippedList));
        table.setRowHeight(22);
        table.getColumnModel().getColumn(0).setPreferredWidth(140);
        table.getColumnModel().getColumn(1).setPreferredWidth(50);
        table.getColumnModel().getColumn(2).setPreferredWidth(120);
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
        JTableHeader header = table.getTableHeader();
        header.setReorderingAllowed(false);
        JScrollPane pane = new JScrollPane(table);
        JPanel panel = new JPanel(new BorderLayout());
        JLabel help = new JLabel(LanguageBundle.getString("in_equipSelectQtyLoc")); // $NON-NLS-1$
        panel.add(help, BorderLayout.NORTH);
        panel.add(pane, BorderLayout.CENTER);
        int res =
            JOptionPane.showConfirmDialog(
                JOptionPane.getFrameForComponent(equipmentTable),
                panel,
                LanguageBundle.getString("in_equipEquipSel"), // $NON-NLS-1$
                JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE);

        if (res == JOptionPane.OK_OPTION) {
          for (int i = 0; i < equipment.size(); i++) {
            EquipNode path = (EquipNode) tableModel.getValueAt(i, 2);
            equipSet.addEquipment(path, equipment.get(i), (Integer) tableModel.getValueAt(i, 1));
          }
        }
      }
    }
Beispiel #9
0
    @Override
    public void actionPerformed(ActionEvent e) {
      EquipmentSetFacade equipSet = character.getEquipmentSetRef().getReference();
      int[] rows = equipmentSetTable.getSelectedRows();
      List<EquipNode> paths = new ArrayList<EquipNode>();
      for (int i = 0; i < rows.length; i++) {
        EquipNode path = (EquipNode) equipmentSetTable.getValueAt(rows[i], 0);
        if (path.getNodeType() == NodeType.EQUIPMENT) {
          paths.add(path);
        }
      }
      if (!paths.isEmpty()) {
        Object[][] data = new Object[paths.size()][3];
        for (int i = 0; i < paths.size(); i++) {
          EquipNode path = paths.get(i);
          data[i][0] = path.getEquipment();
          data[i][1] = 1;
        }
        Object[] columns =
            new Object[] {
              LanguageBundle.getString("in_equipItem"), // $NON-NLS-1$
              LanguageBundle.getString("in_equipQuantityAbbrev"), // $NON-NLS-1$
            };
        DefaultTableModel tableModel =
            new DefaultTableModel(data, columns) {

              @Override
              public Class<?> getColumnClass(int columnIndex) {
                if (columnIndex == 1) {
                  return Integer.class;
                }
                return Object.class;
              }

              @Override
              public boolean isCellEditable(int row, int column) {
                return column != 0;
              }
            };
        JTable table = new JTable(tableModel);
        table.setFocusable(false);
        table.setCellSelectionEnabled(false);
        table.setDefaultRenderer(Integer.class, new TableCellUtilities.SpinnerRenderer());
        table.setDefaultEditor(Integer.class, new SpinnerEditor(equipSet.getEquippedItems()));
        table.setRowHeight(22);
        table.getColumnModel().getColumn(0).setPreferredWidth(140);
        table.getColumnModel().getColumn(1).setPreferredWidth(50);
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
        JTableHeader header = table.getTableHeader();
        header.setReorderingAllowed(false);
        JScrollPane pane = new JScrollPane(table);
        JPanel panel = new JPanel(new BorderLayout());
        JLabel help =
            new JLabel(LanguageBundle.getString("in_equipSelectUnequipQty")); // $NON-NLS-1$
        panel.add(help, BorderLayout.NORTH);
        panel.add(pane, BorderLayout.CENTER);
        int res =
            JOptionPane.showConfirmDialog(
                JOptionPane.getFrameForComponent(equipmentTable),
                panel,
                LanguageBundle.getString("in_equipUnequipSel"), // $NON-NLS-1$
                JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE);

        if (res == JOptionPane.OK_OPTION) {
          for (int i = 0; i < paths.size(); i++) {
            equipSet.removeEquipment(paths.get(i), (Integer) tableModel.getValueAt(i, 1));
          }
        }
      }
    }
  private void initializeGUI() {

    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    ColumnModel m = new ColumnModel(this.controller);

    TableModel headerData = new RowModel(this.controller);
    AbstractTableModel data = new StageTableModel(this.controller, m);
    JTable table = new JTable(data);
    table.setColumnModel(m);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    JTable rowHeader = new JTable(headerData);
    rowHeader.setColumnModel(new EmptyColumns());

    LookAndFeel.installColorsAndFont(
        rowHeader, "TableHeader.background", "TableHeader.foreground", "TableHeader.font");

    rowHeader.setIntercellSpacing(new Dimension(0, 0));
    Dimension d = rowHeader.getPreferredScrollableViewportSize();
    d.width = rowHeader.getPreferredSize().width;
    rowHeader.setPreferredScrollableViewportSize(d);
    rowHeader.setRowHeight(table.getRowHeight());
    rowHeader.setDefaultRenderer(Object.class, new RowHeaderRenderer());

    JScrollPane scrollPane = new JScrollPane(table);

    scrollPane.setRowHeaderView(rowHeader);

    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    JTableHeader corner = rowHeader.getTableHeader();
    corner.setResizingAllowed(false);
    corner.setReorderingAllowed(false);

    scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner);

    new JScrollPaneAdjuster(scrollPane);

    new JTableRowHeaderResizer(scrollPane).setEnabled(true);

    new RowHeaderResizer(scrollPane).setEnabled(true);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridwidth = 9;
    c.gridx = 0;
    c.gridy = 0;
    this.add(scrollPane, c);
    JPanel button_panel = new JPanel(new GridLayout());
    button_panel.setPreferredSize(new Dimension(250, 50));
    AddStageButtonListener list = new AddStageButtonListener(this);
    JButton add_stage = new JButton("Add");
    add_stage.setPreferredSize(new Dimension(75, 30));
    add_stage.addActionListener(list);
    JButton rename_stage = new JButton("Rename");
    rename_stage.setPreferredSize(new Dimension(100, 30));
    rename_stage.addActionListener(new RenameStageButtonListener(this));
    JButton delete_stage = new JButton("Delete");
    delete_stage.setPreferredSize(new Dimension(75, 30));
    delete_stage.addActionListener(new DeleteStageButtonListener(this));
    button_panel.add(add_stage);
    button_panel.add(rename_stage);
    button_panel.add(delete_stage);
    c.weightx = 0;
    c.gridwidth = 3;
    c.gridy = 1;
    c.gridx = 3;
    this.add(button_panel, c);
  }
  public ConstructionProtocolViewD(final AppD app) {
    // cpPanel = new JPanel(new BorderLayout());

    this.app = app;
    kernel = app.getKernel();
    data = new ConstructionTableData(this);
    useColors = true;
    addIcons = false;

    table = new JTable();
    table.setAutoCreateColumnsFromModel(false);
    table.setModel(((GAbstractTableModelD) data.getImpl()).getImpl());
    table.setRowSelectionAllowed(true);
    table.setGridColor(Color.lightGray);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);

    // header
    JTableHeader header = table.getTableHeader();
    // header.setUpdateTableInRealTime(true);
    header.setReorderingAllowed(false);

    // init model
    ConstructionTableCellRenderer renderer;
    HeaderRenderer headerRend = new HeaderRenderer();
    tableColumns = new TableColumn[data.columns.length];

    for (int k = 0; k < data.columns.length; k++) {
      renderer = new ConstructionTableCellRenderer();
      renderer.setHorizontalAlignment(data.columns[k].getAlignment());
      tableColumns[k] = new TableColumn(k, data.columns[k].getPreferredWidth(), renderer, null);
      tableColumns[k].setMinWidth(data.columns[k].getMinWidth());
      tableColumns[k].setHeaderRenderer(headerRend);
      if (data.columns[k].getInitShow()) table.addColumn(tableColumns[k]);
      if (data.columns[k].getTitle() == "Caption") {
        tableColumns[k].setCellEditor(new ConstructionTableCellEditor());
      }
    }
    // first column "No." should have fixed width
    tableColumns[0].setMaxWidth(tableColumns[0].getMinWidth());

    table
        .getColumnModel()
        .addColumnModelListener(((ConstructionTableData) data).new ColumnMovementListener());

    scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setBackground(Color.white);
    // cpPanel.add(scrollPane, BorderLayout.CENTER);

    // clicking
    ConstructionMouseListener ml = new ConstructionMouseListener();
    table.addMouseListener(ml);
    table.addMouseMotionListener(ml);
    header.addMouseListener(ml); // double clicking, right-click menu
    scrollPane.addMouseListener(ml); // right-click menu

    // keys
    ConstructionKeyListener keyListener = new ConstructionKeyListener();
    table.addKeyListener(keyListener);

    app.getGuiManager().registerConstructionProtocolView(this);

    // navigation bar
    // protNavBar = new ConstructionProtocolNavigationD(app);
    // protNavBar.register(this);
    // protNavBar.setPlayButtonVisible(false);
    // protNavBar.setConsProtButtonVisible(false);
    // this.cpPanel.add(protNavBar.getImpl(), BorderLayout.SOUTH);
    // org.geogebra.desktop.util.Util.addKeyListenerToAll(protNavBar.getImpl(),
    // keyListener);

    initGUI();
    initActions();

    ConstructionProtocolSettings cps = app.getSettings().getConstructionProtocol();
    settingsChanged(cps);
    cps.addListener(this);
  }
  public ScoreGameTableScreen(ArrayList<Player> scoreTable, final Integer userType) {
    setTitle(LoginScreen.getTitleGame());
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (userType == 0) {
              AdminMenuScreen adminmenuscreen = new AdminMenuScreen();
              adminmenuscreen.setVisible(true);
            } else {
              UserMenuScreen usermenuscreen = new UserMenuScreen();
              usermenuscreen.setVisible(true);
            }
            setVisible(false);
          }
        });
    setBounds(100, 100, 352, 526);
    setLocationRelativeTo(null);
    setResizable(false);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblTablaDePuntuaciones = new JLabel("Tabla de puntuaciones de la partida");
    lblTablaDePuntuaciones.setFont(new Font("Verdana", Font.BOLD, 15));
    lblTablaDePuntuaciones.setBounds(21, 21, 327, 35);
    contentPane.add(lblTablaDePuntuaciones);

    table = new JTable();
    table.setShowGrid(false);
    table.setRowSelectionAllowed(false);
    table.setToolTipText("");
    table.setBackground(SystemColor.control);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {
              {null}, {null}, {null},
            },
            new String[] {"Puntuaci\u00F3n"}));
    table.setBounds(52, 110, 239, 201);

    tableModel.addColumn("Jugador");
    tableModel.addColumn("Puntuación");

    table.setRowHeight(30);
    for (int i = 0; i < scoreTable.size() && i < 10; i++) {
      if (!scoreTable.get(i).disconnectedWhilePlaying())
        tableModel.addRow(
            new String[] {scoreTable.get(i).getName(), scoreTable.get(i).getScore().toString()});
      else tableModel.addRow(new String[] {scoreTable.get(i).getName(), "Desconectado"});
    }

    table.setModel(tableModel);
    centerRenderer.setHorizontalAlignment(JLabel.CENTER);
    table.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);
    table.getColumnModel().getColumn(1).setCellRenderer(centerRenderer);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.setResizingAllowed(false);

    JPanel panel = new JPanel();
    panel.setBounds(34, 75, 264, 343);
    panel.setLayout(new BorderLayout(0, 0));
    panel.add(header, BorderLayout.NORTH);
    panel.add(table, BorderLayout.CENTER);

    contentPane.add(panel);

    JButton btnVolverAlMen = new JButton("Volver al men\u00FA principal");
    btnVolverAlMen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (userType == 0) {
              AdminMenuScreen adminmenuscreen = new AdminMenuScreen();
              adminmenuscreen.setVisible(true);
            } else {
              UserMenuScreen usermenuscreen = new UserMenuScreen();
              usermenuscreen.setVisible(true);
            }
            setVisible(false);
          }
        });
    btnVolverAlMen.setBounds(135, 453, 180, 23);
    contentPane.add(btnVolverAlMen);
  }