コード例 #1
0
  /** Update favorite menu with resource. */
  public void updateFavoriteMenu() {
    final Vector favorites = resource.getFavorites();
    favoriteItems = new JMenuItem[favorites.size()];

    historyMenu.removeAll();

    // 顯示目前我的最愛內容
    for (int i = 0; i < favorites.size(); i++) {
      final Site fa = (Site) favorites.elementAt(i);
      favoriteItems[i] = new JMenuItem(fa.getName());
      favoriteItems[i].setToolTipText(fa.getHost() + ":" + fa.getPort()); // $NON-NLS-1$
      favoriteItems[i].addActionListener(actionController);
      historyMenu.add(favoriteItems[i]);
    }
  }
コード例 #2
0
  /**
   * Connect to the site at certain index of tab page.
   *
   * @param site site to be connected.
   * @param index the index of tab page corresponding to this site.
   */
  public void connect(final Site site, final int index) {
    final SessionPane session = new SessionPane(site, terminalImage);

    // index 為連線後放在第幾個分頁,若為 -1 表開新分頁。
    if (index == -1) {
      model.getSessions().add(session);

      // 一開始預設 icon 是連線中斷
      final ImageIcon icon = closedIcon;

      tabbedPane.addTab(site.getName(), icon, session, site.getHost());
      tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
    } else {
      model.getSessions().setElementAt(session, index);
      tabbedPane.setComponentAt(index, session);
    }

    // 每個 session 都是一個 thread, 解決主程式被 block 住的問題。
    new Thread(session).start();
  }