コード例 #1
0
 public void initHeaderTooltips() {
   ColumnHeaderToolTips tips = new ColumnHeaderToolTips();
   for (int c = 0; c < jTablePlayers.getColumnCount(); c++) {
     String tooltipText = "";
     switch (c) {
       case 0:
         tooltipText =
             "<HTML><b>The flag the user has assigned to his profile</b>"
                 + "<br>You can assign the flag in the connect to server dialog window";
         break;
       case 1:
         tooltipText =
             "<HTML><b>Name of the user</b>"
                 + "<br>(the number behind the header text is the number of currently connected users to the server)";
         break;
       case 2:
         tooltipText =
             "<HTML><b>Number of matches the user played so far</b>"
                 + "<br>Q = number of matches quit"
                 + "<br>I = number of matches lost because of idle timeout"
                 + "<br>T = number of matches lost because of match timeout";
         break;
       case 3:
         tooltipText =
             "<HTML><b>Percent-Ratio of matches played related to matches quit</b>"
                 + "<br>this calculation does not include tournament matches";
         break;
       case 4:
         tooltipText =
             "<HTML><b>Number of tournaments the user played so far</b>"
                 + "<br>D = number of tournaments left during draft phase"
                 + "<br>C = number of tournaments left during constructing phase"
                 + "<br>R = number of tournaments left during rounds";
         break;
       case 5:
         tooltipText =
             "<HTML><b>Percent-Ratio of tournament matches played related to tournament matches quit</b>"
                 + "<br>this calculation does not include non tournament matches";
         break;
       case 6:
         tooltipText =
             "<HTML><b>Current activities of the player</b>"
                 + "<BR>the header itself shows the number of currently active games"
                 + "<BR>T: = number of games threads "
                 + "<BR><i>(that can vary from active games because of sideboarding or crashed games)</i>"
                 + "<BR>limt: the maximum of games the server is configured to"
                 + "<BR><i>(if the number of started games exceed that limit, the games have to wait"
                 + "<BR>until active games end)</i>";
         break;
       case 7:
         tooltipText = "<HTML><b>Latency of the user's connection to the server</b>";
         break;
     }
     tips.setToolTip(c, tooltipText);
   }
   JTableHeader header = jTablePlayers.getTableHeader();
   header.addMouseMotionListener(tips);
 }
コード例 #2
0
 protected void uninstallMouseMotionHook() {
   MouseMotionListener[] listeners = header.getMouseMotionListeners();
   for (int i = 0; i < listeners.length; i++) {
     MouseMotionListener l = listeners[i];
     if (l == this) {
       listeners[i] = mouseMotionDelegate;
     }
     header.removeMouseMotionListener(l);
   }
   for (MouseMotionListener l : listeners) {
     header.addMouseMotionListener(l);
   }
 }
コード例 #3
0
 protected void installMouseMotionHook() {
   MouseMotionListener[] listeners = header.getMouseMotionListeners();
   for (int i = 0; i < listeners.length; i++) {
     MouseMotionListener l = listeners[i];
     if (l.getClass().getName().contains("TableHeaderUI")) {
       this.mouseMotionDelegate = l;
       listeners[i] = this;
     }
     header.removeMouseMotionListener(l);
   }
   for (MouseMotionListener l : listeners) {
     header.addMouseMotionListener(l);
   }
 }
コード例 #4
0
ファイル: JX2Table.java プロジェクト: hdijkema/JSplitTable
  public void init() {
    _persistentRequested = false;
    this.addMouseListener(new MouseAdapt(this));

    super.setShowGrid(true); // --> Not reliable with Nimbus
    super.setGridColor(new Color(160, 160, 160));
    ;
    // super.setShowGrid(false); // override default mode of any LAF
    // this.addHighlighter(new BorderHighlighter(null,SplitTableDefaults.innerCellBorder(),false));

    super.setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED);

    JTableHeader h = super.getTableHeader();
    h.addMouseListener(new zc3MouseAdaptForHeader(this));
    h.addMouseMotionListener(new zc3MouseAdaptForHeader(this));
    h.getColumnModel()
        .addColumnModelListener(
            new TableColumnModelListener() {
              public void columnAdded(TableColumnModelEvent e) {
                storeIfRequested();
              }

              public void columnRemoved(TableColumnModelEvent e) {
                storeIfRequested();
              }

              public void columnMoved(TableColumnModelEvent e) {
                storeIfRequested();
              }

              public void columnMarginChanged(ChangeEvent e) {
                storeIfRequested();
              }

              public void columnSelectionChanged(ListSelectionEvent e) {
                storeIfRequested();
              }
            });

    super.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    super.getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                  int index = getSelectedRow();
                  int indices[] = getSelectedRows();
                  if (index == -1) {
                    informUnselect();
                  } else if (indices.length > 1) {
                    Vector<Integer> rows = new Vector<Integer>();
                    for (int i : indices) {
                      rows.add(i);
                    }
                    informSelect(rows);
                  } else {
                    informSelect(index);
                  }
                }
              }
            });

    _listeners = new HashSet<SelectionListener>();
    _mlisteners = new HashSet<MultipleSelectionListener>();
    _hlisteners = new HashSet<HeaderListener>();

    addKey(
        KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (JX2Table.this.getSelectedRow() != -1) {
              JX2Table.this.deleteEvent();
            }
          }
        });

    addKey(
        KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (JX2Table.this.getSelectedRow() != -1) {
              JX2Table.this.insertEvent();
            }
          }
        });

    addKey(
        KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.VK_CONTROL),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (JX2Table.this.getSelectedRow() != -1) {
              JX2Table.this.enterEvent();
            }
          }
        });

    readPrefs();
  }