Results 1 to 11 of 11
- 06-01-2009, 03:34 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 27
- Rep Power
- 0
- 06-01-2009, 03:45 PM #2
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
- 06-01-2009, 04:12 PM #3
Member
- Join Date
- Feb 2009
- Posts
- 27
- Rep Power
- 0
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.
- 06-01-2009, 04:58 PM #4
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 05:05 PM.
- 06-01-2009, 06:57 PM #5
Member
- Join Date
- Feb 2009
- Posts
- 27
- Rep Power
- 0
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
-
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 [code] above your pasted code and the tag [/code] below your pasted code like so:
Java Code:[code] // your code goes here // notice how the top and bottom tags are different [/code]
- 06-02-2009, 05:23 PM #7
Member
- Join Date
- Feb 2009
- Posts
- 27
- Rep Power
- 0
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
i dont understand why it will not load. If i take the servleturlpanel code out it will work. Im miffedJava 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);
- 06-02-2009, 06:34 PM #8
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
- 06-02-2009, 07:36 PM #9
Member
- Join Date
- Feb 2009
- Posts
- 27
- Rep Power
- 0
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.
- 06-02-2009, 07:39 PM #10
Member
- Join Date
- Feb 2009
- Posts
- 27
- Rep Power
- 0
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);
- 06-02-2009, 10:25 PM #11
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.
You'll probably also find this resource usefulJava Code:private static URL = new URL("http://localhost:8084/Assignment/pass1ser");
The Java™ TutorialsDon't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Similar Threads
-
Cannot open socket with Log4J from Applet
By i007 in forum Advanced JavaReplies: 3Last Post: 03-20-2009, 03:01 AM -
cannot open database requested in login. Login fails
By banduskank in forum JDBCReplies: 0Last Post: 06-25-2008, 12:41 PM -
Jlabel in Login Applet
By nokomis in forum Java AppletsReplies: 3Last Post: 06-05-2008, 10:29 PM -
Applet Login System Tutorial
By Free-JavaTutorials in forum Java AppletsReplies: 0Last Post: 03-15-2008, 02:51 AM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks