public void toChatScreen(String toScreen, boolean selfSeen)
      throws IOException, BadLocationException {
    // Timestamp ts = new Timestamp();
    String toScreenFinal = "";
    Date now = Calendar.getInstance().getTime();
    SimpleDateFormat format = new SimpleDateFormat("hh:mm");
    String ts = format.format(now);

    // chatScreen.append(ts + " " + toScreen + "\n");
    toScreenFinal = "<font color=gray>" + ts + "</font> ";
    if (selfSeen) toScreenFinal = toScreenFinal + "<font color=red>" + toScreen + "</font>";
    else toScreenFinal = toScreenFinal + toScreen;

    // chatter.addTo(toScreen);

    // if(standardWindow) {
    //    chatScreen.setCaretPosition(chatScreen.getDocument().getLength());
    // }
    // else {
    JScrollBar vBar = scrollChat.getVerticalScrollBar();
    int vSize = vBar.getVisibleAmount();
    int maxVBar = vBar.getMaximum();
    int currVBar = vBar.getValue() + vSize;
    kit.insertHTML(doc, doc.getLength(), toScreenFinal, 0, 0, null);
    if (maxVBar == currVBar) {
      chatScreen.setCaretPosition(chatScreen.getDocument().getLength());
    }

    // }

    // kit.insertHTML(doc, doc.getLength(), toScreenFinal, 0, 0, null);

  }
 @Override
 public void focusGained(FocusEvent fe) {
   if (-1 == table.getSelectedRow() && table.getRowCount() > 0) {
     table.setRowSelectionInterval(0, 0);
     JScrollBar scrollbar = scrollpane.getVerticalScrollBar();
     scrollbar.setValue(scrollbar.getMinimum());
   }
   if (-1 == table.getSelectedColumn()) {
     table.setColumnSelectionInterval(0, 0);
   }
 }
Exemple #3
0
  public void setResultSet(DiskResultSet rset) throws Exception {
    set = rset;

    max = rset.getRowCount();

    table.setModel(model);
    table.setModel(this);

    offset = 0;
    scrollBar.setValue(0);
    scrollBar.setMaximum((max < window ? 0 : max - window));
  }
 public void setScrollPane(JScrollPane parent) {
   this.parent = parent;
   JScrollBar jsb = parent.getVerticalScrollBar();
   jsb.addAdjustmentListener(
       new AdjustmentListener() {
         @Override
         public void adjustmentValueChanged(AdjustmentEvent ae) {
           if (!ae.getValueIsAdjusting() && autoscroll) {
             jsb.setValue(jsb.getMaximum());
           }
         }
       });
 }
Exemple #5
0
  private void addControls() {
    setLayout(new BorderLayout());

    scrollBar = new JScrollBar(JScrollBar.VERTICAL);

    table = new JTable(this);
    add(
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
    add(scrollBar, BorderLayout.EAST);

    scrollBar.addAdjustmentListener(this);
    scrollBar.setMinimum(0);
  }
    // {{{ restoreSelection() method
    public void restoreSelection(Set<String> savedChecked, Set<String> savedSelection) {
      for (int i = 0, c = getRowCount(); i < c; i++) {
        Object obj = filteredEntries.get(i);
        String name = obj.toString();
        if (obj instanceof Entry) {
          name = ((Entry) obj).plugin.jar;
        }
        if (pluginSet.contains(name)) setValueAt(true, i, 0);
        else setValueAt(savedChecked.contains(name), i, 0);
      }
      if (table == null) return;

      table.setColumnSelectionInterval(0, 0);
      if (!savedSelection.isEmpty()) {
        int i = 0;
        int rowCount = getRowCount();
        for (; i < rowCount; i++) {
          String name = filteredEntries.get(i).toString();
          if (savedSelection.contains(name)) {
            table.setRowSelectionInterval(i, i);
            break;
          }
        }
        ListSelectionModel lsm = table.getSelectionModel();
        for (; i < rowCount; i++) {
          String name = filteredEntries.get(i).toString();
          if (savedSelection.contains(name)) {
            lsm.addSelectionInterval(i, i);
          }
        }
      } else {
        if (table.getRowCount() != 0) table.setRowSelectionInterval(0, 0);
        JScrollBar scrollbar = scrollpane.getVerticalScrollBar();
        scrollbar.setValue(scrollbar.getMinimum());
      }
    } // }}}
Exemple #7
0
 public void adjustmentValueChanged(AdjustmentEvent e) {
   offset = scrollBar.getValue();
   table.tableChanged(cEvent);
 }
Exemple #8
0
 public void clear() {
   table.setModel(model);
   offset = 0;
   scrollBar.setValue(0);
   scrollBar.setMaximum(0);
 }