将参数传递给jinternalframe形式java中的构造函数

时间:2017-03-27 04:12:07

标签: java swing netbeans jframe jinternalframe

// This is the code in my Home_Page to perform when the jbutton is clicked. 

 private void homeActionPerformed(java.awt.event.ActionEvent evt) 
 {       
    jDesktopPane1.removeAll();
    error_ e = new error_();
    jDesktopPane1.add(e);
    e.setVisible(true);
    jDesktopPane1.updateUI();
            // TODO add your handling code here:
 }

 //This is the parameter  need to pass through  constructor of jinternalframe form "error_"
 public String eid1;


 Model.JDBC j=new JDBC();
 public error_(String eid) 
 {
    initComponents();
    jLabel3.setText(eid); 
    ResultSet rs;
    try 
    {                     
        rs = j.getData("select mid from employee where eid='"+eid+"'");  

        if(rs.next()==true)
        {
           if(rs.next()==true)
           {
              if(rs.getString(1).equals"sp/cso/it/1")
              {

                    if(eid.equals("sp/cso/it/1"))
                    {}
                    else if(eid.equals("sp/cso/finance/1"))
                    {
                        System.out.println("else if");
                    }
                    else
                    {
                        System.out.println("else");
                    }
              }
           }
        }
        else
        {
            System.out.println("outer else executed");
        }
        } 
        catch (Exception ex) 
        {
            Logger.getLogger(Home_Page.class.getName()).log(Level.SEVERE, null, ex);
        }
}

//This is the code in Home_Page to load the jinternalframe form error_ on to the jDesktopPane in Home_Page

private void homeActionPerformed(java.awt.event.ActionEvent evt) {                                     

      jDesktopPane1.removeAll();
      error_ e = new error_();
      jDesktopPane1.add(e);
      e.setVisible(true);
      jDesktopPane1.updateUI();
        // TODO add your handling code here:
    } 

Home_Page是主要的jFrame表单,它上面有一个jDesktopPane。当我点击Home_Page上的jButton Home时,我需要将jinternaframe表单错误加载到该jDesktoPane。

但是当我尝试在jinternalframe中传递参数时,在Home_Page中出现错误,说错误构造函数_

我做到了。在那个构造函数中有一个抛出部分,抛出一个异常,如下所示。

debug:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - constructor error_ in class Viewer.error_ cannot be applied to given types;
  required: java.lang.String
  found: no arguments
  reason: actual and formal argument lists differ in length
    at Viewer.Home_Page.homeActionPerformed(Home_Page.java:418)
    at Viewer.Home_Page.access$100(Home_Page.java:33)
    at Viewer.Home_Page$2.actionPerformed(Home_Page.java:166)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6533)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

0 个答案:

没有答案