Results 1 to 11 of 11
  1. #1
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default [SOLVED] After login, new applet open

    Once you have an login authenticated, how do you get java to clear panel or open a new applet or something?

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Program some code to do so.

    You may need to be more specific. Try having a go yourself first.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    what a helpful post!

    What i have tried to do:

    <code>

    if (obj.equals("Login"))
    {
    this.interactWithServlet();
    return true;
    }
    return false;
    }

    </code>

    What i want to do is that after the login has been authenticated i want to clear all the panels and overwrite this and put some fresh objects on it.

  4. #4
    Mr.Beans's Avatar
    Mr.Beans is offline Senior Member
    Join Date
    Apr 2009
    Location
    Virginia Beach, Virginia
    Posts
    149
    Rep Power
    0

    Default

    First off OrangeDog provided a very helpful post, and it's best that you take his advice.

    PHPBB does not except html segments. You need to use their BB code. Usually this means replacing the < & > with [ & ]

    Also it does not appear that you have provided much of the relavent code.

    Please show us how you have tried to accomplish your goal.

    Mr. Beans

    BTW You should try investing some of your time into reading through the article OrangeDog links to in his signature.
    Last edited by Mr.Beans; 06-01-2009 at 06:05 PM.

  5. #5
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    ok what it is most of my coding has been from a VB background, but this time, its with java, so im not 100%.

    at the start of my code i have
    public void init()
    {
    super.init();
    this.setLayout(new BorderLayout());

    Panel topPanel = new Panel();
    topPanel.setLayout(new GridLayout(0,1));

    Panel servletUrlPanel = new Panel ();

    then i have multiple pannels, one of username, password, display and a button on the bottom

    Basicly when you enter a username and password, the applet sends two strings to the database, which is then queried. If there is a match found, a variable called connecttodb will display either, it works, or try again.

    what i want to do, is that if the login is sucessful, then the person can go forth but if not, they have to stay at this place

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You might want to look at using a CardLayout layout manager. Then if the login is successful, swap out the login panel and swap in the application panel.

    Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [cod&#101;] above your pasted code and the tag [/cod&#101;] below your pasted code like so:

    Java Code:
    [cod&#101;]
      // your code goes here
      // notice how the top and bottom tags are different
    [/cod&#101;]

  7. #7
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    ok i have tried to implement card layouts but the applet will not load giving this error:

    java.lang.NullPointerException
    at sicksys.pass1.init(pass1.java:48)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.NullPointerException

    heres some code which i have typed in

    Java Code:
    public class pass1 extends Applet implements ActionListener
    {
      TextField servletUrlField;
      TextField Username;
      TextField Password;
      TextArea responseField;
      Panel cardPanel;        // the container that will hold the various "cards"
      Panel firstP, secondP, thirdP,servletUrlPanel, User, Pass;  // each of these panels will constitute the "cards"
      Panel buttonP;                  // panel to hold three buttons
      Button first, second, third;    // the three buttons
      GridLayout grid1, grid2, grid3;
      BorderLayout border, border1;
      CardLayout ourLayout;           // the card layout object
    
      public void init()
      {
        //create cardPanel which is the panel that will contain the three "cards"
        cardPanel = new Panel();
        //create the CardLayout object
        ourLayout = new CardLayout();
        //set card Panel's layout to be our Card Layout
        cardPanel.setLayout (ourLayout);
    
       //Panel servletUrlPanel = new Panel ();
       servletUrlPanel.setLayout(new BorderLayout());
       servletUrlPanel.add("West", new Label("Servlet URM:", Label.RIGHT));
       servletUrlPanel.add("Center", servletUrlField = new TextField("http://localhost:8084/Assignment/pass1ser"));
           //servletURL is set to hidden so that no one can modify it
       servletUrlPanel.setVisible(false);
       firstP.add(servletUrlPanel);
    i dont understand why it will not load. If i take the servleturlpanel code out it will work. Im miffed

  8. #8
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Which is line 48? Something there is null when it shouldn't be.

    Not sure what the point of the hidden panel is. If you want to hold a url somewhere, just declare a variable of type URL or similar.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  9. #9
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    what you must remember is that im not as good with java as you. The reason why there is a textbox there is to tell the applet where the servlet is. In the early days of trying to create this, i was fiddling around trying to get it working, as the code was supposed to be pointing at port 8080 however when netbeans installed it set appache to 8084, so i needed something editable, so thats what i thought was the best way to do it.

  10. #10
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    just a quick update, i have managed to get some things on to the card by doing the following. Im sure its not the cleanest way of doing it, but its the best i can do

    Java Code:
    firstP = new Panel();
        firstP.setBackground(Color.LIGHT_GRAY);
    
        servletUrlPanel = new Panel();
        servletUrlPanel.setLayout(new BorderLayout());
        servletUrlPanel.add("West", new Label("Servlet URM:", Label.RIGHT));
        servletUrlPanel.add("Center", servletUrlField = new TextField("http://localhost:8084/Assignment/pass1ser"));
        firstP.add(servletUrlPanel);

  11. #11
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    As I said, don't use hidden UI components to hold information, use normal variables. This would probably want to be a private, static field.
    Java Code:
    private static URL = new URL("http://localhost:8084/Assignment/pass1ser");
    You'll probably also find this resource useful
    The Java™ Tutorials
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. Cannot open socket with Log4J from Applet
    By i007 in forum Advanced Java
    Replies: 3
    Last Post: 03-20-2009, 04:01 AM
  2. Replies: 0
    Last Post: 06-25-2008, 01:41 PM
  3. Jlabel in Login Applet
    By nokomis in forum Java Applets
    Replies: 3
    Last Post: 06-05-2008, 11:29 PM
  4. Applet Login System Tutorial
    By Free-JavaTutorials in forum Java Applets
    Replies: 0
    Last Post: 03-15-2008, 03:51 AM
  5. Replies: 4
    Last Post: 06-08-2007, 07:15 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
  •