Package java.awt.datatransfer

Examples of java.awt.datatransfer.Clipboard


        sb.append("\t");
      }
      sb.deleteCharAt(sb.length() - 1);
      sb.append("\n");
    }
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection stsel = new StringSelection(sb.toString());

    clipboard.setContents(stsel, stsel);
  }
View Full Code Here


        JButton copyButton = new JButton("Copy");
        copyButton.setMnemonic('o');
        copyButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                StringSelection trace = new StringSelection(text.getText());
                Clipboard cp = Toolkit.getDefaultToolkit().getSystemClipboard();
                cp.setContents(trace, trace);
            }
        });
        buttonPanel.add(copyButton);
        buttonPanel.add(button);
        dialog.getRootPane().setDefaultButton(button);
View Full Code Here

    assertEquals("Wrong piece count in home", 0, home.getFurniture().size());
    assertEquals("Wrong wall count in home", 0, home.getWalls().size());
    assertEquals("Wrong dimension count in home", 0, home.getDimensionLines().size());
    // Check only Paste action is enabled
    assertActionsEnabled(controller, false, false, true, false);
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // Check clipboard contains two different data flavors (HomeTransferableList and Image)
    assertTrue("Missing home data flavor", clipboard.isDataFlavorAvailable(HomeTransferableList.HOME_FLAVOR));
    assertTrue("Missing String flavor", clipboard.isDataFlavorAvailable(DataFlavor.imageFlavor));

    // 8. Paste selected items in plan component
    runAction(tester, controller, HomePane.ActionType.PASTE);
    tester.waitForIdle();
    // Check home contains one piece, one wall and one dimension
    assertEquals("Wrong piece count in home", 1, home.getFurniture().size());
    assertEquals("Wrong wall count in home", 1, home.getWalls().size());
    assertEquals("Wrong dimension count in home", 1, home.getDimensionLines().size());

    // 9. Transfer focus to furniture table
    tester.actionKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK);
    // Check furniture table has focus
    assertTrue("Table doesn't have the focus", furnitureTable.isFocusOwner());
    // Delete selection
    runAction(tester, controller, HomePane.ActionType.DELETE);
    // Check home contains no piece, one wall and one dimension
    assertEquals("Wrong piece count in home", 0, home.getFurniture().size());
    assertEquals("Wrong wall count in home", 1, home.getWalls().size());
    assertEquals("Wrong dimension count in home", 1, home.getDimensionLines().size());
    // Check only Paste action is enabled
    assertActionsEnabled(controller, false, false, true, false);

    // 10. Paste selected items in furniture table
    runAction(tester, controller, HomePane.ActionType.PASTE);
    // Check home contains one piece, one wall and one dimension
    assertEquals("Wrong piece count in home", 1, home.getFurniture().size());
    assertEquals("Wrong wall count in home", 1, home.getWalls().size());
    assertEquals("Wrong dimension count in home", 1, home.getDimensionLines().size());
    // Check Cut, Copy and Paste actions are enabled
    assertActionsEnabled(controller, true, true, true, true);
   
    // 11. Copy selected furniture in clipboard while furniture table has focus
    runAction(tester, controller, HomePane.ActionType.COPY);   
    // Check clipboard contains two different data flavors (HomeTransferableList and String)
    assertTrue("Missing home data flavor", clipboard.isDataFlavorAvailable(HomeTransferableList.HOME_FLAVOR));
    assertTrue("Missing String flavor", clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor));
  }
View Full Code Here

  /**
   * Returns <code>true</code> if clipboard contains data that
   * components are able to handle.
   */
  public boolean isClipboardEmpty() {
    Clipboard clipboard = getToolkit().getSystemClipboard();
    return !(clipboard.isDataFlavorAvailable(HomeTransferableList.HOME_FLAVOR)
        || getToolkit().getSystemClipboard().isDataFlavorAvailable(DataFlavor.javaFileListFlavor));   
  }
View Full Code Here

  }


  void setClipboardContents( String str ){
    StringSelection stringSelection = new StringSelection( str );
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents( stringSelection, this );
  }
View Full Code Here

  protected void doCopyPath() {
    String path = node.absolutePath();

    StringSelection sel  = new StringSelection(path);
    Clipboard       clip = Toolkit.getDefaultToolkit().getSystemClipboard();
   
    clip.setContents(sel, sel);
  }
View Full Code Here

   
   
  public String getClipboardText() {
    try {
      // get the system clipboard
      Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
     
      // get the contents on the clipboard in a
      // transferable object
      Transferable clipboardContents = systemClipboard.getContents(null);
     
      // check if clipboard is empty
      if (clipboardContents == null) {
       
        //Clipboard is empty!!!
View Full Code Here

      //clippy.setContents( clippysContent ,null); //zur�cksetzen vom alten Kontext
    }
   
    private void pressSpecialSign(String charValue, Robot instance)
    {
      Clipboard clippy = Toolkit.getDefaultToolkit().getSystemClipboard();
      //Transferable clippysContent = clippy.getContents( null );
      try{

     Transferable transferableText = new StringSelection(charValue);
         clippy.setContents( transferableText, null  );
       
         //logger.debug("os.name :: "+System.getProperty("os.name"));
      
         if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") >= 0) {
        
View Full Code Here

    }
   
    public String getClipboardText() {
    try {
      // get the system clipboard
      Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
     
      // get the contents on the clipboard in a
      // transferable object
      Transferable clipboardContents = systemClipboard.getContents(null);
     
      // check if clipboard is empty
      if (clipboardContents == null) {
       
        //Clipboard is empty!!!
View Full Code Here

      //clippy.setContents( clippysContent ,null); //zur�cksetzen vom alten Kontext
    }
   
    private void pressSpecialSign(String charValue, Robot instance)
    {
      Clipboard clippy = Toolkit.getDefaultToolkit().getSystemClipboard();
      //Transferable clippysContent = clippy.getContents( null );
      try{

     Transferable transferableText = new StringSelection(charValue);
         clippy.setContents( transferableText, null  );
       
         //logger.debug("os.name :: "+System.getProperty("os.name"));
      
         if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") >= 0) {
        
View Full Code Here

TOP

Related Classes of java.awt.datatransfer.Clipboard

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.