/** 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);
  }
コード例 #2
0
  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());
  }
 protected JTableHeader createDefaultTableHeader() {
   if (dataTableHeader == null) {
     dataTableHeader = new JTableHeader(getDataColumnModel());
     dataTableHeader.setResizingAllowed(true);
     dataTableHeader.setTable(dataTable);
   }
   return (dataTableHeader);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
  /**
   * 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();
    }
  }
コード例 #6
0
ファイル: RueckgabeUI.java プロジェクト: sdft/se2
  /** 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);
  }
コード例 #7
0
  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);
  }
コード例 #8
0
  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);
  }