Java.lang.OutOfMemoryError

2 respostas
P
Pessoal estou fazendo um controlezinho bazico onde digito a data e ele diz num controle de hotel se o quarto está alugado ou está vago. Mas quando vou executar ele retorna um erro assim
Warning: Cannot convert string "MetaCtrl<Key>Insert" to type VirtualBinding
Exception in thread "main" java.lang.OutOfMemoryError
Se alguém puder me ajudar eu agradeço!! Segue abaixo o código do programa:
/*
 * Hotel.java
 *
 * Created on 1 de Abril de 2005, 14:02
 */

/**
 *
 * @author  bsi
 */
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.MaskFormatter;
import javax.swing.JOptionPane;
public class Hotel extends javax.swing.JFrame {
    
    /** Creates new form Hotel */
    public Hotel() {
        initComponents();
    }
    
    SqlHotel hotel = new SqlHotel();
    
    public static DefaultFormatterFactory formato(String mask){
        MaskFormatter comFoco=null,semFoco=null;
        try{
            comFoco = new MaskFormatter(mask);
        }catch (Exception e){
        }
        DefaultFormatterFactory factory = new DefaultFormatterFactory(comFoco,comFoco);
        return factory;
    }
    
    public int resp;
    public void alugar(){
        resp=JOptionPane.showConfirmDialog(this,"Deseja Alugar este quarto?","Pergunta!",JOptionPane.YES_NO_OPTION);
    }
    
