嘿嘿,老兄,你问错地方了。
应该去J2SE版

解决方案 »

  1.   


    //Frame1.java
    public class Frame1 extends JFrame {
    ....
     JButton jButton1 = new JButton();
     JPanel jPanel2 = new JPanel();
    .....
    public Frame1() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      //Component initialization
      private void jbInit() throws Exception  {
        contentPane = (JPanel) this.getContentPane();
      ....
      jPanel2.add(jButton1, null);
      }
    //Overridden so we can exit when window is closed
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
        }
      }  void jButton1_mouseClicked(MouseEvent e) {
        JFrame dFrame = new DrawFrame();
        dFrame.setSize(new Dimension(600, 400));
        dFrame.setTitle("绘图框");
        dFrame.setLocation(100,100);
        dFrame.show();  }
    }
    class Frame1_jButton1_mouseAdapter extends java.awt.event.MouseAdapter {
      Frame1 adaptee;  Frame1_jButton1_mouseAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
      }
      public void mouseClicked(MouseEvent e) {
        adaptee.jButton1_mouseClicked(e);
      }
    }
    //DrawFrame.java  绘图框
    public class DrawFrame extends JFrame {
      BorderLayout borderLayout1 = new BorderLayout();
      DrawPanel dp = new DrawPanel();
      public DrawFrame() throws HeadlessException {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }  public static void main(String[] args) throws HeadlessException {
        DrawFrame drawFrame1 = new DrawFrame();  }
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(borderLayout1);
        //this.getContentPane().repaint();    this.getContentPane().add(dp);
      }  public class DrawPanel extends JPanel {
          public void paintComponent(Graphics g) {
          super.paintComponents(g);
          Graphics2D g2 = (Graphics2D)g;      g2.setPaint(Color.black);
          g2.draw(new Line2D.Double(40, 40, 40, 200));
          g2.setPaint(Color.red);
          g2.draw(new Line2D.Double(40,200,200,200));
        }
     }
    }