Package transfer.ui

Source Code of transfer.ui.TransferJTable$DoubleClickListener

package transfer.ui;


import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JTable;
import javax.swing.table.TableModel;

import transfer.AbstractFileTransfer;
import transfer.ui.bar.AbstractBar;


public class TransferJTable extends JTable
{
  private static final long serialVersionUID = 2286953050024799374L;

  public TransferJTable(TableModel model)
  {
    super(model);
    getColumnModel().getColumn(0).setMaxWidth(30);
    getColumnModel().getColumn(2).setMaxWidth(200);
    getColumnModel().getColumn(3).setMaxWidth(200);
    getColumnModel().getColumn(4).setMaxWidth(100);
    getColumnModel().getColumn(6).setMaxWidth(300);
    setDefaultRenderer(AbstractBar.class, new ProgressBarRenderer());
    addMouseListener(new DoubleClickListener());
  }

  private class DoubleClickListener extends MouseAdapter
  {
    public void mouseClicked(MouseEvent event)
    {
      if (!getSelectionModel().isSelectionEmpty())
      {
        if (event.getClickCount() == 2)
        {
          handleDoubleClick();
        }
      }
    }

    private void handleDoubleClick()
    {
      TransferTableEntry tableEntry = (TransferTableEntry) getValueAt(
          getSelectedRow(), 1);
      AbstractFileTransfer transfer = tableEntry.getTransfer();
      if (transfer.isFinished())
      {
        // TODO: open file
      }
      else
      {
        transfer.forkToChat();
      }
    }

  }

}
TOP

Related Classes of transfer.ui.TransferJTable$DoubleClickListener

TOP
Copyright © 2018 www.massapi.com. 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.