List of usage examples for java.awt.datatransfer Clipboard setContents
public synchronized void setContents(Transferable contents, ClipboardOwner owner)
From source file:library.Form_Library.java
License:asdf
private void tbBookAdminMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbBookAdminMouseClicked // TODO add your handling code here: int donghh = this.tbBookAdmin.getSelectedRow(); Book b = BookList.getBook(donghh); this.viewBook(b); jMenuItemBook.addActionListener(new ActionListener() { @Override/*from w w w. j av a 2 s . com*/ public void actionPerformed(ActionEvent e) { StringSelection entry = new StringSelection(tfBookID.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(entry, entry); } }); }
From source file:library.Form_Library.java
License:asdf
private void tbAuthorAdminMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbAuthorAdminMouseClicked // TODO add your handling code here: int donghh = this.tbAuthorAdmin.getSelectedRow(); Author b = AuthorList.getAuthor(donghh); this.viewAuthor(b); jMenuItemAuthor.addActionListener(new ActionListener() { @Override//from w w w.j a va 2 s. co m public void actionPerformed(ActionEvent e) { StringSelection entry = new StringSelection(tfAuthorID1.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(entry, entry); } }); }
From source file:library.Form_Library.java
License:asdf
private void tbPublisherMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbPublisherMouseClicked int donghh = this.tbPublisher.getSelectedRow(); Publisher b = PublisherList.getPublisher(donghh); this.viewSupplier(b); jMenuItemPub.addActionListener(new ActionListener() { @Override/*from w w w .jav a2 s .co m*/ public void actionPerformed(ActionEvent e) { StringSelection entry = new StringSelection(tfPublisherID.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(entry, entry); } }); }
From source file:library.Form_Library.java
License:asdf
private void tbSupplierAdminMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbSupplierAdminMouseClicked // TODO add your handling code here: int donghh = this.tbSupplierAdmin.getSelectedRow(); Supplier b = SupplierList.getSupplier(donghh); this.viewSupplier1(b); jMenuItemSup.addActionListener(new ActionListener() { @Override/*from w ww . ja va 2 s . c o m*/ public void actionPerformed(ActionEvent e) { StringSelection entry = new StringSelection(tfSupplierID1.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(entry, entry); } }); }
From source file:library.Form_Library.java
License:asdf
private void tbBorrowingManagementMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbBorrowingManagementMouseClicked int donghh = this.tbBorrowingManagement.getSelectedRow(); BorrowingManagement b = BorrowingList.getBorrowingManagement(donghh); this.viewBorrowing(b); // System.out.println(tbBorrowingManagement.getValueAt(donghh, 4).toString()); jMenuItemBo.addActionListener(new ActionListener() { @Override/*from ww w. jav a 2s .c om*/ public void actionPerformed(ActionEvent e) { StringSelection entry = new StringSelection(tfBorrowID.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(entry, entry); } }); }
From source file:library.Form_Library.java
License:asdf
private void tbReaderMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbReaderMouseClicked carActivationDate.setEnabled(true);//w w w . j a v a 2 s. c o m carExpiredDate.setEnabled(true); int donghh = this.tbReader.getSelectedRow(); Reader t = ReaderList.getReader(donghh); this.viewReader(t); this.taPrintReader.setText(""); this.taPrintReader.append("Receipt\n"); this.taPrintReader.append("ReaderID: " + this.tfID.getText() + ".\n"); this.taPrintReader.append("Name: " + this.tfName.getText() + ".\n"); this.taPrintReader.append("IDCardNo: " + this.tfIDCardNumber.getText() + ".\n"); this.taPrintReader.append("Gender: " + this.cbSex.getSelectedItem() + ".\n"); this.taPrintReader.append("Birthday: " + df.format(this.carBirthday.getDate()) + ".\n"); this.taPrintReader.append("Address: " + this.tfAddress.getText() + ".\n"); this.taPrintReader.append("Phone: " + this.tfPhone.getText() + ".\n"); this.taPrintReader.append("Email: " + this.tfEmail.getText() + ".\n"); this.taPrintReader.append("Activation Date: " + df.format(this.carActivationDate.getDate()) + ".\n"); this.taPrintReader.append("Expired Date: " + df.format(this.carExpiredDate.getDate()) + ".\n"); this.taPrintReader.append("Paid: 80.000 VN?"); this.taPrintReader.append("\r\n"); jMenuItemReader.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { StringSelection entry = new StringSelection(tfID.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(entry, entry); } }); }
From source file:com.cohort.util.String2.java
/** This method writes a string to the system clipboard. * This works in a standalone Java program, not an applet. * From Java Developers Almanac.//from w w w . j a v a 2s . co m * This won't throw an exception. */ public static void setClipboardString(String s) { try { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(s), null); } catch (Throwable t) { log(ERROR + " while putting the string on the clipboard:\n" + MustBe.throwableToString(t)); } }
From source file:lu.fisch.unimozer.Diagram.java
/** * Copies the UML diagram of a *SINGLE CLASS* as PNG to the clipboard. * @param mode the drawing mode://from www . j a va2 s . com * 0 = uncompiled, nothing selected * 1 = uncompiled, selected * 2 = compiled */ public void copyToClipboardPNG(MyClass myClass, int mode) { Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); //DataFlavor pngFlavor = new DataFlavor("image/png","Portable Network Graphics"); // reset the comments commentString = null; commentPoint = null; // get diagram BufferedImage image = new BufferedImage(myClass.getWidth() + 1, myClass.getHeight() + 1, BufferedImage.TYPE_INT_ARGB); myClass.draw(image.getGraphics(), showFields, showMethods, mode); // do twice to make shure the image dimensions are OK if (mode == 2) // because of the double border image = new BufferedImage(myClass.getWidth() + 5, myClass.getHeight() + 5, BufferedImage.TYPE_INT_ARGB); else image = new BufferedImage(myClass.getWidth() + 1, myClass.getHeight() + 1, BufferedImage.TYPE_INT_ARGB); myClass.draw(image.getGraphics(), showFields, showMethods, mode); /* debug: save the image somewhere */ /* try { ImageIO.write((RenderedImage) image, "png", new File("/Users/robertfisch/Desktop/test.png")); } catch (IOException ex) { ex.printStackTrace(); } */ /* for (final DataFlavor flavor : Toolkit.getDefaultToolkit().getSystemClipboard().getAvailableDataFlavors()) { System.out.println(flavor.getMimeType()); } */ // put image to clipboard ImageSelection imageSelection = new ImageSelection(image); try { systemClipboard.setContents(imageSelection, null); } catch (Exception ex) { // ignore } // use the JWS clipboard if loaded via JWS try { Class.forName("javax.jnlp.ClipboardService"); final ClipboardService clipboardService = (ClipboardService) ServiceManager .lookup("javax.jnlp.ClipboardService"); clipboardService.setContents(imageSelection); } catch (Exception ex) { // ignore } }
From source file:lu.fisch.unimozer.Diagram.java
public void copyToClipboardPNG() { Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); //DataFlavor pngFlavor = new DataFlavor("image/png","Portable Network Graphics"); // reset the comments commentString = null;//from w ww . jav a 2s . c o m commentPoint = null; // get diagram BufferedImage image = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_ARGB); paint(image.getGraphics()); /*System.out.println(this.topLeft.x); System.out.println(this.topLeft.y); System.out.println(this.bottomRight.x); System.out.println(this.bottomRight.y);*/ int x = this.topLeft.x - 2; if (x < 0) x = 0; int y = this.topLeft.y - 2; if (y < 0) y = 0; image = new BufferedImage(this.bottomRight.x + 2 + 1 + 4, this.bottomRight.y + 2 + 1 + 4, BufferedImage.TYPE_INT_ARGB); paint(image.getGraphics()); /*System.out.println(this.getWidth()); System.out.println(this.getParent().getWidth()); System.out.println(x+this.bottomRight.x-x+2+1+4); System.out.println(x+" , "+ y+" , "+ (this.bottomRight.x-x+2+1+4)+" , "+ (this.bottomRight.y-y+2+1+4)); */ BufferedImage image2 = image.getSubimage(x, y, this.bottomRight.x - x + 2 + 1 + 4, this.bottomRight.y - y + 2 + 1 + 4); // put image to clipboard ImageSelection imageSelection = new ImageSelection(image2); try { systemClipboard.setContents(imageSelection, null); } catch (Exception ex) { // ignore } // use the JWS clipboard if loaded via JWS try { Class.forName("javax.jnlp.ClipboardService"); final ClipboardService clipboardService = (ClipboardService) ServiceManager .lookup("javax.jnlp.ClipboardService"); clipboardService.setContents(imageSelection); } catch (Exception ex) { //ex.printStackTrace(); } }