无法从另一个类访问主类

时间:2010-11-05 14:00:20

标签: java netbeans

我正在使用NetBeans,我正在尝试编写一个具有用户界面的程序 我的主要课程是JFrame表单,其文件名为HotelHG.java 我可以毫无问题地编写这个文件中的所有代码,但代码太复杂了,我永远无法找到我在里面寻找的代码。
所以我创建了一个名为DataBaseConnection的新Java类来放入一些代码。

问题出现了:当我做的时候

public class DataBaseConnection extends HotelHG{
    //Some Codes...
}

我明白了:

  

线程“AWT-EventQueue-0”java.lang.StackOverflowError中的异常           at sun.awt.Win32GraphicsConfig.getBounds(Native Method)           在sun.awt.Win32GraphicsConfig.getBounds(Win32GraphicsConfig.java:215)

因此,我尝试公开我的HotelHG类组件并尝试直接访问它们 没有extends,但DataBaseConnection无法找到HotelHG个组件。

简而言之,我在A.java中有一个JFrame形式的课程,其中包含main(),我必须从B.java中的其他课程访问其组件

更新

我检查了我的代码,但是没找到任何东西。所以我在主要课程中添加了我的代码,看看问题是否会得到解决。 但是这次它给C级带来了同样的错误......我想我会更新发现这里发生了什么。 我会添加代码,所以如果您可以查看并找到任何内容,请再次告诉我们。

主要类别代码:

import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import javax.swing.JOptionPane;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;



public class HotelHG extends javax.swing.JFrame{

    private Connection Con = null;
    private String Url     = "jdbc:mysql://localhost:3306/";
    private String Db      = "hotel_hg";
    private String Dri     = "com.mysql.jdbc.Driver";
    private String Root    = "root";
    private String Pass    = "";
    protected ResultSet Res;

    Tab1Codes MyCodes1 = new Tab1Codes();

    /** Creates new form HotelHG */
//============================================================================== I N S T A L L A T I O N ===========
    public HotelHG() {
        Statement st;
        try{
            st = OpenConnection();
            Res = st.executeQuery("select * from idpass");
        }catch(Exception ex){
            JOptionPane.showConfirmDialog(null,"Няма Достъп до Информатции!",
                    "Опит за Свързване на бази данни...",
                    JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
        }
        initComponents();
    }
//============================================================================== I N S T A L L A T I O N ===========


//=================================================================================================== OPEN CONNNECTION
    private Statement OpenConnection() throws Exception{
        try{
            Class.forName(Dri).newInstance();
        }catch(Exception ex){
            JOptionPane.showConfirmDialog(null,"Връзка с Дата Бейс Не е Успешна-Driver!",
                    "Опит за Свързване на бази данни...",
                    JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
        }
        try{
            Con = DriverManager.getConnection(Url + Db, Root, Pass);
        }catch(Exception ex){
            JOptionPane.showConfirmDialog(null,"Връзка с Дата Бейс Не е Успешна-Url!",
                    "Опит за Свързване на бази данни...",
                    JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
        }
        return Con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_UPDATABLE);
    }
//=================================================================================================== OPEN CONNNECTION

//=================================================================================================== CLOSE CONNECTION
    public void CloseConnection(){
        try
        {
            Con.close();
        }catch(Exception ex)
        {
            Logger.getLogger(HotelHG.class.getName()).log(Level.SEVERE,null,ex);
        }
    }
//=================================================================================================== CLOSE CONNECTION

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        TabMenu = new javax.swing.JTabbedPane();
        Tab1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        IDBox1 = new javax.swing.JTextField();
        PassBox = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        EnterButton1 = new javax.swing.JButton();
        StatusLabel1 = new javax.swing.JLabel();
        ExitButton1 = new javax.swing.JButton();
        Tab2 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        Tab3 = new javax.swing.JPanel();
        Tab4 = new javax.swing.JPanel();
        Tab5 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Хотел Heaven Garden");
        setMinimumSize(null);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        TabMenu.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        TabMenu.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        TabMenu.setFont(new java.awt.Font("Consolas", 1, 14)); // NOI18N

        Tab1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(204, 0, 0), new java.awt.Color(204, 0, 0), null));

