javaeclipsejavaw

Eclipse : JAVAW terminated


perhaps i misclicked something, and my java application won't run. i have made the following Login Form and press f12 to run my java application.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;

import javax.swing.*;


public class Cl_Login extends JFrame {

    Cl_Register registerform = new Cl_Register();
    Command cmd = new Command();
    Validate val = new Validate();
    public static Cl_Login logform = null;
    static private String form_name = "Gamestops Login";
    static private String lbl_judul = "GameStops";
    static private String lbl_username = "Username";
    static private String lbl_password = "Password";
    static private String lbl_buttonlogin = "Login";
    static private String lbl_buttonreset = "Reset";
    static private String lbl_buttonregister = "Register";          

    public void addComponentsToPane(Container pane) {                       
        JButton buttonlogin,buttonregister,buttonreset; 
        JLabel labelatas,labelbawah,labelusername,labelpassword;
        JPanel panelbawah,paneltengah,panelkiri,panelkanan;
        final JTextField textusername;
        final JPasswordField textpassword;

        labelatas = new JLabel(lbl_judul,SwingConstants.CENTER);        
        pane.add(labelatas, BorderLayout.PAGE_START);


        paneltengah= new JPanel(new GridLayout(2,2));

        labelusername = new JLabel(lbl_username,SwingConstants.CENTER);                                                         
        paneltengah.add(labelusername);

        labelpassword = new JLabel(lbl_password,SwingConstants.CENTER);
        paneltengah.add(labelpassword);

        textusername = new JTextField(20);
        textpassword = new JPasswordField(20);
        paneltengah.add(textusername);
        paneltengah.add(textpassword);
        pane.add(paneltengah, BorderLayout.LINE_START);         

        panelbawah = new JPanel(new FlowLayout(FlowLayout.CENTER)); 
        buttonlogin = new JButton(new AbstractAction(lbl_buttonlogin) {

            @Override
            public void actionPerformed(ActionEvent e) {

                String inusernamenya = textusername.getText();
                String inpassword = textpassword.getText();

                if(val.isEmpty(inusernamenya) || val.isEmpty(inpassword))
                {
                    cmd.printError("Username or Password must be filled !", form_name);
                }
                else
                {
                    cmd.printSuccess("Login Success !", form_name);
                    Cl_Main mainform = new Cl_Main();
                    mainform.showFormAdmin(true);
//                  cmd.printSuccess(System.getProperty("sun.arch.data.model"), form_name);
//                  ConnectAccess ca = new ConnectAccess();
//                  ResultSet resultnya = ca.getData("Select * from MsUser where Username = '"+inusernamenya+"' and password = '"+inpassword+"'");
//                  try {
//                      if(resultnya.next())
//                      {
//                          
//                          cmd.printSuccess(inusernamenya+" dan "+inpassword+" berhasil login", form_name);                            
//                          Cl_Main mainform = new Cl_Main();                           
//                      }
//                      else
//                      {
//                          cmd.printError("Invalid username or password !", form_name);
//                      }
//                  } catch (SQLException e) {
//                      // TODO Auto-generated catch block
//                      e.printStackTrace();
//                  }

                    //if user role admin blabla user blabla             
                    //show MDI

                }
            }
        });         
        buttonreset = new JButton(lbl_buttonreset);
        buttonreset.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) { 
                textusername.setText("");
                textpassword.setText("");
            }
        });
        buttonregister = new JButton(lbl_buttonregister);       
                buttonregister.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
//              new Cl_Register().setVisible(true);
                registerform.showRegister();
                setVisible(false);
            }
        });
        panelbawah.add(buttonlogin);
        panelbawah.add(buttonreset);        
        panelbawah.add(buttonregister);
        pane.add(panelbawah, BorderLayout.PAGE_END);

    }   

    public Cl_Login() {
        setVisible(true);       
        this.setTitle(form_name);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setResizable(false);        
        addComponentsToPane(this.getContentPane());
        pack();
        setLocationRelativeTo(null);

    }

    /**
     * @param args
     */
    public static void main(String[] args) {        
        Cl_Login login = new Cl_Login();
    }

}

then, eclipse show the following error enter image description here

i have no idea what is happening, because everything perfectly fine in the last couple of hours. i believe i made some mistake by misclicked something or activate something in my eclipse.

why does my login form is not show ?

idk if the following picture has something to do with my login form problem enter image description here

solved, the problem coming from the following code

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;


