Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: A simple BOX in Console! Please Help!

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    6
    My Mood
    Where
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default A simple BOX in Console! Please Help!

    Hi, I'm a Freshmen BSIT College Student, Learning Very Basic in JAVA
    Can someone help me or give me the code on how to make a box (password field box thingy)
    where you can input the password INSIDE the box (that is displayed already)

    For Example: (Output)



     
    // The box is displayed already even though there's no yet input from the user
                                             __________________________
                                              |                         |
    Please Enter your Password           |   /*this is where you*/ |
                                              | /*enter the password*/ |
                                              |________________________|

    Here is my code snippet (on the log in) anyway: I would like to replace the design

     
        	//Username and Password Login
        	 do
        	   {
         	 System.out.print("\n");
    	     System.out.print("\n");
    		 System.out.println("\t   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    		 System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    		 System.out.println("\t   xx<>                                                    <>xx");
    		 System.out.println("\t   xx<>      [E][N][T][E][R]  [U][S][E][R][N][A][M][E]     <>xx");
    		 System.out.println("\t   xx<>                                                    <>xx");
    		 System.out.print("\t\t\t\t    ");
        	 username = (br.readLine());              
    	  	 System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx<>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<>xx");
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx<>      [E][N][T][E][R] [P][A][S][S][W][O][R][D]      <>xx");
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.print("\t\t\t\t    ");
    	     password = br.readLine(); 
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    	     System.out.println("\t   xx<>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<>xx");
     
    	    //if username and password is correct
    	     if(username.equals("123")&&password.equals("321"))
    			{
    			am=3;
    		 System.out.println("          ");	
        	 System.out.println("          ");  	
    		 System.out.println("\t   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    		 System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    		 System.out.println("\t   xx<>                                                    <>xx");
    		 System.out.println("\t   xx<>     [L][O][G][I][N] [S][U][C][C][E][S][F][U][L]    <>xx");
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    	     System.out.println("\t   xx<>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<>xx")
     
    			}else
    			{
     
    	      int dispattm = attempts - 1;
     
    	     System.out.println("          ");	
        	 System.out.println("          ");  	
    		 System.out.println("\t   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    		 System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    		 System.out.println("\t   xx<>                                                    <>xx");
    		 System.out.println("\t   xx<>   [I][N][V][A][L][I][D] [U][S][E][R][N][A][M][E]   <>xx");
    	     System.out.println("\t   xx<>            [O][R] [P][A][S][S][W][O][R][D]         <>xx");
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx<>             You have "+dispattm+" attempt(s) left             <>xx");
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    	     System.out.println("\t   xx<>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<>xx");
     
    	       attempts--;
    	       if(attempts == 0)
    	       	  {
    	     System.out.println("          ");	
        	 System.out.println("          ");  	
    		 System.out.println("\t   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    		 System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    		 System.out.println("\t   xx<>                                                    <>xx");
    		 System.out.println("\t   xx<>    Sorry, You have reached the maximum attempts!   <>xx");
    		 System.out.println("\t   xx<>               The program will now exit            <>xx");
    	     System.out.println("\t   xx<>                                                    <>xx");
    	     System.out.println("\t   xx++++++++++++++++++++++++++++++++++++++++++++++++++++++++xx");
    	     System.out.println("\t   xx<>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<>xx");
    	       	break; 	
     
    	       	  }
    	       	  }
     
     
     
    	    	}while(attempts!=3);
     
     	}
     }


    Thanks in Advance for Help, Sorry I'm new to this forum, I apologize, if I posted this in the wrong forum
    Last edited by rainexel; September 26th, 2011 at 10:06 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: A simple BOX in Console! Please Help!

    I'm not really sure what your question is. If you can type out what you want it to look like, why can't you print that out?

    If you want to print something below where the user types input, then that's a different story. Not sure Java can even do that.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    rainexel (September 26th, 2011)

  4. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    6
    My Mood
    Where
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: A simple BOX in Console! Please Help!

    Oh, I understand So it is not possible in the simple console.
    Thanks

    By the way, Another question

    How to display the password inputted by the user as ASTERISKS ****

  5. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: A simple BOX in Console! Please Help!

    I definitely don't think writing inside the box like that would be possible.. All I can think of is printing the first top of the box, prompting for user input, then printing the bottom half.

    I don't think there is any way to display asterixis in the console as the password is being typed either...
    You could print the password to the console like that, but not manipulate the input as it's being typed.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  6. The Following User Says Thank You to JavaPF For This Useful Post:

    rainexel (September 26th, 2011)

  7. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    6
    My Mood
    Where
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: A simple BOX in Console! Please Help!

    And yeah, I searched Google and I found nothing about password masking displaying on console in Java

    Thanks for the help and thank you for the fast response.

    Thread Solved Thanks!

  8. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: A simple BOX in Console! Please Help!

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. The Following User Says Thank You to KevinWorkman For This Useful Post:

    JavaPF (September 26th, 2011)

  10. #7
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: A simple BOX in Console! Please Help!

    Quote Originally Posted by KevinWorkman View Post
    That's a very interesting read. Thanks for that link.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  11. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: A simple BOX in Console! Please Help!

    Quote Originally Posted by rainexel View Post
    And yeah, I searched Google and I found nothing about password masking displaying on console in Java
    Are you serious? Googling "java command prompt password" got back tons of results, including the one above.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  12. #9
    Junior Member
    Join Date
    Sep 2011
    Posts
    6
    My Mood
    Where
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: A simple BOX in Console! Please Help!

    No, I mean nothing helped :'> results are complicated, can't understand much for a beginner like me

  13. #10
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: A simple BOX in Console! Please Help!

    Quote Originally Posted by rainexel View Post
    No, I mean nothing helped :'> results are complicated, can't understand much for a beginner like me
    Well, if there's something you don't understand, you could always create an SSCCE from the results and ask a more specific question here.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. From Console to GUI : problem !!
    By hexwind in forum AWT / Java Swing
    Replies: 33
    Last Post: August 20th, 2011, 10:50 PM
  2. Console box with scanner?
    By Hallowed in forum Java Theory & Questions
    Replies: 1
    Last Post: May 26th, 2011, 12:50 AM
  3. How do i run this Accounting console app?
    By mirzahat in forum AWT / Java Swing
    Replies: 2
    Last Post: November 16th, 2010, 12:22 AM
  4. Console Application - How to run it?
    By mirzahat in forum AWT / Java Swing
    Replies: 3
    Last Post: November 16th, 2010, 12:21 AM
  5. simple java console program, need help recalling commands
    By zero0000000 in forum Java Theory & Questions
    Replies: 2
    Last Post: October 22nd, 2010, 05:47 AM