⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resultstable.java

📁 基于jxta的局域网P2P文件共享,可以实现局域网中的文件p2p共享,实现文件快速传输及交流
💻 JAVA
字号:
package connex.plugins.filesharing.ui;

import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;

import connex.app.utils.TableUtils.*;
import connex.plugins.filesharing.*;
import connex.plugins.filesharing.model.*;
import net.jxta.share.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ResultsTable
    extends JLabel implements ContentSearchListener {

  int selectedRow;
  ContentAdvertisement contentAdv;
  BorderLayout borderLayout1 = new BorderLayout();
  private ImageIcon back = new ImageIcon(
      "resources/images/ConneXLogo_alpha5.png");
  String[] coulumnName = {
      "Name", "Size", "Type", "User", "Sources",
      "Description"};

  MyTableModel tm = new MyTableModel(coulumnName);
  ContentRow cRow;
  JTable jTable1 = new JTable(tm);
  JScrollPane jScrollPane1 = new JScrollPane();
  //ImageIcon img1 = new ImageIcon("images/scrI.jpg");
  private ContentSearch searchM;
  public ResultsTable() {

    try {
      jbInit();

    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  private void jbInit() throws Exception {

    this.setLayout(borderLayout1);
    this.setBackground(SystemColor.textHighlightText);
    this.setOpaque(true);
    this.setHorizontalAlignment(SwingConstants.TRAILING);
    this.setHorizontalTextPosition(SwingConstants.LEADING);

    this.setVerticalAlignment(SwingConstants.BOTTOM);
    this.setIcon(back);
    jTable1.setForeground(SystemColor.controlDkShadow);
    jTable1.setOpaque(false);

    jTable1.setGridColor(SystemColor.inactiveCaption);
    jTable1.setIntercellSpacing(new Dimension(2, 1));
    jTable1.setRowHeight(29);

    jScrollPane1.setOpaque(false);
    this.add(jScrollPane1, java.awt.BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jTable1);
    ListSelectionModel rowSM = jTable1.getSelectionModel();
    rowSM.addListSelectionListener(new MyListSelectionListener(this));
    jScrollPane1.getViewport().setOpaque(false);
  }

  /**
   * getSelectedContent
   */
  public void startSearch(String search) {
    this.searchM = new ContentSearch(FilesharingService.getInstance().
                                     getWorkspace().getPeerGroup(), search, this);
    searchM.activateRequest();
  }

  protected ContentSearch getContentSearch() {
    return this.searchM;
  }

  protected ContentAdvertisement getSelectedContentAdv() {
    return ( (ContentRow) tm.getRow(selectedRow)).getContentAdv();
  }

  protected MyTableModel getModel() {
    return tm;
  }

  protected int getSelectedRowIndex() {
    return selectedRow;
  }

  protected ContentRow getSelectedRow() {
    return (ContentRow) tm.getRow(selectedRow);
  }

  protected ContentRow getRow(int i) {
    return (ContentRow) tm.getRow(i);
  }

  public void receiveResult(ContentAdvertisement cAdv) {
    ContentRow row;

    row = (ContentRow) tm.getRow(cAdv.getContentId().toString());
    if (row != null) {
      row.addAdvertesement(cAdv);
      tm.fireTableRowsUpdated(row.getPosition(),row.getPosition());
    }
    else {
      cRow = new ContentRow();
      cRow.addAdvertesement(cAdv);

      tm.addRow(cRow);

    }

  }

  protected void resT_Selection(ListSelectionEvent e) {
    //Ignore extra messages.
    if (e.getValueIsAdjusting()) {
      return;
    }

    ListSelectionModel lsm =
        (ListSelectionModel) e.getSource();
    if (lsm.isSelectionEmpty()) {
      //no rows are selected
    }
    else {
      selectedRow = lsm.getMinSelectionIndex();


      //selectedRow is selected

    }

  }

  /**
   * row_Selection
   *
   * @param e ListSelectionEvent
   */


}

class MyListSelectionListener
    implements ListSelectionListener {
  private ResultsTable adaptee;

  MyListSelectionListener(ResultsTable adaptee) {
    this.adaptee = adaptee;
  }

  public void valueChanged(ListSelectionEvent e) {
    adaptee.resT_Selection(e);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -