There are 6 code examples for java.awt.datatransfer.StringSelection.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: jbidwatcher Package: com.jbidwatcher.ui

Source Code: Clipboard.java (Click to view .java file)

Method Code:
vote
like

public static void setClipboardString(String saveString){
  java.awt.datatransfer.Clipboard sysClip=Toolkit.getDefaultToolkit().getSystemClipboard();
  StringSelection t=new StringSelection(saveString);
  sysClip.setContents(t,t);
}
 

Project Name: weka Package: weka.gui

Source Code: PropertyPanel.java (Click to view .java file)

Method Code:
vote
like

public void actionPerformed(ActionEvent e){
  String str=m_Editor.getValue().getClass().getName();
  if (m_Editor.getValue() instanceof OptionHandler)   str+=" " + Utils.joinOptions(((OptionHandler)m_Editor.getValue()).getOptions());
  StringSelection selection=new StringSelection(str.trim());
  Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard();
  clipboard.setContents(selection,selection);
}
 

Project Name: weka Package: weka.gui.arffviewer

Source Code: ArffPanel.java (Click to view .java file)

Method Code:
vote
like

/** 
 * copies the content of the selection to the clipboard
 */
public void copyContent(){
  StringSelection selection;
  Clipboard clipboard;
  selection=getTable().getStringSelection();
  if (selection == null)   return;
  clipboard=Toolkit.getDefaultToolkit().getSystemClipboard();
  clipboard.setContents(selection,selection);
}
 

Project Name: weka Package: weka.gui.arffviewer

Source Code: ArffTable.java (Click to view .java file)

Method Code:
vote
like

/** 
 * returns the selected content in a StringSelection that can be copied to
 * the clipboard and used in Excel, if nothing is selected the whole table
 * is copied to the clipboard
 * @return			the current selection
 */
public StringSelection getStringSelection(){
  StringSelection result;
  int[] indices;
  int i;
  int n;
  StringBuffer tmp;
  result=null;
  if (getSelectedRow() == -1) {
    if (ComponentHelper.showMessageBox(getParent(),"Question...","Do you really want to copy the whole table?",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION)     return result;
    indices=new int[getRowCount()];
    for (i=0; i < indices.length; i++)     indices[i]=i;
  }
 else {
    indices=getSelectedRows();
  }
  tmp=new StringBuffer();
  for (i=0; i < getColumnCount(); i++) {
    if (i > 0)     tmp.append("\t");
    tmp.append(getPlainColumnName(i));
  }
  tmp.append("\n");
  for (i=0; i < indices.length; i++) {
    for (n=0; n < getColumnCount(); n++) {
      if (n > 0)       tmp.append("\t");
      tmp.append(getValueAt(indices[i],n).toString());
    }
    tmp.append("\n");
  }
  result=new StringSelection(tmp.toString());
  return result;
}
 

Project Name: weka Package: weka.gui.experiment

Source Code: AlgorithmListPanel.java (Click to view .java file)

Method Code:
vote
like

public void actionPerformed(ActionEvent e){
  String str=m_List.getSelectedValue().getClass().getName();
  if (m_List.getSelectedValue() instanceof OptionHandler)   str+=" " + Utils.joinOptions(((OptionHandler)m_List.getSelectedValue()).getOptions());
  StringSelection selection=new StringSelection(str.trim());
  Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard();
  clipboard.setContents(selection,selection);
}
 

Project Name: weka Package: weka.gui.sql

Source Code: InfoPanel.java (Click to view .java file)

Method Code:
vote
like

/** 
 * copies the currently selected error message to the clipboard
 * @return		true if the content was copied
 */
public boolean copyToClipboard(){
  StringSelection selection;
  Clipboard clipboard;
  if (m_Info.getSelectedIndices().length != 1)   return false;
  selection=new StringSelection(((JLabel)m_Info.getSelectedValue()).getText());
  clipboard=Toolkit.getDefaultToolkit().getSystemClipboard();
  clipboard.setContents(selection,selection);
  return true;
}