Go Back   Java Programming Forums > Java Standard Edition Programming Help > AWT / Java Swing


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-02-2010, 06:36 AM
Junior Member
 

Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ramanavarayuri1986 is on a distinguished road
Thumbs up How to copy image from one jpanel to another jpanel

Hai! I am new to java. In my swings application a problem was arised. that is when i drag an image from one jpanel to another jpanel. the copy of the image will come with the mouse. the original image may not move. only copy of the image will move from one jpanel to another. here is the sample code. how to move the copy of the image from one jpanel to another jpanel.
Please help me.

Java Code
import javax.swing.*; 
import java.awt.*; 
public class test1 { 
 public test1() {
  JFrame frame=new JFrame("Drag");
  Container container=frame.getContentPane();
  JPanel panel=new JPanel(new GridLayout(2,1));
  JPanel panel1=new JPanel(new BorderLayout());
  JPanel panel2=new JPanel();
  JLabel label=new JLabel(new ImageIcon("icons/save.png"));
  panel1.add(label);
  panel1.setBackground(Color.red);
  panel2.setBackground(Color.gray);
  panel.add(panel1);
  panel.add(panel2);
  container.add(panel);
  frame.setSize(300,400);
  frame.setVisible(true);
 }
 /**
 * @param args
 */
 public static void main(String[] args) {
  new test1();
 }
}




Last edited by helloworld922; 15-02-2010 at 03:59 PM.
Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with ActionListener,JPanel,JFrame amahara AWT / Java Swing 5 03-02-2010 05:40 PM
Drawing image on JPanel from another frame jeryslo AWT / Java Swing 3 08-12-2009 08:01 PM
How to write above a JPanel bruno88 AWT / Java Swing 4 23-06-2009 11:16 PM
Creating, and displaying a JPanel inside another JPanel JayDuck AWT / Java Swing 1 07-04-2009 01:02 PM
2 D Array and JComboBox on a JPanel crazydeo AWT / Java Swing 4 27-05-2008 06:20 PM


100 most searched terms
Search Cloud
2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

All times are GMT. The time now is 02:03 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.