这个程序就是一个能实现鼠标拖放的白版,我想问几个问题,一个是我想有一个button ,click后如何创建一个新的tag,我定义了一大堆TabbedPanel panel并且在lib目录下放了一大堆的TabbedPanel用来import这样做很是烦琐显的太笨拙,如何动态实现呢?  还有一个就是  backward和forward按纽click的时候能显示出前一个tag或者后一个tag上的图片,如何实现?  clear的时候我原来的图片怎么还是在tag上呢      谢谢啦!  很急迫!
//This project is to drag and drop images on tabbedpane, click 
//reload button to load activing tabbedpanel image to whiteboard
//and make painting.
//MyInterface.java
//Mainclass combines toolbar, tabbedpane, whiteboard together 
 
package MyInterface;import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import MyInterface.lib.WhiteboardPanel;
import MyInterface.lib.TabbedPanel1;
import MyInterface.lib.TabbedPanel2;
import MyInterface.lib.TabbedPanel3;
import MyInterface.lib.TabbedPanel4;
import MyInterface.lib.TabbedPanel5;
import MyInterface.lib.TabbedPanel6;
import MyInterface.lib.TabbedPanel7;
import MyInterface.lib.TabbedPanel8;
import MyInterface.lib.TabbedPanel9;
import MyInterface.lib.TabbedPanel10;
import MyInterface.lib.TabbedPanel11;
import MyInterface.lib.TabbedPanel12;
public class MyInterface extends JFrame implements ActionListener {
    
   private JTabbedPane tabbedPane;
   private WhiteboardPanel whiteboard;
   private TabbedPanel1 panel1;
   private TabbedPanel2 panel2;
   private TabbedPanel3 panel3;
   private TabbedPanel4 panel4;
   private TabbedPanel5 panel5;
   private TabbedPanel6 panel6;
   private TabbedPanel7 panel7;
   private TabbedPanel8 panel8;
   private TabbedPanel9 panel9;
   private TabbedPanel10 panel10;
   private TabbedPanel11 panel11;
   private TabbedPanel12 panel12;
   
   private JButton jback, jforward, jload, jclear,jnew;
   public ImageIcon cimage;
  
   // TabbedPaneWebBrowser constructor
   public MyInterface() 
   {     
        super( "Whiteboard and Image Interface" );
        //Set the default window close operation
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Create the panel for the tab
        tabbedPane = new JTabbedPane();
        panel1 = new TabbedPanel1();
        panel2 = new TabbedPanel2();
        panel3 = new TabbedPanel3();
        panel4 = new TabbedPanel4();
        panel5 = new TabbedPanel5();
        //Create the tabs
        tabbedPane.setSize(300, 500);
        tabbedPane.add("Tab 1", panel1);
        tabbedPane.add("Tab 2", panel2);
        tabbedPane.add("Tab 3", panel3);
        tabbedPane.add("Tab 4", panel4);
        tabbedPane.add("Tab 5", panel5);     
        //Create toolbar  
         JPanel pToolBar = new JPanel();
         pToolBar.setLayout(new GridLayout(1, 5));
         pToolBar.add(jback = new JButton("Backward"));
         jback.setBackground(Color.BLUE);
         pToolBar.add(jforward = new JButton("forward"));
         jforward.setBackground(Color.BLUE);
         pToolBar.add(jload = new JButton("reload"));
         jload.setBackground(Color.BLUE);
         pToolBar.add(jclear = new JButton("clear"));
         jclear.setBackground(Color.BLUE);
         pToolBar.add(jnew = new JButton("New Tag"));
         jnew.setBackground(Color.BLUE);
         //Create instance of whiteboard
         whiteboard  = new WhiteboardPanel();
         whiteboard.setLayout(new BorderLayout());
         //Set contentPane
         this.getContentPane().setLayout(new GridLayout(1, 2));
         this.getContentPane().add(whiteboard);  
         this.getContentPane().add(tabbedPane);  
         whiteboard.add(pToolBar, BorderLayout.NORTH);       
         // Button actions
         jload.addActionListener(this);
         jclear.addActionListener(this);
   }  
   public void actionPerformed(ActionEvent e) {
       if (e.getSource() == jload) {
           cimage = panel1.display1();
           whiteboard.displayImage(cimage);
       }
       if (e.getSource() == jclear) {
              cimage = new ImageIcon( getClass().getResource(
       "images/javaIcon.gif" ) );
           whiteboard.clearwhiteboard(cimage);
       }
       // if (e.getSource() == jnew) {
           // int n=6; 
           // (panel&n)= (new (TabbedPanel&n))();
           // tabbedPane.add("Tab" + n , panel + n);
           // n++;
      // }
   }
 
   // execute application
   public static void main( String args[] )
   {
      MyInterface browser = new MyInterface();
      browser.setDefaultCloseOperation( EXIT_ON_CLOSE );
      browser.setSize( 800, 600 );
      browser.setVisible( true );     
   }      
}lib 下的  一个TabbedPanel代码
package MyInterface.lib;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class TabbedPanel1 extends JPanel {
    
    protected ImageIcon imagep1;
    // set up GUI and register mouse event handler
    public TabbedPanel1() {
       // super( "A simple whiteboard program" );
        setBackground( Color.WHITE );
        imagep1 = new ImageIcon( getClass().getResource(
        "images/ewanPumpkin.gif") );   
  
    } // end Painter constructor
    
    // draw oval in a 4-by-4 bounding box at specified location on window
    public void paint( Graphics g ) {
        imagep1.paintIcon( this, g, 0, 0 );
    }
     public ImageIcon display1() {  
         return imagep1;
     }
  
    
} // end class Painter