Solved

implementing cut and paste

Posted on 2004-09-30
4
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

688 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