Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Why does the title page disappear after the invaild intry
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
starcraft




PostPosted: 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
Sponsor
sponsor
PaulButler




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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.

Very Happy
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: