Results 1 to 2 of 2
  1. #1
    boybackup is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default No error but can't see after logging in

    no error but i can't see anything after log in.. i dunno why.. please help.. here's the code.
    Java Code:
    LoginDemo.java
    
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
     
    class Login extends JFrame implements ActionListener
    {
     JButton SUBMIT;
     JPanel panel;
     JLabel label1,label2;
     final JTextField  text1,text2;
      Login()
      {
      label1 = new JLabel();
      label1.setText("Username:");
      text1 = new JTextField(15);
    
      label2 = new JLabel();
      label2.setText("Password:");
      text2 = new JPasswordField(15);
     
      SUBMIT=new JButton("SUBMIT");
      
      panel=new JPanel(new GridLayout(4,1));
      panel.add(label1);
      panel.add(text1);
      panel.add(label2);
      panel.add(text2);
      panel.add(SUBMIT);
      add(panel,BorderLayout.CENTER);
      SUBMIT.addActionListener(this);
      setTitle("LOGIN FORM");
      }
     public void actionPerformed(ActionEvent e)
      {
      String value1=text1.getText();
      String value2=text2.getText();
      if (value1.equals("java") && value2.equals("sample")) {
    int i=0;
    NextPage page=new NextPage();
    page.setVisible(true); 
    JButton[] buttons = new JButton[4];
    panel=new JPanel(new GridLayout(4,6));
    String  b[]={"S","McFloat","Fries","Burger",};
    for(i = 0; i < buttons.length; i++) {
    buttons[i] = new JButton(b[i]);
    buttons[i].setSize(80, 80);
    buttons[i].setActionCommand(b[i]);
    buttons[i].addActionListener(new ActionListener(){
        
    public void actionPerformed(ActionEvent e) {
    String choice = e.getActionCommand();
    JOptionPane.showMessageDialog(null, "You have clicked: "+choice);
    setVisible(true); 
      }
    });
    panel.add(buttons[i]);
    }
      }
      else{
      System.out.println("enter the valid username and password");
      JOptionPane.showMessageDialog(this,"Incorrect login or password",
      "Error",JOptionPane.ERROR_MESSAGE);
      }
    }
    }
     class LoginDemo
    {
      public static void main(String arg[])
      {
      try
      {
      Login frame=new Login();
      frame.setSize(300,100);
      frame.setVisible(true);
      }
      catch(Exception e)
      {JOptionPane.showMessageDialog(null, e.getMessage());}
      }
    }
    
    
    NextPage.java
    
    import javax.swing.*;
    import java.awt.*;
     
    class NextPage extends JFrame
    {
      NextPage()
     {
     setDefaultCloseOperation(javax.swing.
      WindowConstants.DISPOSE_ON_CLOSE);
     setTitle("Welcome");
     setSize(400, 200);
      }
     }
    Last edited by Norm; 11-06-2011 at 09:29 PM. Reason: added cod tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,307
    Rep Power
    25

    Default Re: No error but can't see after logging in

    i can't see anything after log in.
    What do you expect to see?
    Add some printlns to the code to show where the execution is going. Be sure to print out the values of any variables that are used to make decisions.

Similar Threads

  1. Replies: 2
    Last Post: 06-16-2011, 04:44 PM
  2. Error while logging in first time in struts 2
    By sameerk in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 11-03-2010, 08:53 AM
  3. Replies: 2
    Last Post: 03-09-2010, 08:18 AM
  4. Error logging
    By blueflash2o in forum NetBeans
    Replies: 0
    Last Post: 01-12-2010, 10:39 PM
  5. what is logging
    By Thirumalt in forum Java Software
    Replies: 1
    Last Post: 11-26-2007, 11:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •