Solved

implementing cut and paste

Posted on 2004-09-30
4
212 Views
Last Modified: 2010-03-31
how can i implement cut and paste to the system clipboard in a simple painter program?
0
Comment
Question by:Orlando15767
  • 2
4 Comments
 
LVL 6

Expert Comment

by:expertmb
ID: 12196872
0
 
LVL 1

Author Comment

by:Orlando15767
ID: 12197086
I tried putting the methods into the cut method created from implementing cutable and I was recieving errors at line marked **

      public void cut(ActionEvent evt) {
**          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);
                      return text;
                  }
              } catch (UnsupportedFlavorException e) {
              } catch (IOException e) {
              }
              return null;
          }
}

      Syntax error, insert ";" to complete BlockStatements                  
                Syntax error on token(s), misplaced construct(s)      

0
 
LVL 18

Expert Comment

by:armoghan
ID: 12197442
Is the above mentioned  code being used in program..
As it seems to have a method in a method

As you are missing some } somewhere
The below mentioend method is OK

       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);
                        return text;
                    }
                } catch (UnsupportedFlavorException e) {
                } catch (IOException e) {
                }
                return null;
            }
   }
0
 
LVL 6

Accepted Solution

by:
expertmb earned 125 total points
ID: 12197543
try this
   public void cut(ActionEvent evt) {
 getClipboard() ;
}

         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);
                     return text;
                 }
             } catch (UnsupportedFlavorException e) {
             } catch (IOException e) {
             }
             return null;
         }
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question