Luen Hong Wuan

Greenhorn
+ Follow
since May 30, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Luen Hong Wuan

Oh, sorry. I forgot the preview the codes earlier.
14 years ago
I've tried to loop a switch case, to prompt for continuation, instead of stopping after one process is done. It resulted in an endless parse, lol.

The code is as below:



I've wanted to do something like, when the program ask if the user wants to continue the transaction and the user says yes (assuming its a confirmDialog with yes/no), it shows this part again :



Can someone point out to me where and which loop do I use to perform such event?
14 years ago
Thanks Rob, I'm sorry as I still couldn't get it. I wonder if anyone could give me an example on how to do it, or direct me to some similar cases or demonstration. I'm confused
14 years ago
i've tried using ActionListener for the JRadioButtons, but, the value that I would like to call in the function (currentbal) can't be retrieved and I'm not sure how to actually implement an ActionListener inside an ActionPerformed method. A bigger part of the code is as below, just to help you guys get a clearer picture.




I would like to know, if there is any way, I can fix this code to set a String to represent the JRadioButton, so that i can replace it as something like this :

if(jrbtn1="deposit"){
}
14 years ago
I created 2 radiobuttons, put it into a group box, and gave one of them a function called deposit ( a simple maths calculation) and the other, withdrawal.However, when i run the program, even when i don't select the 1st button, it automatically runs the deposit function, and when i click the other button, it doesn't execute the withdrawal function. I''m guessing that its either:

-the true value at the radiobutton has a problem
-the boolean b part is assigned wrongly
-or I'm using the isSelected function the wrong way

Can someone please take a look at it and see if where i should fix? Alternative suggestions are extremely welcomed too!



14 years ago
It worked. Thanks Narendira for the thorough explanation, I've learned alot. I really never knew increment had to be done like that do avoid process from reloading. I was definitely trying very hard to declare a do-while or for loop to increment the value, but I think that it can be done with a do-while or a for loop if the "i" value is static at class level right? This is just out of curiosity ^^

I would also like to ask, if the program validated the username and password, it opens up NextPage, but the first Login page remains there, along with its Login and Exit function. How can I disable the first page after login is successful?

I cannot use setVisible(false) for login page, because the frame is created under static void main. The whole updated code is as below, I know its long, but I'm sure you guys will get a better idea what I'm talking about.

14 years ago
Oh, ok. The actionperform method takes place when the Login button is pressed. As far as im concerned, its tasks is suppose to include ;

checking on whether the username/password combination is correct, before allowing NextPage to take place, and also to limit the number of tries to 3 times before calling the system off.

I've achieved the first task, which leaves limiting number of tries to 3 times before calling the system off. I really wish someone could show me an example of a proper way to increment the count without reloading any other functions.
14 years ago
Fred >>
Haha yeah, now it made sense =.="

Narendira>>
Hmm..what about the loop? If I were to set an increment value to allow 3 tries of login, it also means, that the loop must cover all the way up to the input right? To allow users to retype and the program to recheck? Darn, to figure out where to place the loop and avoid reload is definitely a tough nut to crack =.="



Current code looks like this. I've also set int i as a static value way up at class level. However, its confusing on which loop to use, and also the placing of loop start and end.
14 years ago
Yeah, the code is working already. My bad, got a lil confused on how boolean works lol ..How do i count tries? Like , lets say the codes is suppose to allow 3 tries for login. Is this possibly done also with boolean? What is retryCount?
14 years ago
Ankit >>

Boolean has been set as false in default , thus "ok!=false" will return "true" no?
The reason why i set a boolean is because i assumed the program to stop and allow the users to try 3 times. Without the booleans , the program will only allow the user to try once, and the program pops up 3 error messages consequently instead of one, and then exits.

I don't understand what it means by declaring 'i' in the class level.
The first part of the boolean worked, as in..it checks every line of the input (notepad) and allows authentication. However if the wrong username/password is keyed in, it does not generate an error message as it is expected to do so.

This is part of the original code before i added in the boolean. If there are any better suggestions on to fulfill the criteria of 3 try-authentication, can i have some examples along with it, just for better understanding?

14 years ago
I'm implementing a login form, with two inputs, allowing a maximum of 3 tries for authentication; username and password. Scanner class reads input from notepad, and matches it with input from user. However, without a boolean statement, the program will search every line for a match until file ends, displaying every error message until match is found. For example, if the username/password combination is on the 5th line, it will display 4 error messages (invalid username/password) before allowing the user to login. Once boolean statements in the code are implemented, it matches the username/password combination immediately. However, the error message for wrong combination of username/password does not work anymore.
Can anyone please help check if the boolean statement is done properly? Code is as below.

14 years ago
Is it also possible to implement a max number of tries for dis kind of login form? I've tried using do-while loop, but instead of letting a user try 3 times and displaying an error message for each time an invalid username/password is presented, it displays the error message 3 times and then closes the system. Can you guys check my loop to see if i did anything wrong?

14 years ago
Ok, so i know we can read the information from the database file. Is it also possible to use 'alter' and 'update' just like in sql?

For example, lets say it involves calculation, a bank account for example, if transactions are done, surely the current balance would be updated right?

Even if the current balance can be updated, can it also be aligned with the correct users?
14 years ago
i checked my database done by my group member. The field 'password', data type has been set as a number =.=" i've changed it to text, and the program worked lol..

question is, how can i convert the 'value2' which is the password, into int data type? can i use the parseInt codes?
14 years ago
Dear Rob and Ravin,

I'm uber grateful for your enthusiasm and anticipation in solving this. I've a feeling that we're really this close =.="

I've no error during compilation after fixing the connection string and setting up the dsn. But this did popped up during execution :


checkjava.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (comma) in query expression 'user= 'cheeyin' , password = '123'


When i replaced the comma with an 'and', what i get is this :

[b]checkjava.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

I don't understand how would data type mismatch error appear, when both the values are declared as strings earlier on.
I've been thinking, if it isn't the code or the system problem anymore, would it then be the database file itself? Is there anything I should take note in the database file?

However, an empty field, allows the system to execute properly, in this case, display error message as below:

14 years ago