public class Cl_Register{

//  Cl_Login loginform = new Cl_Login(); << done by markin as comment, still not understand why does this line causing the problem
    Command cmd = new Command();
    Validate val = new Validate();
    static private String form_name = "Register Form";
    static private String lbl_judul = "Register";
    static private String lbl_name = "Name";
    static private String lbl_username = "Username";
    static private String lbl_password = "Password";
    static private String lbl_gender = "Gender";
    static private String lbl_email = "Email";
    static private String lbl_hobby = "Hobby";
    static private String lbl_role = "Role";
    static private String lbl_buttonlogin = "Login";
    static private String lbl_buttonreset = "Reset";
    static private String lbl_buttonregister = "Register";  




    public void showRegister() {        

        JFrame frame = new JFrame(form_name);
        JButton buttonlogin,buttonregister,buttonreset; 
        JLabel labelatas,labeljudul,labelname,labelusername,labelpassword,labelgender,labelemail,labelhobby,labelrole;
        JPanel panelbawah,paneltengah,panelkiri,panelkanan,panelgender;
        final JTextField textname,textusername,textemail;
        final JPasswordField textpassword;
        JRadioButton radiobuttonmale,radiobuttonfemale;
        JComboBox comboboxhobby,comboboxrole;

        String[]listhobby = {"Coding", "Swimming", "Racing", "Playing Football", "Playing Basketball", "Painting", "Drawing"};
        String[]listrole={"Admin","User"};
        labelatas = new JLabel(lbl_judul,SwingConstants.CENTER);

        frame.add(labelatas,BorderLayout.PAGE_START);

        panelkiri = new JPanel(new GridLayout(7,1));        
        labelname = new JLabel(lbl_name,SwingConstants.LEFT);       
        labelusername = new JLabel(lbl_username,SwingConstants.LEFT);                                                                           
        labelpassword = new JLabel(lbl_password,SwingConstants.LEFT);               
        labelgender = new JLabel(lbl_gender,SwingConstants.LEFT);               
        labelemail = new JLabel(lbl_email,SwingConstants.LEFT);         
        labelhobby = new JLabel(lbl_hobby,SwingConstants.LEFT);             
        labelrole = new JLabel(lbl_role,SwingConstants.LEFT);               
        panelkiri.add(labelname);
        panelkiri.add(labelusername);
        panelkiri.add(labelpassword);       
        panelkiri.add(labelemail);  
        panelkiri.add(labelgender);
        panelkiri.add(labelhobby);
        panelkiri.add(labelrole);
        frame.add(panelkiri, BorderLayout.LINE_START);  

        panelkanan = new JPanel(new GridLayout(7,1));   
        panelgender = new JPanel(new FlowLayout(FlowLayout.CENTER));
        textname = new JTextField(5);       
        textusername = new JTextField(20);
        textpassword = new JPasswordField(20);
        textemail = new JTextField(20);
        comboboxhobby = new JComboBox(listhobby);
        comboboxrole = new JComboBox(listrole);


        radiobuttonmale = new JRadioButton("Male");
        radiobuttonfemale = new JRadioButton("Female");
        panelgender.add(radiobuttonmale);
        panelgender.add(radiobuttonfemale);

        comboboxhobby.setSelectedIndex(0);
        comboboxrole.setSelectedIndex(0);
        radiobuttonmale.setSelected(true);


        panelkanan.add(textname);       
        panelkanan.add(textusername);
        panelkanan.add(textpassword);
        panelkanan.add(textemail);
        panelkanan.add(panelgender);        
        panelkanan.add(comboboxhobby);
        panelkanan.add(comboboxrole);

        frame.add(panelkanan, BorderLayout.LINE_END);
        panelbawah = new JPanel(new FlowLayout(FlowLayout.CENTER)); 
        buttonlogin = new JButton(lbl_buttonlogin);     
        buttonlogin.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {         

            }
        });
        buttonreset = new JButton(lbl_buttonreset);
        buttonreset.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                textname.setText("");
                textusername.setText("");
                textpassword.setText("");
                textemail.setText("");
            }
        });
        buttonregister = new JButton(lbl_buttonregister);
        buttonregister.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub


            }
        });
        panelbawah.add(buttonlogin);
        panelbawah.add(buttonreset);        
        panelbawah.add(buttonregister);
        frame.add(panelbawah, BorderLayout.PAGE_END);
        frame.pack();
        frame.setVisible(true);     
        frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
        frame.setResizable(false);                      
        frame.setLocationRelativeTo(null);

    }   


    public Cl_Register() {              

    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub                  
    }

    public void actionPerformed(ActionEvent arg0) {
        // TODO Auto-generated method stub

    }

}

and i still don't understand why the error come from Cl_Register


Solution

  • As pointed out by gamliela your main is empty.It can't be that it was working earlier. Please check with your local history if you have made some changes.