Package charva.awt

Examples of charva.awt.EventQueue


  // It seems reasonable to assume that the "current row" should
  // be set to the index that is being made visible.
  _currentRow = index_;

  Toolkit term = Toolkit.getDefaultToolkit();
  EventQueue evtqueue = term.getSystemEventQueue();

  // First scroll the list DOWN so that index 0 is visible.
  evtqueue.postEvent(
          new ScrollEvent(this, ScrollEvent.DOWN,
    new Point(0, 0)));

  // Then (if necessary) scroll it UP so that the specified index
  // is not below the bottom of the viewport.
  evtqueue.postEvent(
          new ScrollEvent(this, ScrollEvent.UP,
    new Point(0, index_)));
    }
View Full Code Here


   */
  if (ke_.isConsumed())
      return;

  Toolkit term = Toolkit.getDefaultToolkit();
  EventQueue evtqueue = term.getSystemEventQueue();
  int key = ke_.getKeyCode();
  switch (key) {
      case '\t':
    getParent().nextFocus();
    return;

      case KeyEvent.VK_BACK_TAB:
    getParent().previousFocus();
    return;

      case KeyEvent.VK_DOWN:
    /* If we are already at the bottom of the list, ignore
     * this keystroke.
     */
    if (_currentRow >= _listModel.getSize() -1)
        return;

    evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.UP,
      new Point(0, ++_currentRow)));
    break;

      case KeyEvent.VK_PAGE_DOWN:
    _currentRow += _visibleRows;
    if (_currentRow >= _listModel.getSize())
        _currentRow = _listModel.getSize() -1;

    evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.UP,
      new Point(0, _currentRow)));
    break;

      case KeyEvent.VK_END:
    _currentRow = _listModel.getSize() - 1;
    evtqueue.postEvent(new ScrollEvent(
            this, ScrollEvent.UP, new Point(0, _currentRow)));
    break;

      case KeyEvent.VK_UP:
    /* If we are already at the top of the list, ignore
     * this keystroke.
     */
    if (_currentRow < 1)
        return;

    evtqueue.postEvent(new ScrollEvent(
            this, ScrollEvent.DOWN, new Point(0, --_currentRow)));
    break;

      case KeyEvent.VK_PAGE_UP:
    _currentRow -= _visibleRows;
    if (_currentRow < 0)
        _currentRow = 0;

    evtqueue.postEvent(new ScrollEvent(this, ScrollEvent.DOWN,
      new Point(0, _currentRow)));
    break;

      case KeyEvent.VK_ENTER:
    _doSelect();
View Full Code Here

    public void valueChanged(ListSelectionEvent e_) {
  _popup.hide();

  /* Put an ActionEvent onto the system event queue.
   */
  EventQueue evtqueue =
    Toolkit.getDefaultToolkit().getSystemEventQueue();

  Object selectedItem = _popup.getSelectedItem();
  if (selectedItem != null)
      _model.setSelectedItem(selectedItem);

  evtqueue.postEvent(new ActionEvent(
      this, _model.getSelectedItem().toString()));
    }
View Full Code Here

        return;
    }
    super.setSelected( ! super.isSelected());

    // post an ItemEvent
    EventQueue queue = term.getSystemEventQueue();
    int state = (super.isSelected()) ?
      ItemEvent.SELECTED :
      ItemEvent.DESELECTED;
    queue.postEvent(new ItemEvent(this, this, state));
    break;
  }

  draw(Toolkit.getDefaultToolkit());
  requestFocus();
View Full Code Here

  /* Post an ItemEvent if ENTER was pressed (but only if the
   * button is not disabled).
   */
  if (super.isEnabled() && (key == KeyEvent.VK_ENTER)) {

      EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
      queue.postEvent(new ItemEvent(this, this, ItemEvent.SELECTED));
  }
    }
View Full Code Here

        return
    }
    super.setSelected(true);

    // post an ItemEvent.
    EventQueue queue = term.getSystemEventQueue();
    queue.postEvent(new ItemEvent(this, this, ItemEvent.SELECTED));
    break;
  }

  draw(Toolkit.getDefaultToolkit());
  requestFocus();
