Complies but doesn't run!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • javatech007
    New Member
    • Nov 2007
    • 51

    #1

    Complies but doesn't run!

    Here is my application. It does compile successfully but it won't run. I throes up an error saying :

    Exception in thread "main"
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

    Code(Java):

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event. *;


    public class Main_Menu extends JFrame implements ActionListener

    {

    private JButton timetableBtn;
    private JLabel irishrailpicLbl ;
    private JPanel panel;

    public Main_Menu()

    {

    super("Irish Rail Main Menu");
    Container c = getContentPane( );
    panel = new JPanel(new BorderLayout()) ;
    irishrailpicLbl = new JLabel(new ImageIcon("iarn rod.bmp"));
    timetableBtn = new JButton("TimeTa bles");
    timetableBtn.ad dActionListener (this);
    panel.add(irish railpicLbl, BorderLayout.NO RTH);
    c.add(panel);
    setVisible(true );
    setSize(800,800 );

    }

    public static void Main(String args[])

    {

    Main_Menu main_menu = new Main_Menu();

    }

    public void actionPerformed (ActionEvent e)

    {

    if (e.getSource() == timetableBtn)
    {
    this.setVisible (false);
    Admin_Login pass = new Admin_Login();
    pass.setVisible (true);

    }

    }
    }
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by javatech007
    Here is my application. It does compile successfully but it won't run. I throes up an error saying :

    Exception in thread "main"
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    *Continue Quote*
    [CODE=java]
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event. *;


    public class Main_Menu extends JFrame implements ActionListener

    {

    private JButton timetableBtn;
    private JLabel irishrailpicLbl ;
    private JPanel panel;

    public Main_Menu()

    {

    super("Irish Rail Main Menu");
    Container c = getContentPane( );
    panel = new JPanel(new BorderLayout()) ;
    irishrailpicLbl = new JLabel(new ImageIcon("iarn rod.bmp"));
    timetableBtn = new JButton("TimeTa bles");
    timetableBtn.ad dActionListener (this);
    panel.add(irish railpicLbl, BorderLayout.NO RTH);
    c.add(panel);
    setVisible(true );
    setSize(800,800 );

    }

    public static void Main(String args[])

    {

    Main_Menu main_menu = new Main_Menu();

    }

    public void actionPerformed (ActionEvent e)

    {

    if (e.getSource() == timetableBtn)
    {
    this.setVisible (false);
    Admin_Login pass = new Admin_Login();
    pass.setVisible (true);

    }

    }
    }[/CODE]*End Quote*

    Are you sure, that's all? If so, what's this "Admin_Logi n"? I can't see anything wrong with what you've posted so far (haven't looked very thoroughly though, I must admit, as I can't see anything to do with "jGRASP", which is "a lightweight development environment, created specifically to provide automatic generation of software visualizations. .." and therefore external).

    Greetings,
    Nepomuk

    PS: You start java code tags with [ CODE = java ] and end them with [ /CODE ] (both without the blanks of course).

    Comment

    • javatech007
      New Member
      • Nov 2007
      • 51

      #3
      Here is all the code:

      Code: (Java)

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event. *;


      public class Main_Menu extends JFrame implements ActionListener

      {

      private JButton timetableBtn;
      private JLabel irishrailpicLbl ;
      private JPanel panel;

      public Main_Menu()

      {

      super("Irish Rail Main Menu");
      Container c = getContentPane( );
      panel = new JPanel(new BorderLayout()) ;
      irishrailpicLbl = new JLabel(new ImageIcon("iarn rod.bmp"));
      timetableBtn = new JButton("TimeTa bles");
      timetableBtn.ad dActionListener (this);
      panel.add(irish railpicLbl, BorderLayout.NO RTH);
      c.add(panel);
      setVisible(true );
      setSize(800,800 );

      }

      public static void Main(String args[])

      {

      Main_Menu main_menu = new Main_Menu();

      }

      public void actionPerformed (ActionEvent e)

      {

      if (e.getSource() == timetableBtn)
      {
      this.setVisible (false);
      Admin_Login pass = new Admin_Login();
      pass.setVisible (true);

      }

      }
      }

      import java.io.*;
      import java.awt.*;
      import java.awt.event. *;
      import javax.swing.*;
      import javax.swing.eve nt.*;

      public class Admin_Login extends JFrame implements ActionListener
      {
      private JButton loginBtn, clearBtn, backBtn;
      private JTextField usernameTxt;
      private JPasswordField passwordTxt;
      private JLabel usernameLbl, passwordLbl;

      public Admin_Login()
      {
      super("Adminstr ator Login");

      FlowLayout flow =new FlowLayout();
      Container c = getContentPane( );
      c.setLayout(flo w);

      loginBtn = new JButton("Login" );
      loginBtn.addAct ionListener(thi s);

      backBtn = new JButton("Back") ;
      backBtn.addActi onListener(this );

      clearBtn = new JButton("Clear" );
      clearBtn.addAct ionListener(thi s);

      c.setBackground (Color.white);
      usernameLbl = new JLabel ("Username:" );
      passwordLbl = new JLabel ("Password:" );
      usernameTxt = new JTextField (10);
      passwordTxt = new JPasswordField (10);

      c.add(usernameL bl);
      c.add(usernameT xt);
      c.add(passwordL bl);
      c.add(passwordT xt);
      c.add(loginBtn) ;
      c.add(backBtn);
      c.add(clearBtn) ;

      c.setBackground (Color.white);

      setSize(250,150 );
      setVisible(true );

      }

      public static void main(String[] args)
      {

      Admin_Login admin= new Admin_Login();

      }

      public void actionPerformed (ActionEvent e)
      {
      if (e.getSource() == loginBtn)

      {
      String username = "Rory";
      String password = "IS2216";
      String newStr = passwordTxt.get Text();
      String newStr2 = usernameTxt.get Text();

      if(newStr.equal s(password) && newStr2.equals( username))
      {

      JOptionPane.sho wMessageDialog( null, "Welcome " + usernameTxt.get Text());

      }


      if (e.getSource() == clearBtn)

      usernameTxt.set Text("");
      passwordTxt.set Text("");
      }
      }
      }

      (/Code)

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Once again, you can either get code tags by pressing on the button marked "#" or by typing them in: note that they use brackets, not parentheses:

        [CODE=Ja va]
        x = y;
        z = w;
        [/CODE]

        Comment

        Working...