        jLabel1.setFont(new java.awt.Font("Consolas", 2, 24));
        jLabel1.setText("Heaven Garden Главно меню:"); // NOI18N
        jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jLabel2.setFont(new java.awt.Font("Consolas", 2, 24));
        jLabel2.setText("-Напишете паролата си за да активирате контролите на меню..."); // NOI18N
        jLabel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jLabel3.setFont(new java.awt.Font("Consolas", 2, 24));
        jLabel3.setText("-Само администратора може да активира всичките менюта!"); // NOI18N
        jLabel3.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jLabel4.setFont(new java.awt.Font("Consolas", 2, 24));
        jLabel4.setText("-При три грешени опити програмата ще се заключва!"); // NOI18N
        jLabel4.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        IDBox1.setFont(new java.awt.Font("Consolas", 2, 18));

        PassBox.setFont(new java.awt.Font("Consolas", 2, 18));

        jLabel5.setFont(new java.awt.Font("Consolas", 0, 18));
        jLabel5.setText("Потребителско Име:");

        jLabel6.setFont(new java.awt.Font("Consolas", 0, 18));
        jLabel6.setText("Парола:");

        EnterButton1.setFont(new java.awt.Font("Consolas", 1, 18));
        EnterButton1.setText("Влизай");
        EnterButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EnterButton1ActionPerformed(evt);
            }
        });

        StatusLabel1.setFont(new java.awt.Font("Consolas", 0, 24));
        StatusLabel1.setText("Статус:Няма Достъп");

        ExitButton1.setFont(new java.awt.Font("Consolas", 1, 18));
        ExitButton1.setText("Изход");
        ExitButton1.setActionCommand("jButton1");

        javax.swing.GroupLayout Tab1Layout = new javax.swing.GroupLayout(Tab1);
        Tab1.setLayout(Tab1Layout);
        Tab1Layout.setHorizontalGroup(
            Tab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Tab1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(Tab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jSeparator1)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Tab1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(Tab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel6)
                            .addComponent(IDBox1)
                            .addComponent(PassBox)
                            .addComponent(EnterButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(StatusLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(ExitButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        Tab1Layout.setVerticalGroup(
            Tab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Tab1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(IDBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PassBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(EnterButton1)
                .addGap(18, 18, 18)
                .addComponent(StatusLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ExitButton1)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        TabMenu.addTab("Главно меню", new javax.swing.ImageIcon(getClass().getResource("/Pics/Admin.png")), Tab1); // NOI18N
        Tab1.getAccessibleContext().setAccessibleName("Tab1");

        Tab2.setBorder(javax.swing.BorderFactory.createCompoundBorder(null, new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
        Tab2.setEnabled(false);

        jTextField1.setText("jTextField1");

        jButton1.setText("jButton1");

        javax.swing.GroupLayout Tab2Layout = new javax.swing.GroupLayout(Tab2);
        Tab2.setLayout(Tab2Layout);
        Tab2Layout.setHorizontalGroup(
            Tab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Tab2Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(633, Short.MAX_VALUE))
        );
        Tab2Layout.setVerticalGroup(
            Tab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Tab2Layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addGroup(Tab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap(360, Short.MAX_VALUE))
        );

        TabMenu.addTab("Рецепция", new javax.swing.ImageIcon(getClass().getResource("/Pics/Reception.png")), Tab2); // NOI18N
        Tab2.getAccessibleContext().setAccessibleName("Tab2");

        Tab3.setBorder(javax.swing.BorderFactory.createCompoundBorder(null, new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
        Tab3.setEnabled(false);

        javax.swing.GroupLayout Tab3Layout = new javax.swing.GroupLayout(Tab3);
        Tab3.setLayout(Tab3Layout);
        Tab3Layout.setHorizontalGroup(
            Tab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 803, Short.MAX_VALUE)
        );
        Tab3Layout.setVerticalGroup(
            Tab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 431, Short.MAX_VALUE)
        );

        TabMenu.addTab("Резервация", new javax.swing.ImageIcon(getClass().getResource("/Pics/Reservation.png")), Tab3); // NOI18N
        Tab3.getAccessibleContext().setAccessibleName("Tab3");

        Tab4.setBorder(javax.swing.BorderFactory.createCompoundBorder(null, new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
        Tab4.setEnabled(false);

        javax.swing.GroupLayout Tab4Layout = new javax.swing.GroupLayout(Tab4);
        Tab4.setLayout(Tab4Layout);
        Tab4Layout.setHorizontalGroup(
            Tab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 803, Short.MAX_VALUE)
        );
        Tab4Layout.setVerticalGroup(
            Tab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 431, Short.MAX_VALUE)
        );

        TabMenu.addTab("Ресторант", new javax.swing.ImageIcon(getClass().getResource("/Pics/desk.png")), Tab4); // NOI18N
        Tab4.getAccessibleContext().setAccessibleName("Tab4");

        Tab5.setBorder(javax.swing.BorderFactory.createCompoundBorder(null, javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
        Tab5.setEnabled(false);

        javax.swing.GroupLayout Tab5Layout = new javax.swing.GroupLayout(Tab5);
        Tab5.setLayout(Tab5Layout);
        Tab5Layout.setHorizontalGroup(
            Tab5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 805, Short.MAX_VALUE)
        );
        Tab5Layout.setVerticalGroup(
            Tab5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 433, Short.MAX_VALUE)
        );

        TabMenu.addTab("Работници", new javax.swing.ImageIcon(getClass().getResource("/Pics/w1.png")), Tab5); // NOI18N
        Tab5.getAccessibleContext().setAccessibleName("Tab5");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 820, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 518, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        TabMenu.getAccessibleContext().setAccessibleName("TabMenu");

        pack();
    }// </editor-fold>                        
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new HotelHG().setVisible(true);
            }
        });
    }

//============================================================================== FORM OPEN - CLOSE
    private void formWindowClosing(WindowEvent evt) {                                   
        CloseConnection();
    }                                  

    private void formWindowOpened(WindowEvent evt) {                                  
        if(!MyCodes1.LockAll())
            System.exit(1);
    }                                 
//============================================================================== FORM OPEN - CLOSE

//============================================================================== TAB1 CODES
    private void EnterButton1ActionPerformed(ActionEvent evt) {                                             
        MyCodes1.AdministrationControl();
    }                                            
//============================================================================== TAB1 CODES







    // Variables declaration - do not modify                     
    public javax.swing.JButton EnterButton1;
    public javax.swing.JButton ExitButton1;
    public javax.swing.JTextField IDBox1;
    public javax.swing.JTextField PassBox;
    public javax.swing.JLabel StatusLabel1;
    public javax.swing.JPanel Tab1;
    public javax.swing.JPanel Tab2;
    public javax.swing.JPanel Tab3;
    public javax.swing.JPanel Tab4;
    public javax.swing.JPanel Tab5;
    public javax.swing.JTabbedPane TabMenu;
    public javax.swing.JButton jButton1;
    public javax.swing.JLabel jLabel1;
    public javax.swing.JLabel jLabel2;
    public javax.swing.JLabel jLabel3;
    public javax.swing.JLabel jLabel4;
    public javax.swing.JLabel jLabel5;
    public javax.swing.JLabel jLabel6;
    public javax.swing.JSeparator jSeparator1;
    public javax.swing.JTextField jTextField1;
    // End of variables declaration                   

}

C类代码:

import javax.swing.JOptionPane;

public class Tab1Codes extends HotelHG{

    byte PassTry;
//============================================================================== LOCK ALL TABS
    public boolean LockAll(){
        try
        {
            TabMenu.setEnabledAt(1, false);
            TabMenu.setEnabledAt(2, false);
            TabMenu.setEnabledAt(3, false);
            TabMenu.setEnabledAt(4, false);
        }catch(Exception e)
        {
            JOptionPane.showConfirmDialog(null, "Не можем да заключим разделите!",
                    "Заключване на разделите...",
                    JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
            return false;
        }
        return true;
    }
//============================================================================== LOCK ALL TABS

//============================================================================== ADMINISTRATION
    public void AdministrationControl(  ){
        PassTry=0;
        byte No=1;
        do{
            if(ChechForIDPass(No)){
                FindUserType(No);
                No=4;
            }
            else{
                No++;
                PassTry++;
                JOptionPane.showConfirmDialog(null, "Грешно Потребителско име  или Парола!",
                       "П. Име-Парола Контрол...",
                        JOptionPane.PLAIN_MESSAGE,
                        JOptionPane.ERROR_MESSAGE);
            }
                        if(No == 1) 
                        if(No == 2) 
                        if(No == 3) 
                        TabMenu.setEnabledAt(2, false);
                        PassTry=0;
        }while(No<4);
    }
//============================================================================== ADMINISTRATION

//============================================================================== CHECK FOR ID PASS
    private boolean ChechForIDPass(byte NO){
        try {
            Res.absolute(NO);
            if(IDBox1.getText().equals(Res.getString("ID"))) {
                if(PassBox.getText().equals(Res.getString("Pass"))) {
                    return true;
                }
            }
        }catch(Exception ex){
            JOptionPane.showConfirmDialog(null, "Грешка с Връзка на Данни!",
                    "П. Име-Парола Контрол...",
                    JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
        }
        return false;
    }
//============================================================================== CHECK FOR ID PASS

//============================================================================== FIND USER TYPE
    private void FindUserType(byte NO){
        try {
            Res.absolute(NO);
            if(Res.getString("access").equalsIgnoreCase("Admin")){
                PassTry=0;
                StatusLabel1.setText("Статус:Админ Достъп");
                JOptionPane.showConfirmDialog(null, "Верна Парала! Здравей Администратор!",
                       "П. Име-Парола Контрол...",
                        JOptionPane.PLAIN_MESSAGE,
                        JOptionPane.INFORMATION_MESSAGE);
                TabMenu.setEnabledAt(2, true);
                TabMenu.setEnabledAt(3, true);
                TabMenu.setEnabledAt(4, true);
                TabMenu.setEnabledAt(5, true);
            }
            if(Res.getString("access").equalsIgnoreCase("Reception")){
                PassTry=0;
                StatusLabel1.setText("Статус:Ресепция Достъп");
                JOptionPane.showConfirmDialog(null, "Верна Парала! Здравей Потребител!",
                       "П. Име-Парола Контрол...",
                        JOptionPane.PLAIN_MESSAGE,
                        JOptionPane.INFORMATION_MESSAGE);
                TabMenu.setEnabledAt(2, true);
                TabMenu.setEnabledAt(3, true);
            }
            if(Res.getString("access").equalsIgnoreCase("Worker")){
                PassTry=0;
                StatusLabel1.setText("Статус:Работник Достъп");
                JOptionPane.showConfirmDialog(null, "Верна Парала! Здравей Потребител!",
                       "П. Име-Парола Контрол...",
                        JOptionPane.PLAIN_MESSAGE,
                        JOptionPane.INFORMATION_MESSAGE);
                TabMenu.setEnabledAt(4, true);
                TabMenu.setEnabledAt(5, true);
            }

        }catch(Exception ex){
            JOptionPane.showConfirmDialog(null, "Грешка с Връзка на Данни!",
                    "П. Име-Парола Контрол...",
                    JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
        }
    }
//============================================================================== FIND USER TYPE
}

2 个答案:

答案 0 :(得分:2)

问题的原因不是来自扩展HotelHG - 原因隐藏在“//部分代码”的某处。如果你有太多的方法调用,虚拟机会引发StackOverFlowError,通常当你有一个递归算法没有像这样正确终止时:

 public void createStackOverFlowError() {
    createStackOverFlowError();
 }

所以要摆脱这个错误:在你的应用程序代码中寻找产生这种“循环”的方法。

答案 1 :(得分:0)

  1. HotelHG中的主要方法基类没有继承到类Tab1Codes中,因此您应该复制子类中的整个main方法,并且还要更改代码以在其中创建类的对象

  2. 您还没有提到如何运行这些文件,请详细说明您是如何运行该程序的?

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new Tab1Codes().setVisible(true);
        }
    });
    

    }

  3. 此方法添加到新子类并运行子类文件可能有效。

    关于
    Tushar Joshi,那格浦尔