View Full Code Here

   */
  if (ke_.isConsumed())
      return;

  Toolkit term = Toolkit.getDefaultToolkit();
  EventQueue evtqueue = term.getSystemEventQueue();
  int key = ke_.getKeyCode();
  if (key == '\t') {
      getParent().nextFocus();
      return;
  }
  else if (key == KeyEvent.VK_BACK_TAB) {
      getParent().previousFocus();
      return;
  }
  else if (key == KeyEvent.VK_UP) {
      if (_currentRow == 0)
    term.beep();
      else {
    _currentRow--;
    int x=0;
    for (int i=0; i<_currentColumn; i++)
        x += getColumnWidth(i) + 1;
    evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.DOWN,
      new Point(x, _currentRow+1)));
      }
  }
  else if (key == KeyEvent.VK_DOWN) {
      if (_currentRow == _model.getRowCount() - 1)
    term.beep();
      else {
    _currentRow++;
    int x=0;
    for (int i=0; i<_currentColumn; i++)
        x += getColumnWidth(i) + 1;
    evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.UP,
      new Point(x, _currentRow+2)));
      }
  }
  else if (key == KeyEvent.VK_LEFT) {
      if (_currentColumn == 0)
    term.beep();
      else {
    _currentColumn--;
    int x=0;
    for (int i=0; i<_currentColumn; i++)
        x += getColumnWidth(i) + 1;
    evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.RIGHT,
      new Point(x, _currentRow)));
      }
  }
  else if (key == KeyEvent.VK_RIGHT) {
      if (_currentColumn == _model.getColumnCount() - 1)
    term.beep();
      else {
    _currentColumn++;
    int x=0;
    for (int i=0; i<=_currentColumn; i++)
        x += getColumnWidth(i) + 1;
    evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.LEFT,
      new Point(x, _currentRow)));
      }
  }
  else if (key == KeyEvent.VK_HOME) {
      int x=0;
      for (int i=0; i<_currentColumn; i++)
    x += getColumnWidth(i) + 1;
      evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.RIGHT,
      new Point(x, _currentRow)));
  }
  else if (key == KeyEvent.VK_END) {
      int x=0;
      for (int i=0; i<=_currentColumn; i++)
    x += getColumnWidth(i) + 1;
      evtqueue.postEvent(
        new ScrollEvent(this, ScrollEvent.LEFT,
      new Point(x, _currentRow)));
  }
  else if (key == KeyEvent.VK_ENTER) {
      if (getColumnSelectionAllowed())
View Full Code Here

      KeyEvent key_event = (KeyEvent) evt_;
      if (( ! key_event.isConsumed()) &&
    key_event.getKeyCode() == KeyEvent.VK_ENTER &&
    super.isEnabled()) {
   
    EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
    queue.postEvent(new ActionEvent(this, getActionCommand()));
    key_event.consume();
      }
  }
  else if (evt_ instanceof ActionEvent)
      fireActionPerformed((ActionEvent) evt_);
View Full Code Here

        }

        private class MyList extends JList {
            @Override
            public void processKeyEvent(KeyEvent ke) {
                EventQueue evtqueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
                int keyCode = ke.getKeyCode();
                if (keyCode == KeyEvent.VK_ENTER) {
                    Object sel = ((ListDataEntry) list.getSelectedValue()).name;
                    String s;
                    String n = null;
                    if ("..".equals(sel)) {
                        File file = new File(path);
                        n = file.getName();
                        s = file.getParentFile().getAbsolutePath();
                    } else {
                        String sels = String.valueOf(sel);
                        s = new File(path, sels.substring(1, sels.length())).getAbsolutePath();
                    }
                    int sri = setData(s, "/" + n);
                    int dir = _currentRow < sri ? ScrollEvent.UP : ScrollEvent.DOWN;
                    if (sri > -1)
                        _currentRow = sri;
                    setSelectedIndex(_currentRow);
                    evtqueue.postEvent(new ScrollEvent(this, dir, new Point(0, _currentRow)));
                    ke.consume();
                } else if (keyCode == KeyEvent.VK_HOME) {
                    _currentRow = 0;
                    evtqueue.postEvent(new ScrollEvent(
                        this, ScrollEvent.DOWN, new Point(0, _currentRow)));
                }
                super.processKeyEvent(ke);
                if (keyCode == KeyEvent.VK_UP ||
                    keyCode == KeyEvent.VK_DOWN ||
View Full Code Here

TOP

Related Classes of charva.awt.EventQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.