    /** 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 void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        ftfData = new javax.swing.JFormattedTextField();
        bQuarto1 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        bQuarto2 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        bQuarto3 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        bQuarto4 = new javax.swing.JButton();
        bQuarto6 = new javax.swing.JButton();
        bQuarto7 = new javax.swing.JButton();
        bQuarto8 = new javax.swing.JButton();
        bQuarto5 = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        bQuarto10 = new javax.swing.JButton();
        bQuarto11 = new javax.swing.JButton();
        bQuarto12 = new javax.swing.JButton();
        bQuarto9 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        bQuarto14 = new javax.swing.JButton();
        bQuarto15 = new javax.swing.JButton();
        bQuarto16 = new javax.swing.JButton();
        bQuarto13 = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();

        setTitle("Controle de Hotel");
        setName("fHotel");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jPanel1.setLayout(null);

        jLabel1.setText("Data:");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(10, 20, 32, 15);

        ftfData.setFormatterFactory(formato("####-##-##"));
        ftfData.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                ftfDataFocusLost(evt);
            }
        });

        jPanel1.add(ftfData);
        ftfData.setBounds(50, 20, 90, 19);

        bQuarto1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto1ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto1);
        bQuarto1.setBounds(10, 70, 88, 30);

        jLabel6.setText("Quarto  1");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(30, 50, 60, 15);

        jLabel7.setText("Quarto 2");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(130, 50, 60, 15);

        bQuarto2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto2ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto2);
        bQuarto2.setBounds(110, 70, 88, 30);

        jLabel8.setText("Quarto 3");
        jPanel1.add(jLabel8);
        jLabel8.setBounds(230, 50, 60, 15);

        bQuarto3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto3ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto3);
        bQuarto3.setBounds(210, 70, 88, 30);

        jLabel9.setText("Quarto 4");
        jPanel1.add(jLabel9);
        jLabel9.setBounds(330, 50, 60, 15);

        bQuarto4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto4ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto4);
        bQuarto4.setBounds(310, 70, 88, 30);

        bQuarto6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto6ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto6);
        bQuarto6.setBounds(110, 130, 88, 30);

        bQuarto7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto7ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto7);
        bQuarto7.setBounds(210, 130, 88, 30);

        bQuarto8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto8ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto8);
        bQuarto8.setBounds(310, 130, 88, 30);

        bQuarto5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto5ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto5);
        bQuarto5.setBounds(10, 130, 88, 30);

        jLabel10.setText("Quarto 5");
        jPanel1.add(jLabel10);
        jLabel10.setBounds(30, 110, 60, 15);

        jLabel11.setText("Quarto 6");
        jPanel1.add(jLabel11);
        jLabel11.setBounds(130, 110, 60, 15);

        jLabel12.setText("Quarto 7");
        jPanel1.add(jLabel12);
        jLabel12.setBounds(230, 110, 60, 15);

        jLabel13.setText("Quarto 8");
        jPanel1.add(jLabel13);
        jLabel13.setBounds(330, 110, 60, 15);

        bQuarto10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto10ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto10);
        bQuarto10.setBounds(110, 190, 88, 30);

        bQuarto11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto11ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto11);
        bQuarto11.setBounds(210, 190, 88, 30);

        bQuarto12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto12ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto12);
        bQuarto12.setBounds(310, 190, 88, 30);

        bQuarto9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto9ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto9);
        bQuarto9.setBounds(10, 190, 88, 30);

        jLabel14.setText("Quarto 9");
        jPanel1.add(jLabel14);
        jLabel14.setBounds(30, 170, 60, 15);

        jLabel15.setText("Quarto 10");
        jPanel1.add(jLabel15);
        jLabel15.setBounds(130, 170, 70, 15);

        jLabel16.setText("Quarto 11");
        jPanel1.add(jLabel16);
        jLabel16.setBounds(230, 170, 70, 15);

        jLabel17.setText("Quarto 12");
        jPanel1.add(jLabel17);
        jLabel17.setBounds(330, 170, 70, 15);

        bQuarto14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto14ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto14);
        bQuarto14.setBounds(110, 250, 88, 30);

        bQuarto15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto15ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto15);
        bQuarto15.setBounds(210, 250, 88, 30);

        bQuarto16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto16ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto16);
        bQuarto16.setBounds(310, 250, 88, 30);

        bQuarto13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bQuarto13ActionPerformed(evt);
            }
        });

        jPanel1.add(bQuarto13);
        bQuarto13.setBounds(10, 250, 88, 30);

        jLabel18.setText("Quarto 13");
        jPanel1.add(jLabel18);
        jLabel18.setBounds(30, 230, 70, 15);

        jLabel19.setText("Quarto 14");
        jPanel1.add(jLabel19);
        jLabel19.setBounds(130, 230, 63, 15);

        jLabel20.setText("Quarto 15");
        jPanel1.add(jLabel20);
        jLabel20.setBounds(230, 230, 70, 15);

        jLabel21.setText("Quarto 16");
        jPanel1.add(jLabel21);
        jLabel21.setBounds(330, 230, 70, 15);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-423)/2, (screenSize.height-321)/2, 423, 321);
    }

    private void ftfDataFocusLost(java.awt.event.FocusEvent evt) {
        hotel.consultarHotel(ftfData.getText());
        bQuarto1.setText(hotel.getQuarto1());
        bQuarto2.setText(hotel.getQuarto2());
        bQuarto3.setText(hotel.getQuarto3());
        bQuarto4.setText(hotel.getQuarto4());
        bQuarto5.setText(hotel.getQuarto5());
        bQuarto6.setText(hotel.getQuarto6());
        bQuarto7.setText(hotel.getQuarto7());
        bQuarto8.setText(hotel.getQuarto8());
        bQuarto9.setText(hotel.getQuarto9());
        bQuarto10.setText(hotel.getQuarto10());
        bQuarto11.setText(hotel.getQuarto11());
        bQuarto12.setText(hotel.getQuarto12());
        bQuarto13.setText(hotel.getQuarto13());
        bQuarto14.setText(hotel.getQuarto14());
        bQuarto15.setText(hotel.getQuarto15());
        bQuarto16.setText(hotel.getQuarto16());
    }
    
    private void bQuarto16ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         alugar();
    }
    
    private void bQuarto15ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         alugar();
    }
    
    private void bQuarto14ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         alugar();
    }
    
    private void bQuarto13ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        alugar();
    }
    
    private void bQuarto12ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         alugar();
    }
    
    private void bQuarto11ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         alugar();
    }
    
    private void bQuarto10ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        alugar();
    }
    
    private void bQuarto9ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         alugar();
    }
    
    private void bQuarto8ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         alugar();
    }
    
    private void bQuarto7ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        alugar();
    }
    
    private void bQuarto6ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        alugar();
    }
    
    private void bQuarto5ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        alugar();
    }
    
    private void bQuarto4ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        alugar();
    }
    
    private void bQuarto3ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
       alugar();
    }
    
    private void bQuarto2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        alugar();
    }
    
    private void bQuarto1ActionPerformed(java.awt.event.ActionEvent evt) {
       alugar();
    }
    
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new Hotel().show();
    }
    
    // Variables declaration - do not modify
    private javax.swing.JButton bQuarto1;
    private javax.swing.JButton bQuarto10;
    private javax.swing.JButton bQuarto11;
    private javax.swing.JButton bQuarto12;
    private javax.swing.JButton bQuarto13;
    private javax.swing.JButton bQuarto14;
    private javax.swing.JButton bQuarto15;
    private javax.swing.JButton bQuarto16;
    private javax.swing.JButton bQuarto2;
    private javax.swing.JButton bQuarto3;
    private javax.swing.JButton bQuarto4;
    private javax.swing.JButton bQuarto5;
    private javax.swing.JButton bQuarto6;
    private javax.swing.JButton bQuarto7;
    private javax.swing.JButton bQuarto8;
    private javax.swing.JButton bQuarto9;
    private javax.swing.JFormattedTextField ftfData;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
    
}
Obrigado pela ajuda!!

2 Respostas

D

me parece q sua VM ficou sem memória suficiente…

abraços!

B

pqno, esse erro (java.lang.OutOfMemoryError ) ja aconteceu comigo, quando eu tentava carregar uma tabela muito grande do oracle. O default da VM eh 64M, então tive que executar o programa da seguinte forma:

java -Xmx256m -cp class Banco

-XmxZZm onde ZZ é o tamanho da sua RAM

comigo funcionou, mas só quando executo pelo DOS…
falow!

Criado 8 de abril de 2005
Ultima resposta 15 de abr. de 2005
Respostas 2
Participantes 3