Solved

implementing cut and paste

Posted on 2004-09-30
4
214 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse apache tomcat admin console 52 150
Eclipse for Java EE development 2 43
spring maven example issues 3 40
junit example issue 2 25
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

756 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