Why does the title page disappear after the invaild intry
Author |
Message |
starcraft
|
Posted: Sun Mar 25, 2007 12:26 pm Post subject: Why does the title page disappear after the invaild intry |
|
|
Hmm, i create a prompt like program, where you run it, it tell you to type password, if the password is right, you can go to the next part of the program.
How ever, if you type the wrong password, it will say: password wrong, you cant enter, but the title page disappear when it says that. (page go blank)
I will post more details if you ask for it. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
PaulButler
|
Posted: Sun Mar 25, 2007 1:01 pm Post subject: RE:Why does the title page disappear after the invaild intry |
|
|
Uh, yeah, some code would help. |
|
|
|
|
|
starcraft
|
Posted: Sun Mar 25, 2007 4:29 pm Post subject: Re: Why does the title page disappear after the invaild intry |
|
|
OK, i think im at the right place, if my posts made no sense, then im at the right place.
this is the main method
/*The main method for the 'DelayYI' class,
after delay it creates a square*/
public static void main(String args[])
{
c=new Console(30,90);
//Set common integers.
int x=c.getWidth();
int y=c.getHeight();
int x1=0;
int y1=0;
int width=c.getWidth();
int height=c.getHeight();
//Call upon the loading methods.
{
titlePage(x,y,width,height,x1,y1);
prompt(x,y,width,height,x1,y1);
//enterKey();
titlePage(x,y,width,height,x1,y1);
sandFall(x,y);
doorOpen(x,y);
grid(x1,y1);
}
}//main method
and here is the password method.
//This method will allow or deny to user access.
public static void prompt(int x, int y, int width, int height, int x1, int y1)
{
/*Read a sequence of words until
the sentinel is read.*/
String word;
final String SENTINEL="NEO";
//Ask user to enter name for access to program.
c.setTextBackgroundColor(lightGrey);
c.print("Enter your name: ");
word=c.readLine();
while (!word.equalsIgnoreCase (SENTINEL))//Read while word is incorrect.
{
c.clear();
c.print("Access denied. ");
c.print("Please try again, enter your name now: ");
word= c.readLine ();
titlePage(x,y,width,height,x1,y1);
//c.clear();
//titlePage(x,y,width,height,x1,y1);
}
}//prompt method |
|
|
|
|
|
starcraft
|
Posted: Sun Mar 25, 2007 4:32 pm Post subject: Re: Why does the title page disappear after the invaild intry |
|
|
If I were to ptye the right word, it works, but if i type anything else, the whole page goes grey
I never told it to make the title page disspear.
If you need some more info, just ask and i will post. |
|
|
|
|
|
starcraft
|
Posted: Sun Mar 25, 2007 4:34 pm Post subject: Re: Why does the title page disappear after the invaild intry |
|
|
Oh, and this progrma im using is called
"IBM VisualAge for JAVA" |
|
|
|
|
|
klopyrev
|
Posted: Sun Mar 25, 2007 9:50 pm Post subject: Re: Why does the title page disappear after the invaild intry |
|
|
If the word is incorrect, you are calling c.clear(). Since the background color is set to lightGrey, c.clear() makes the entire Console light grey! After you call c.clear(), you print the text and prompt the user for the password again. After the user enters something do you redisplay the title page. I'm guessing after you enter the new password and press enter, it displays the title page or is it the fact that it's not displaying it again after that that is the problem?
KL |
|
|
|
|
|
starcraft
|
Posted: Mon Mar 26, 2007 2:28 pm Post subject: Re: Why does the title page disappear after the invaild intry |
|
|
Yep, and now it works PERFECTLY.
|
|
|
|
|
|
|
|