Writing text in the clipboard

Hi,
To write text in the clipboard the natural way is to use the StringSelection flavor. The problem is it requires a String to work on. But here I have a big volume (xml) that I generate from a DOM like structure => I would like to stream the generated xml in the clipboard without loading it in a String.
Anybody knows if it is possible by writing a custom Data Flavor ?
Thanks,
Jean

Look at the ArrayListTransferHandler class in the following Drag List Demo example: http://www.java2s.com/Code/Java/Swing-JFC/DragListDemo.htm

Similar Messages

  • I find that I can no longer copy text to the clipboard.

    Why can I no longer copy text to my clipboard?

    Here is a little more information.  Last week everything worked fine.  I opened the same document yesterday and tried to copy some text to the clipboard and now I get an error message saying "can not copy to clipboard, internal error.  I also find that pdf files from the internet will not load and all I get is a small black x box in the upper left corner of the screen.  Went through the steps in control panel and adobe is enabled.

  • Writing Image in the clipboard to Oracle DB

    Hi,
    I want to write the image in the clipboard to the Blob am using JDeveloper. Can any1 help me please I am stuck on conversion and writing to Blob.
    Very Urgent Please!!!!!!!
    Comments: Applet is used to diplay an image present in the clipboard, convert this image into bytes write it to a blob and transfer the blob into Oracle DB
    package mypackage1;
    import java.applet.Applet;
    import javax.swing.JLabel;
    import oracle.jdeveloper.layout.XYLayout;
    import oracle.jdeveloper.layout.XYConstraints;
    import java.awt.datatransfer.*;
    import java.awt.image.*;
    import java.awt.datatransfer.DataFlavor;
    import java.awt.event.*;
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import oracle.jdeveloper.layout.OverlayLayout2;
    import java.awt.Button;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.sql.Blob;
    import java.sql.Statement;
    import java.awt.Toolkit;
    import java.awt.event.*; //Clipboard
    import java.awt.datatransfer.*; //Clipboard
    import java.awt.Image;// .image.*; //Clipboard
    import java.sql.*;
    import java.sql.*;
    import java.net.*;
    import java.lang.*;
    import java.awt.TextField;
    import java.awt.Font;
    import oracle.sql.BLOB;
    public class ClipboardImage extends Applet
    Button displayButton = new Button();
    Button exitButton = new Button();
    JLabel photoLabel = new JLabel();
    Panel panel1 = new Panel();
    XYLayout xYLayout2 = new XYLayout();
    XYLayout xYLayout1 = new XYLayout();
    Button submitButton = new Button();
    Connection connection = null;
    static Image photo;
    public byte[] data;
    public Blob bl;
    TextField Message = new TextField();
    public ClipboardImage()
    public void init()
    try
    jbInit();
    catch(Exception e)
    e.printStackTrace();
    public static void main(String[] args)
    ClipboardImage applet = new ClipboardImage();
    Frame frame = new Frame();
    frame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    frame.add(applet, BorderLayout.CENTER);
    frame.setTitle("Applet Frame");
    applet.init();
    applet.start();
    frame.setSize(300, 300);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    frame.setLocation((d.width - frameSize.width) / 2, (d.height -
    frameSize.height) / 2);
    frame.setVisible(true);
    private void jbInit() throws Exception
    this.setLayout(xYLayout2);
    this.setBackground(new Color(136, 212, 122));
    displayButton.setLabel("Display");
    displayButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    scanButton_actionPerformed(e);
    exitButton.setLabel("Exit");
    exitButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    exitButton_actionPerformed(e);
    photoLabel.setText("Photo");
    panel1.setLayout(xYLayout1);
    panel1.setBackground(new Color(255, 249, 240));
    xYLayout2.setWidth(288);
    xYLayout2.setHeight(300);
    submitButton.setLabel("Submit");
    submitButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    submitButton_actionPerformed(e);
    Message.setFont(new Font("Abadi MT Condensed", 0, 9));
    panel1.add(photoLabel, new XYConstraints(0, 0, 115, 155));
    this.add(Message, new XYConstraints(20, 275, 250, 15));
    this.add(submitButton, new XYConstraints(105, 220, 80, 30));
    this.add(panel1, new XYConstraints(90, 25, 115, 155));
    this.add(exitButton, new XYConstraints(195, 220, 85, 30));
    this.add(displayButton, new XYConstraints(10, 220, 85, 30));
    void exitButton_actionPerformed(ActionEvent e)
    System.exit(0);
    If an image is on the system clipboard, this method returns it
    otherwise it returns null
    public static Image getClipboard()
    Transferable t =
    Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
    try
    if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor))
    Image text = (Image)t.getTransferData(DataFlavor.imageFlavor);
    photo = text;
    return text;
    catch (UnsupportedFlavorException e)
    catch (IOException e)
    return null;
    Display an image in the system's clipboard
    void scanButton_actionPerformed(ActionEvent e)
    Image img = this.getClipboard();
    photo = img;
    photoLabel.setIcon(new ImageIcon(photo));
    // Gives out int array
    public int[] fetchPixels(Image image, int width, int height)
    int pixMap[] = new int[width*height];
    PixelGrabber pg = new PixelGrabber(image, 0,0,width,height, pixMap,
    0, width);
    try
    pg.grabPixels();
    catch (InterruptedException e)
    return null;
    if((pg.status() & ImageObserver.ABORT)!=0)
    return null;
    return pixMap;
    // Here int array given by Pixel Grabber function is converted into
    byte array
    public byte[] extractData(int[] pixmap, int numbands) {
    byte data[] = new byte[pixmap.length*numbands];
    for(int i=0;i<pixmap.length;i++){
    int pixel = pixmap;
    byte a = (byte)((pixel >> 24) & 0xff);
    byte r = (byte)((pixel >> 16) & 0xff);
    byte g = (byte)((pixel >> 8) & 0xff);
    byte b = (byte)((pixel ) & 0xff);
    if(numbands == 4){
    data[i*numbands+0] = r;
    data[i*numbands+1] = g;
    data[i*numbands+2]= b;
    data[i*numbands+3] = a;
    } else {
    data[i*numbands+0] = r;
    data[i*numbands+1] = g;
    data[i*numbands+2]= b;
    return data;
    public void processData() {
    Image awtImage = getClipboard();
    int imageWidth = awtImage.getWidth(this);
    int imageHeight = awtImage.getHeight(this);
    int[] pix = fetchPixels(awtImage, imageWidth, imageHeight);
    data = extractData(pix, 4);
    photo = awtImage;
    System.out.println(" Height = " + imageHeight + " Width = " +
    imageWidth + " Pixel = " + pix + " Byte = " + data);
    void submitButton_actionPerformed(ActionEvent e)
    processData();
    try {
    System.out.println("Executing code");
    // Load the JDBC driver
    String driverName = "oracle.jdbc.driver.OracleDriver";
    Class.forName(driverName);
    // Create a connection to the database
    String serverName = "10.20.90.101";
    String portNumber = "1521";
    String sid = "iasdb";
    String url = "jdbc:oracle:thin:@" + serverName + ":" +
    portNumber + ":" + sid;
    String username = "birmingham";
    String password = "in";
    connection = DriverManager.getConnection(url, username,
    password);
    PreparedStatement ast = connection.prepareStatement("INSERT
    INTO PASSPORT (PASSID, PHOTO) VALUES (1992, EMPTY_BLOB())");
    ast.executeUpdate();
    PreparedStatement pst = connection.prepareStatement("UPDATE
    PASSPORT SET PHOTO = ? WHERE PASSID = 1992");
    //pst.setObject(1, (Object)photo);
    //Writing bytes to blob bl
    bl.setBytes(0, data);
    //Setting the blob to transfer to the blob column in oracle
    db
    pst.setBlob(1, bl);
    pst.executeUpdate(); if(pst.EXECUTE_FAILED == 1)
    Message.setText("Sql failed!");
    }else{
    Message.setText("Sql success!");
    System.out.println ("Connected\n");
    } catch (ClassNotFoundException ea) {
    // Could not find the database driver
    } catch (SQLException ea) {
    System.out.println(ea.toString());

    Look at the ArrayListTransferHandler class in the following Drag List Demo example: http://www.java2s.com/Code/Java/Swing-JFC/DragListDemo.htm

  • Copying text to the clipboard in AVDocDidOpen event handler causes Acrobat 9 to crash

    I'm trying to copy the filename of a document to the clipboard in a plugin with my AVDocDidOpen event handler.  It works for the first file opened; however when a second file is opened, Acrobat crashes.  The description in the application event log is: "Faulting application acrobat.exe, version 9.1.0.163, faulting module gdi32.dll, version 5.1.2600.5698, fault address 0x000074cc."
    I've confirmed that the specific WIN32 function that causes this to happen is SetClipboardData(CF_TEXT, hText);  When that line is commented out and remaining code is left unchanged, Adobe doesn't crash.
    Is there an SDK function that I should be using instead of WIN32's SetClipboardData()?  Alternately, are there other SDK functions that I need to call be before or after I call SetClipboardData()
    Bill Erickson

    Leonard,
    I tried it with both "DURING, HANDLER, END_HANDLER" and "try catch," as shown below.  However, it doesn't crash in the event handler; it crashes later, so the HANDLER/catch block is never hit.
    The string that's passed to SetClipboardData() is good, because I'm able to paste it into the filename text box of the print dialog when I try to create the "connector line" PDF.  I also got rid of all the string manipulation and tried to pass a zero-length string to the clipboard but it still crashes.
    Here's the code:
    ACCB1 void ACCB2 CFkDisposition::myAVDocDidOpenCallback(AVDoc doc, Int32 error, void *clientData)
        PDDoc pdDoc = AVDocGetPDDoc(doc);
        char* pURL = ASFileGetURL(PDDocGetFile(annotDataRec->thePDDoc));
        if (pURL)    {
            if (strstr(pURL, "file://") && strstr(pURL, "Reviewed.pdf")) {
                // Opened from file system so copy filename to clipboard for connector line report
                char myURL[1000];
                strcpy(myURL, pURL);
                ASfree(pURL);    // Do this before we allocate a Windows handle just in case Windows messes with this pointer
                pURL = NULL;
                HGLOBAL hText = GlobalAlloc(GMEM_MOVEABLE, 1000);
                if (hText)    {
                    try
                        // Skip path info and go right to filename
                        char *pText = (char *)GlobalLock(hText);
                        char *pWork = strrchr(myURL,'/');
                        if (pWork)    {
                            strcpy(pText, pWork+1);
                        } else {
                            strcpy(pText, myURL);
                        char *pEnd = pText + strlen(pText);    // Get null terminator address
                        // Replace "%20" in filename with " "
                        pWork = strstr(pText, "%20");
                        while (pWork)    {
                            *pWork = ' ';
                            memmove(pWork+1, pWork+3, (pEnd - (pWork+2)));
                            pWork = strstr(pText, "%20");
                        // Append a new file extension
                        pWork = strstr(pText, ".pdf");
                        *pWork = 0;    // truncate the string before ".pdf"
                        strcat(pWork,".Connectors.pdf");
                        GlobalUnlock(hText);     // Must do this BEFORE SetClipboardData()
                        // Write it to the clipboard
                        OpenClipboard(NULL);
                        EmptyClipboard();
                        SetClipboardData(CF_TEXT, hText);     // Here's the culprit
                        CloseClipboard();
                        GlobalFree(hText);
                    } catch (char * str) {
                        AVAlertNote(str);
            if (pURL)
                ASfree(pURL);

  • Programatically copying text to the clipboard

    Short: I need to programatically copy a string of text from
    either a variable or a hidden control field to the clipboard.
    Long: We have a requirement to allow the user to 'pop-up' a
    list of frequently used words, select one from the list and have
    it pasted into a field on the form. What I would prefer to do
    is select the user's words into an LOV and have the chosen word
    placed into a hidden field. If I could move the contents of
    that field to the clipboard, I can place the focus back in the
    original field ('keep cursor position' = yes) and used the
    PASTE_REGION built-in to insert the text without overwriting
    anything.
    The other method I have been experimenting with is creating my
    own 'List of Values' form. I'm using a t-list to display the
    user's word list. When-List-Changed copies the word to a visible
    text field and an OK button places the focus in the text field,
    executes the SELECT-ALL built-in, then the COPY-REGION built-in
    and returns to the calling form with the word in the clipboard.
    Problems: The user can't shrink the list by typing like they can
    with an Oracle LOV. When the focus is in the t-list, the
    DEFAULT functionality of the OK button doesn't happen. I can't
    get a When-Mouse-Doubleclick trigger to fire while in the t-list.
    In the end, I prefer the first method (the LOV) BUT... I have to
    have a field visible on the form to place focus in, select all
    of the text and copy to the clipboard. This field looks silly.
    I'm sorry this question is so long winded. Thank you for
    reading it all. Does anyone know how I might accomplish this
    requirement (professionally)?
    Thank you,
    Fouad

    Short: I need to programatically copy a string of text from
    either a variable or a hidden control field to the clipboard.
    Long: We have a requirement to allow the user to 'pop-up' a
    list of frequently used words, select one from the list and have
    it pasted into a field on the form. What I would prefer to do
    is select the user's words into an LOV and have the chosen word
    placed into a hidden field. If I could move the contents of
    that field to the clipboard, I can place the focus back in the
    original field ('keep cursor position' = yes) and used the
    PASTE_REGION built-in to insert the text without overwriting
    anything.
    The other method I have been experimenting with is creating my
    own 'List of Values' form. I'm using a t-list to display the
    user's word list. When-List-Changed copies the word to a visible
    text field and an OK button places the focus in the text field,
    executes the SELECT-ALL built-in, then the COPY-REGION built-in
    and returns to the calling form with the word in the clipboard.
    Problems: The user can't shrink the list by typing like they can
    with an Oracle LOV. When the focus is in the t-list, the
    DEFAULT functionality of the OK button doesn't happen. I can't
    get a When-Mouse-Doubleclick trigger to fire while in the t-list.
    In the end, I prefer the first method (the LOV) BUT... I have to
    have a field visible on the form to place focus in, select all
    of the text and copy to the clipboard. This field looks silly.
    I'm sorry this question is so long winded. Thank you for
    reading it all. Does anyone know how I might accomplish this
    requirement (professionally)?
    Thank you,
    Fouad

  • Button to copy text to the clipboard

    Reading the document "Javascript for Acrobat API Reference" Page 120:
    http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf
    the document discusses the execMenuItem command. From all that I have researched it appears I cannot create a button that copies text from a text field to the UI clipboard. 
    On page 121 the API reference says:
    To ensure a secure environment, the menu items that can be executed are limited to the following:
    ●AcroSendMail:SendMail
    ●ActualSize
    ●AddFileAttachment
    ●BookmarkShowLocation
    ●Close
    ●CropPages
    ●DeletePages.............
    ..............●ZoomViewOut
    The list is long but nowhere is "Copy" mentioned. I don't want to surreptitiously copy text or use a trusted function. I am content with the user knowing a button just copied a field of text. I just want to skip the highlighting of multiple field to get all the text. Does anyone know a way around this? I would like to copy a text field to the clipboard so the text can be entered elsewhere in another program.

    All I know is they made this impossible a long time ago, like with Acrobat 5 or 6. I recall because I took advantage of it and never discovered a workaround.

  • Is it possible to copy text to the clipboard in Illustrator via Javascript ?

    I am working on a very basic script that exports coordinates from Illustrator.
    At the moment I am just outputing the values via $.writeln()
    I was wondering if I could copy the output values to the clipboard. If so, what
    am I looking for in the API ?
    Thanks,
    George

    For an actionscript project I will need to animate a few hundred objects to certain destinations. These destinations are given by a designer who works on the look and feel of things in Illustrator.
    I would like to make it as simple as possible for the designer to adjust things visually in Illustrator, then he can get a snippet to test in Flash as well.
    Thank you very much for the applescript idea!
    I'll use something like:
    app.system("osascript -e 'set the clipboard to \"" + code + "\"'");

  • Unable to copy text values in CLipboard in Ubuntu 8.1

    Hi all ,
    Im using the following code to copy the text:
    import java.awt.Toolkit;
    import java.awt.datatransfer.Clipboard;
    import java
         .awt
         .datatransfer
         .StringSelection;
    import java
         .awt
         .datatransfer
         .Transferable;
    public class TextWriter {
         public static void writeToClipboard(String writeMe) {
              // get the system clipboard
              Clipboard systemClipboard =
                   Toolkit
                        .getDefaultToolkit()
                        .getSystemClipboard();
              // set the textual content on the clipboard to our
              // transferable object
              // we use the
              Transferable transferableText =
                   new StringSelection(writeMe);
              systemClipboard.setContents(
                   transferableText,
                   null);
         public static void main(String[] args) {
              System.out.println(
                   "Writing text to the system clipboard.");
              String writeMe =
                   "I'd like to be put on the clipboard";
              writeToClipboard(writeMe);
    }After running the application when I try to paste it in GEDIT , it is not pasting .
    Also in menubar the PASTE is also not getting enable.
    Can anybody tell how to copy text .
    OS used Ubuntu 8.1 and java version 1.6 update 10
    Thanks and regards
    Anshuman Srivastava

    Copy cannot be disabled to my knowledge. Did you try quitting Safari and resetting your iPad? To quit an app double click the Home button to reveal the row of recently used apps. Flick up on the page preview and it will fly away and disappear. That quits the app. Then Press and hold both the Home button and the Sleep/Wake button continuously until the Apple logo appears. Then release the button and let the device restart. You will not lose data doing this. It's like a computer reboot.

  • Can JButtons within applets copy to the clipboard?

    camickr wrote in another thread:
    As always I would like to see the Applet used that caused the problem. We should not have to create our own applet to test this. As we all know from the original problem you may be missing/adding code. And this posting is way off topic so any new SSCCE along with a new question should be posted in a new posting. If I understand the problem is that Ctrl+C works on a text area, but it doesn't work for a JButton that tries to copy text from the same text area?Not quite. Ctrl+C works within a JTable, copying selected row(s) to the clipboard. The problem is getting a JButton to copy arbitrary text to the clipboard, having nothing to do with a JTable.
    Well post the simple 20 line applet that demonstates this.Sorry, it's more than 20 lines. I included three approaches, Jeanette's, Walter's, and mine.
    * Created on 06.12.2010
    * Jeanette, Walter, and Rich
    import java.awt.EventQueue;
    import java.awt.datatransfer.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.Toolkit;
    import javax.swing.*;
    public class ThreeCopyButtons  extends JApplet  implements ClipboardOwner
        final JLabel first  = new JLabel("Larry");
        final JLabel second = new JLabel("Moe");
        final JLabel third  = new JLabel("Curly");
        static ThreeCopyButtons cb3;
        public JPanel getContent() {
            JButton kleo = new JButton("Kleo");
         cb3 = this;
            TransferHandler handler = new TransferHandler() {
                 * @inherited <p>
                @Override
                protected Transferable createTransferable(JComponent c) {
                    return new StringSelection(cb3.toString());
                 * @inherited <p>
                @Override
                public int getSourceActions(JComponent c) {
                    return COPY;
            kleo.setTransferHandler(handler);
            kleo.setAction(TransferHandler.getCopyAction());
            kleo.setText("Kleo");  // gets overridden by "copy"
         AppletCopyButton walt = new AppletCopyButton("Walt", toString());
         JButton rich = new JButton("Rich");
         rich.addActionListener( new ActionListener() {
             public void actionPerformed(ActionEvent e) {
              StringSelection ss = new StringSelection(cb3.toString());
              Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
              cb.setContents(ss, cb3);
            JComponent buttons = new JPanel();
            buttons.add(kleo);
            buttons.add(walt);
            buttons.add(rich);
            JPanel labels = new JPanel();
            labels.add(first);
            labels.add(second);
            labels.add(third);
            JPanel box = new JPanel();
            box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
         box.add(buttons);
         box.add(labels);
            return box;
        public String toString() {
         String s = first.getText() + "\t" +
                 second.getText() + "\t" +
                 third.getText();
         return(s);
        // Empty method needed for implementation of the ClipboardOwner interface.
        public void lostOwnership( Clipboard aClipboard, Transferable aContents) {
          //do nothing
        // method expected by applets
        public void init()
        { // the static block above should have already executed
         try {
             javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
              public void run() {
                  JPanel frame = getContent();
                  setContentPane(frame);
         } catch (Exception e) {
             System.err.println("makeContent() failed to complete: " + e);
             e.printStackTrace();
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.add(new ThreeCopyButtons().getContent());
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    // Walter Laan
    class AppletCopyButton extends JButton {
        public AppletCopyButton(String label, String text) {
            super(label);
         final String clip = text;
            setTransferHandler(new TransferHandler() {
                // @Override
                protected Transferable createTransferable(JComponent c) {
                    return new StringSelection(clip);
                // @Override
                public int getSourceActions(JComponent c) {
                    return COPY;
            addActionListener(new ActionListener() {
                // @Override
                public void actionPerformed(ActionEvent e) {
                    Action copy = TransferHandler.getCopyAction();
                    copy.actionPerformed(new ActionEvent(AppletCopyButton.this,
                            ActionEvent.ACTION_PERFORMED, "copy"));
    }Here is a manifest file I call "3cbManifest.txt".
    Main-Class: ThreeCopyButtonsMake sure you preserve the trailing carriage return.
    ]javac ThreeCopyButtons.java
    ]jar cvfm ThreeCopyButtons.jar 3cbManifest.txt *.class
    ]java -jar ThreeCopyButtons.jar
    (The latter command simply tests, but it is running as program, not applet.)
    And here is a short HTML file to run it as an applet. I call it "3cb.html".
    <html>
    <head><title>TestApplet</title></head>
    <body>
    <applet code="ThreeCopyButtons.class"
            archive="ThreeCopyButtons.jar"
            width="450" height="300">
    Your browser is completely ignoring the <i>applet</i> tag!
    </applet>
    </body>
    </html>The three buttons match our three approaches:
    * Kleo -- Jeanette's approach
    * Walt -- Walt's approach
    * Rich -- my approach
    All three methods work fine as a program, whether running directly as classes or from the .jar. None however work as an applet, from the HTML page.
    To test either as applet or program:
    1) open a text editor
    2) type something short
    3) Ctrl+C copy what you typed
    4) click the Kleo button
    5) in editor, click <enter> and Ctrl+V to paste
    6) observe whether you see the text from step 3 or "Larry Moe Curly", with <tabs> between words.
    7) repeat steps 3-6 for the Walt and Rich buttons
    If you can figure out how to get the applet to bypass its security wall, great. We've found a bug in Java's applet security. If not, I am resigned to having the button in my actual app copy info to the table instead of to the clipboard.

    RichF wrote:
    You are right, but aw gee whiz. Have you ever written something that you think is pretty neat, then have to throw it away? hahahahahaha ... sure, happens nearly every day :-)
    My class QEPanel, which handles each row of the statistics, is like that.yeah, have seen it: pretty nasty mixing of view and data <g>
    Hmm, I wouldn't actually have to throw most of it away. :) correct ...
    The JLabel <b>label</b>s would become the table column labels, and the other JLabels would become integers specifying column. except that I don't completely understand what you are after here (ehem: get your vocabulary right, sir) a clean separation would map the data-part of a QEPanel into a QEBean, with properties title (was: label), percentRed ... etc. Something like:
    public class QEBean extends AbstractBean {
        private float sumRed, sumGrn, sumBlu;
        private float minDist = 9999999;
        private float maxDist = 0;
        private double sumDist;
        private int count;
        private int entries;
        private CountPerEntries countPerEntries;
        private String title;
        public QEBean(String title) {
            this.title = title;
        public void reset() {
            // do reset
            firePropertyChange(null, null, null);
        public void updateData(Color quantized, Color actual) {
            // do update internals
            firePropertyChange(null, null, null);
    //------------ getters...
        public String getTitle() {
            return title;
        public float getPercentRed() {
            if (count == 0)
                return 0f;
            return sumRed / count;
        // more getters
    }Then implement a specialized TableModel which knows about QEBean
    public class QEBeanTableModel extends AbstractTableModel {
        List<QEBean> errors = new ArrayList<QEBean>();
        private PropertyChangeListener errorChangeListener;
        @Override
        public int getColumnCount() {
            return 7;
        @Override
        public int getRowCount() {
            return errors.size();
        @Override
        public Class<?> getColumnClass(int columnIndex) {
            switch (columnIndex) {
                   // implement as appropriate
            return Object.class;
        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            QEBean error = errors.get(rowIndex);
            switch (columnIndex) {
            case 0:
                return error.getTitle();
            case 1:
                return error.getPercentRed();
              // more as appropriate
            return null;
        public void addError(QEBean error) {
            int oldSize = getRowCount();
            error.addPropertyChangeListener(getPropertyChangeListener());
            errors.add(error);
            fireTableRowsInserted(oldSize, oldSize);
        public QEBean getError(int row) {
            return errors.get(row);
        private PropertyChangeListener getPropertyChangeListener() {
            if (errorChangeListener == null) {
                errorChangeListener = new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        int row = errors.indexOf(evt.getSource());
                        fireTableRowsUpdated(row, row);
            return errorChangeListener;
        public void resetAll() {
            for (QEBean error : errors) {
                error.reset();
    }Then use the model in HelpBox:
    // init model and keep in field
         qErrors = new QEBeanTableModel();
         qErrors.addError(new QEBean("Hex QE"));
         qErrors.addError(new QEBean("Name QE"));
         qErrors.addError(new QEBean("Mismatch QE"));
         qErrors.addError(new QEBean("SearchAccuracy"));
            // can't resist - JXTable would make customization so much easier :-)
         // JXTable errorTable = new JXTable(qErrors);
         JTable errorTable = new JTable(qErrors);
         errorTable.setBackground(Color.BLACK);
         errorTable.setSelectionBackground(Color.BLACK);
         errorTable.setForeground(Color.WHITE);
         errorTable.setSelectionForeground(Color.WHITE);
         errorTable.setGridColor(Color.BLACK);
            // install renderers which produce an output similar to the labels
           panel.add(errorTable)
    // in the update methods - update the QEBeans stored in the model
        public void updateQE(int which, String q, String a)
         Color     quantized = Color.black;
         Color     actual = Color.black;
         int     rgb[] = { 0, 0, 0 };
         NTC.getRGB(q, rgb);
         quantized = new Color(rgb[0], rgb[1], rgb[2]);
         NTC.getRGB(a, rgb);
         actual = new Color(rgb[0], rgb[1], rgb[2]);
         qErrors.getError(which -1).updateData(quantized, actual);
    // similar in reset, updateEntriesThat's all and will give you an output very similar to the rows of individual labels, only more symetric.
    The toString() method would go away because row toString() is already built into JTable.ehhh? No, not that I know of :-) The default renderer uses the toString of the cell value, the row is not involved.
    >
    Then you can implement the button's action to copy that error table's content to the clipboard. Better usability ensured, IMO.I'll just throw away the darn button. The colorTable doesn't have one, so why should the statisticsTable? sure, that's an option - the visual setup outlined above is for hiding the table-nature, if you want it expose, just do - no problem.
    Cheers
    Jeanette

  • Safari copy wipes the clipboard

    Anyone else have this in Safari 4 for Windows?
    I use Safari at work, often copying and pasting text; in Safari 4 I have noticed an issue that when I have text in the clipboard and use the keyboard shortcut to paste the text into a text box on a web page.
    Here's what happens, I first have some text I copied into the clipboard, when I accidentally hit Ctrl-C instead of Ctrl-V the clipboard gets wiped out as Safari copies a null amount of text into the clipboard, thus if I realize my mistake and try to do a Ctrl-V my previously copied text has disappeared from the clipboard and nothing pastes.
    Yeah I know I should learn to type better, ha ha, but we all occasionally make mistakes and it's infuriating when this happens. I am sure this was not the behaviour Safari 3 and also this issue does not occur in FireFox and I think most other browsers out there.
    I clean installed Safari on a new install of Windows on a virtual machine and was able to recreate the issue.
    Any thoughts?
    Phil
    Message was edited by: sixfootphil

    I found byselft the solution. Here the step for those who have to do the same:
    Copy Premise to the clipboard (BDD)
      l_procobj-header = 'OBJH'.
      l_procobj-type   = 'SWO'.
    Create object Premises
      CALL FUNCTION 'SWO_CREATE'
           EXPORTING
                objtype = 'PREMISES'
                objkey  = l_key
           IMPORTING
                object  = l_procobj-handle
                return  = l_return.
      IF NOT l_return IS INITIAL.
        EXIT.
      ENDIF.
    Set Object ID
      CALL FUNCTION 'SWO_OBJECT_ID_SET'
           EXPORTING
                object    = l_procobj-handle
                objectkey = l_key
           IMPORTING
                return    = l_return
           EXCEPTIONS
                OTHERS    = 1.
      IF NOT l_return IS INITIAL.
        EXIT.
      ENDIF.
    Buffer Refresh
      CALL FUNCTION 'SWO_OBJECT_REFRESH'
           EXPORTING
                object       = l_procobj
           EXCEPTIONS
                error_create = 02.
      l_def-element      = '<MAINOBJ>'.
      l_def-editorder    = 2000 - 1.
      l_def-reftype      = 'O'.
      l_def-refobjtype   = 'PREMISES'.
    APPEND l_def TO li_def.
      CALL FUNCTION 'EWO_XTAINER_ELEMENT_SET'
           EXPORTING
                x_elemdef       = l_def
                x_value         = l_procobj
           CHANGING
                xy_xtainer      = l_desk_xtain
           EXCEPTIONS
                invalid_elemdef = 1
                internal_error  = 2
                OTHERS          = 3.
      CALL FUNCTION 'CIC_EVENT_RAISE'
           EXPORTING
                event  = 'ADD_XTAINER_TO_BDD'
                p1     = l_desk_xtain
           EXCEPTIONS
                OTHERS = 99.

  • How to create, place, format and paste the clipboard contents into a text frame

    I am new to scripting and need help. I have an existing Indesign document. I need to be able to create a text frame on my current page, the width of my margins with the top of the text frame at the top margin and 1" in height, then format it to be 1-column, and then paste the clipboard contents into it and tag the text with a particular paragraph style. I am using Indesign CS4 on a mac, if that makes any difference. Thanks for any help.

    May this will help you. It will create an anchored object with a text what you desired, with object style. You should create an object style before with the x and y co ordinates. You can choose either para style or character style.
    var the_document = app.documents.item(0);
    // Create a list of paragraph styles
    var list_of_paragraph_styles = the_document.paragraphStyles.everyItem().name;
    // Create a list of character styles
    var list_of_character_styles = the_document.characterStyles.everyItem().name;
    // Create a list of object styles
    var list_of_object_styles = the_document.objectStyles.everyItem().name;
    // Make dialog box for selecting the styles
    var the_dialog = app.dialogs.add({name:"Create anchored text frames"});
    with(the_dialog.dialogColumns.add()){
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Make the anchored frames from ..."});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"This character style:"});
    var find_cstyle = dropdowns.add({stringList:list_of_character_styles, selectedIndex:0});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Or this paragraph style:"});
    var find_pstyle = dropdowns.add({stringList:list_of_paragraph_styles, selectedIndex:0});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Leave one dropdown unchanged!"});
    dialogRows.add();
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Delete matches?"});
    var delete_refs = dropdowns.add({stringList:["Yes","No"], selectedIndex:0});
    dialogRows.add();
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Anchored text frame settings:"});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Object style:"});
    var anchor_style = dropdowns.add({stringList:list_of_object_styles, selectedIndex:0});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Frame width:"});
    var anchor_width = measurementEditboxes.add({editUnits:MeasurementUnits.MILLIMETERS, editValue:72});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Frame height:"});
    var anchor_height = measurementEditboxes.add({editUnits:MeasurementUnits.MILLIMETERS, editValue:72});
    the_dialog.show();
    // Define the selected styles
    var real_find_cstyle = the_document.characterStyles.item(find_cstyle.selectedIndex);
    var real_find_pstyle = the_document.paragraphStyles.item(find_pstyle.selectedIndex);
    var real_anchor_style = the_document.objectStyles.item(anchor_style.selectedIndex);
    // Check if a style is selected
    if(find_cstyle.selectedIndex != 0 || find_pstyle.selectedIndex != 0) {
    // Define whether to search for character styles or paragraph styles
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    if(find_cstyle.selectedIndex != 0) {
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.appliedCharacterStyle = real_find_cstyle;
    } else {
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.appliedParagraphStyle = real_find_pstyle;
    app.findGrepPreferences.findWhat = "^";
    // Search the document
    var found_items = the_document.findGrep();
    myCounter = found_items.length-1;
    do {
    // Select and copy the found text
    var current_item = found_items[myCounter];
    if(find_pstyle.selectedIndex != 0) {
    var found_text = current_item.paragraphs.firstItem();
    var insertion_character = (found_text.characters.lastItem().index) + 1;
    var check_insertion_character = insertion_character + 1;
    var alt_insertion_character = (found_text.characters.firstItem().index) - 1;
    var the_story = found_text.parentStory;
    app.selection = found_text;
    if(delete_refs.selectedIndex == 0) {
    app.cut();
    } else {
    app.copy();
    } else {
    var found_text = current_item;
    var insertion_character = (found_text.characters.lastItem().index) + 2;
    var check_insertion_character = insertion_character;
    var alt_insertion_character = (found_text.characters.firstItem().index) - 1;
    var the_story = found_text.parentStory;
    app.selection = found_text;
    if(delete_refs.selectedIndex == 0) {
    app.cut();
    } else {
    app.copy();
    // Make text frame from selection
    try {
    app.selection = the_story.insertionPoints[check_insertion_character];
    app.selection = the_story.insertionPoints[insertion_character];
    } catch(err) {
    app.selection = the_story.insertionPoints[alt_insertion_character];
    var the_anchored_frame = app.selection[0].textFrames.add({geometricBounds:["0","0",anchor_height.editContents,anch or_width.editContents],anchoredObjectSettings:{anchoredPosition: AnchorPosition.ANCHORED}});
    app.selection = the_anchored_frame.insertionPoints[0];
    app.paste();
    // Apply the object style now to "force apply" paragraph style set in the object style
    if(anchor_style.selectedIndex != 0) {
    the_anchored_frame.appliedObjectStyle = real_anchor_style;
    myCounter--;
    } while (myCounter >= 0);
    } else {
    alert("No styles selected!");

  • Can one copy a text layer's content to the clipboard?

    I have searched for this but have been unsuccessful in doing so...I want to be able to either;
       a: copy the contents of a text layer to the clipboard so that when saving a file I can simply paste and save or...
       b: save a file by the contents in a text layer.
    My sole purpose is to make it so I don't have to type the name of a document that is created through data sets. What I have seen so far is that through scripting one cannot copy these things to the clipboard. Any help would be appreciated.  Thank you and I hope that I have been thorough enough.

    You should be able to set up the data set so that the contents of the layer is the data set name. Then you can use File-Export-Data Sets as Files and have it save the files with the data set name.

  • After recording text using the dragon dictation app, it is converted, it can be copied to the iOS system clipboard for use in any app, how does the user access the clipboard to retrive this information if it is no longer on the screen?

    after recording text using the Dragon dictation app, it can be copied to the iOS systme clipboard for use in any app, how does the user access the clipboard to retrive this information if it is no longer on the screen?

    You need to do a long-press in any data entry field, then select Paste.

  • Paste is only pasting a text field instead of an image copied to the clipboard from another program like mail or safari?

    The latest version of Keynote only pastes a blank text field after copying an image to the clipboard in other applications like mail or Safari.  The previous version worked fine with copying and pasting images.  Saving the image to a file and then inserting the image file is the only work-a-round I have found so far.

    To place an image on a slide, use Finder to drag and drop the file onto the slide.

  • \n is not working by the time writing text into file ...

    Hi,
    I am reading each line from file and writing into another file ...
    It is writing continously in the file even if i use \n for new line ...
    Why "\n" is not working by the time writing text into file ...
    Here is my code:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Test11{
    private BufferedReader data;
    private String line=null;
    private StringBuffer buf= new StringBuffer();
    private BufferedWriter thewriter=null;
    private File file=null;
    private FileReader fr=null;
    private String inputLocation="c:\\test14.txt";
    public Test11(){ }
    public void disp(){
    try {   
    file=new File(inputLocation);
    fr = new FileReader(file);
    data = new BufferedReader(fr);
    while ((line = data.readLine()) != null) {
    buf.append(line + "\n");
    String text=buf.toString();
    thewriter = new BufferedWriter(new FileWriter("c:\\test15.txt"));
    thewriter.write(text);
    buf=null;
    thewriter.close();
    } catch(IOException e) { System.out.println("error ==="+e ); }
    public static void main(String[] args) {
    Test11 t=new Test11();
    t.disp();
    System.out.println("all files are converted...");
    I used "\n" after reading each line .. i want output file also same as input file ... how do i break each line by the time writing into text file .. "\n" is working in word pad but now working in notepad ... in note pad i am getting some thing like rectangle insted of "\n" ....
    Any help please .....
    thanks.

    \n works just fine, and every text editor in the world except Notepad understands that it is supposed to be a line-ending character. You don't have a problem, except in your choice of text editor. If somebody is forcing you to use Notepad then you'll have to output "\r\n" instead.

Maybe you are looking for