更新超级类而不扩展它?

时间:2016-08-04 18:42:46

标签: java swing netbeans extends

我想知道是否有人对我有一些建议。我有使用CardLayout调用不同类(JPanels)的接口(JFrame)。问题是netbeans自动声明[public class Interface_Login extends javax.swing.JPanel]。当我用接口和导入javax.swing.JPanel替换extends时,生成的代码在这些行上给出了2个错误:

   bcp "select d.DOCID,DOC_TYPE,PO,d.STATUS, CASE WHEN LEFT(Path,3)= 'M:\' THEN '\\ServerName'+RIGHT(DWPath,LEN(Path)-3) ELSE Path END AS ImagePath, STATUS_DATE,'No' AS dwimport from openquery([LinkedServer],'select * from data.vw_purchasing_docs_unc') as u INNER JOIN openquery([LinkedServer],'select * from dwdata.purchasing_docs') as d ON u.docid=d.docid WHERE (CONVERT(varchar(10),STATUS_DATE,120)=CONVERT(varchar(10),GETDATE(),120)) AND d.STATUS IN ('FILED - Processing Complete','FILED - Partial Payment','FILED - Confirming') AND DOC_TYPE IN ('CO = Change Order','Purchase Order','CP = Capital Projects','Change Order','PO = Purchase Order','PO','PR = General Operating')" queryout "E:\Data\PO Trigger CSV\PO_Trigger_Doc.csv" -r \n -T -c -t"," -Umv -Smtvwrtst -Pm -q -k

无论如何都要在Netbeans中更改生成的代码,甚至更新调用JPanel方法的超类? Interface类有2个setter方法来更新变量。

编辑1: 对不起大家。代码提供。

接口[JFrame的]

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);

Interface_Login

package Interface;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Interface {

    String selectedDatabase;
    String db_location;
    static JPanel contentPane;

    private static void createAndShowGUI()
    {
        JFrame frame = new JFrame("Card Layout Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setResizable(false);
        // This JPanel is the base for CardLayout for other JPanels.
        contentPane = new JPanel();
        contentPane.setLayout(new CardLayout(0,0));
        Interface_Login login = new Interface_Login();
        contentPane.add(login,"Login Window");

        frame.add(contentPane, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);

    }
    public static void main(String... args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                createAndShowGUI();
            }
        });
    }

    public void setSelectedDatabase(String selectedDatabase) {
        this.selectedDatabase = selectedDatabase;
    }

    public void setDb_location(String db_location) {
        this.db_location = db_location;
    }
}

问题: Login_Interface需要向Interface发送2个变量(db_location,selectedDatabase)。我该怎么做呢?

0 个答案:

没有答案