“java.lang.InternalError:当前进程已使用其所有系统允许的Window Manager对象句柄

时间:2017-04-05 13:17:09

标签: swingx

我已经制作了一个桌面应用程序,它没有运行。在线程“AWT-EventQueue-0”中声明异常的异常java.lang.InternalError:当前进程已使用其所有系统允许的Window Manager对象句柄。请告诉我解决它的步骤。

2 个答案:

答案 0 :(得分:0)

如果您不向我们提供更多信息,我们无法帮助您,发布代码行,其中发生例外情况。还要检查窗口构造函数中是否有太多swing组件。

答案 1 :(得分:-1)

我已经制作了一个桌面应用程序,它没有运行。在线程" AWT-EventQueue-0"中出现异常。 java.lang.InternalError:当前进程已使用其所有系统允许的Window Manager对象句柄。请告诉我解决它的步骤。

我的代码是

package com.agencysoftware.frames;

import com.agencysoftware.beans.AddAgentBean;
import static javax.swing.JFrame.setDefaultLookAndFeelDecorated;
import static com.agencysoftware.dao.Connect.estConnection;
import java.sql.Connection;
import java.sql.SQLException;
import javax.swing.JOptionPane;

import static com.agencysoftware.dao.AutoCompleteFunction.setupAutoComplete;
import com.agencysoftware.operations.ViewAgentOps;
import java.util.ArrayList;

/**
 *
 * @author Ajit Mario John
 */
public class Agent extends javax.swing.JInternalFrame {

    ArrayList<String> nameList;

    /**
     * Creates new form Agent
     */
    public Agent() {
        initComponents();
         setDefaultLookAndFeelDecorated(true);
         setNameList();

    }

    /*method to set the name of agent coming from database*/
    private void setNameList()
    {
        try(Connection con = estConnection())
        {
            nameList = new ViewAgentOps().getAgentName(con);
        }
        catch(SQLException e)
        {
            JOptionPane.showMessageDialog(this, "SQLException "+e);
            e.printStackTrace();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, "Exception "+e);
            e.printStackTrace();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */

    private AddAgentBean setValueToBean()
    {
        AddAgentBean aab = new AddAgentBean();

        aab.setName(name.getText());
        aab.setAddress(address.getText());
        aab.setCity(city.getText());
        aab.setPincode(pincode.getText());
        aab.setCategory(category.getText());

        return aab;
    }//end of private AddAgentBean setValueToBean()

    private void setNull()
    {
        name.setText("");
        address.setText("");
        city.setText("");
        pincode.setText("");
        category.setText("");
    }

    private void setValueFromBeanToFrame(AddAgentBean aab)
    {
        address.setText(aab.getAddress());
        city.setText(aab.getCity());
        pincode.setText(aab.getPincode());
        category.setText(aab.getCategory());
    }

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

        jLabel5 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        name = new javax.swing.JTextField();
        city = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        address = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        pincode = new javax.swing.JTextField();
        category = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();

        jLabel5.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        jLabel5.setText("Pincode");

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Add Agent");

        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel1.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        jLabel1.setText("Address");

        jLabel2.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        jLabel2.setText("Name");

        jLabel3.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        jLabel3.setText("City");

        name.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                nameFocusLost(evt);
            }
        });
        name.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                nameKeyTyped(evt);
            }
        });

        address.setColumns(20);
        address.setRows(5);
        jScrollPane1.setViewportView(address);

        jLabel4.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        jLabel4.setText("Pincode");

        jLabel6.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        jLabel6.setText("Category");

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/agencysoftware/images/db_update.png"))); // NOI18N
        jButton2.setText("Update");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/agencysoftware/images/edit-delete.png"))); // NOI18N
        jButton3.setText("Delete");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/agencysoftware/images/add_user.png"))); // NOI18N
        jButton1.setText("Add");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(pincode))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(category))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(city)
                                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(42, 42, 42))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                        .addGap(31, 31, 31)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(28, 28, 28))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(52, 52, 52)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(city, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pincode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(category, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton1))
                .addContainerGap())
        );

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/agencysoftware/images/agent4.png"))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(50, 50, 50))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(87, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        AddAgentBean aab = setValueToBean();
        System.out.println(aab);
        try(Connection con = estConnection())
        {
            int insert = aab.addAgentValueToDatabase(con);

            if(insert!=0)
            {
                JOptionPane.showMessageDialog(this, "Agent got added to System");
            }//end of if(insert!=0)
            else
            {
                JOptionPane.showMessageDialog(this, "Agent didn't get added to System");
            }
        }
        catch(ClassNotFoundException e)
        {
            JOptionPane.showMessageDialog(this, "ClassNotFoundException"+e);
            e.printStackTrace();
        }
        catch(SQLException e)
        {
            JOptionPane.showMessageDialog(this, "SQLException"+e);
            e.printStackTrace();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, "Exception"+e);
            e.printStackTrace();
        }

        setNameList();
        setNull();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void nameKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nameKeyTyped
        setupAutoComplete(name, nameList);
    }//GEN-LAST:event_nameKeyTyped

    private void nameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_nameFocusLost
        String agentName = name.getText();

        try(Connection con = estConnection())
        {
            AddAgentBean aab = new AddAgentBean().retrieveDataAccTOAgent(con, agentName);

            setValueFromBeanToFrame(aab);
        }
        catch(ClassNotFoundException e)
        {
            JOptionPane.showMessageDialog(this, "ClassNotFoundException"+e);
            e.printStackTrace();
        }
        catch(SQLException e)
        {
            JOptionPane.showMessageDialog(this, "SQLException"+e);
            e.printStackTrace();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, "Exception"+e);
            e.printStackTrace();
        }

    }//GEN-LAST:event_nameFocusLost

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        AddAgentBean aab = setValueToBean();

        try(Connection con = estConnection())
        {
            int update = aab.updateValueToDatabase(con);

            if(update!=0)
            {
                JOptionPane.showMessageDialog(this, "Agent information got update to System");
            }//end of if(insert!=0)
            else
            {
                JOptionPane.showMessageDialog(this, "Agent didn't get updated");
            }
        }
        catch(ClassNotFoundException e)
        {
            JOptionPane.showMessageDialog(this, "ClassNotFoundException"+e);
            e.printStackTrace();
        }
        catch(SQLException e)
        {
            JOptionPane.showMessageDialog(this, "SQLException"+e);
            e.printStackTrace();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, "Exception"+e);
            e.printStackTrace();
        }

   setNameList();
        setNull();

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        String agentName = name.getText();

        try(Connection con = estConnection())
        {
            int delete = new AddAgentBean().deleteAgentInfoFromDatabase(con, agentName);

            if(delete!=0)
            {
                JOptionPane.showMessageDialog(this, "Agent information got deleted from System");
            }//end of if(insert!=0)
            else
            {
                JOptionPane.showMessageDialog(this, "Agent didn't get deleted");
            }
        }
        catch(ClassNotFoundException e)
        {
            JOptionPane.showMessageDialog(this, "ClassNotFoundException"+e);
            e.printStackTrace();
        }
        catch(SQLException e)
        {
            JOptionPane.showMessageDialog(this, "SQLException"+e);
            e.printStackTrace();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, "Exception"+e);
            e.printStackTrace();
        }

        setNameList();
        setNull();

    }//GEN-LAST:event_jButton3ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea address;
    private javax.swing.JTextField category;
    private javax.swing.JTextField city;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField name;
    private javax.swing.JTextField pincode;
    // End of variables declaration//GEN-END:variables
}

当我使用JOptionPane

时,这个问题主要发生