last time, i have read in the internet that java applet don't allow the users to read/write to file...but i found this one website that teaches how to open or write to file in java applet....
http://www.captain.at/programming/java/
after i follow the instruction, 2 files created which is TicketInterface.crt and TicketInterface.jar (i have class called TicketInterface which extends JApplet)
besides that, i have 2 classes which are Admin and User...The User class have some attributes and methods which related to Write and Read Files (BufferedReader...BufferedWriter...something like that)....The Admin class don't have any of the attributes or methods which related to Write or Read Files...The TicketInterface class will call some of the methods from the User class as well as Admin class....
the problem is i still can't open or write to file...Supposely, the TicketInterface class will call the method from User class so that it can write or read to file...
this is some of the portion taken from User class :-
this is some of the portion taken from TicketInterface class :-Code://///////////////////return LOGIN USER TRUE FALSE//////////////////////////////////// public boolean LoginUser() throws IOException { BufferedReader inputusername = new BufferedReader (new FileReader("username.txt")); BufferedReader inputpassword = new BufferedReader (new FileReader("password.txt")); while((UsernameArray[i] = inputusername.readLine()) != null) { if ((UsernameArray[i]).equals (Username)) { i++; flag = true; } else flag = false; } inputusername.close(); while((PasswordArray[i] = inputpassword.readLine()) != null) { if ((PasswordArray[i]).equals (Password)) { i++; flag2 = true; } else flag2 = false; } inputpassword.close(); if (flag == true && flag2 == true) { return true; } else return false; }
there is a screenshot after i sign my applet (after i follow the instruction from the above website)...i also attach the files which are created after i follow the instruction from the above websiteCode:if (e.getSource() == OkPassLoginUser) // call OK button for PASSWORD LOGIN USER { getContentPane().remove(TextFieldPassLoginUser); PasswordLoginUser = PassLoginUser.getText(); try { User u2 = new User(UsernameLoginUser, PasswordLoginUser); flag = u2.LoginUser(); if (flag == true) { MainMenuAdmin(); } else { setCenterPan(PanelError); } } catch (IOException ex) { ex.printStackTrace(); } }


Reply With Quote


Bookmarks