🔒 Closed Java how to cencor user input and detect special character on a string

Status
Not open for further replies.

Nero Swallowtail

Honorary Poster
guys help! paano po ba ung ganon? ung pag ka nag i input is user sa mismong scanner e napapalitan ng asterisk ung iniinput nya sa mismong scanner? or kahit kapag dun nalang sa mismong compiler, kapag prinint ung inenter na password e magiging asterisk lahat? tsaka kung pano na din gagawa ng User Defined Exception kapag ka my Special character na naka sulat, kahit formatting nalang po ibigay nyo, wala po kase sa handout hehehehe ty
 
[CODE title="baka makatulong"]public class Test {

public static void main(final String[] args) throws Exception {
ConsoleReader reader = new ConsoleReader();
Character mask = '*';
String line = null;
do {
line = reader.readLine("Enter Password(blank pwd to exit)> ", mask);
System.out.println("Got password: " + line);
} while (line != null && line.length() > 0);
}

}[/CODE]
 
[XX='Nero Swallowtail, c: 1117526, m: 1752019'][/XX] Next time be precise and specific on your thread titles, sabi mo din kase Java sa thread title mo eh misleading ka tuloy.
 
[XX='PHC rem, c: 1117733, m: 765534'][/XX] ay sorry, scanner ba yung "console?" sanay kase ako na scan lang pinapangalang sa scanner ko hehe
 
[XX='PHC rem, c: 1117733, m: 765534'][/XX] diba kase sa c# my Console.Readkey akala ko ung Console.readPassword parang other scanner sa c# e HAHAHA
 
[XX='Nero Swallowtail, c: 1118452, m: 1752019'][/XX] may mga similarities din kasi yong java at c# minsan nalilito din ako.
 
JAVA:
set mo lang yung echoCharacter ng jPasswordField ng ganito:
jPasswordField.setEchoChar((char)0) - Makikita mo yung characters sa textfield.
jPasswordField.setEchoChar('\u50cf') - Magiging small squares yung characters sa textfield. Palitan mo lang yung '\u50cf' sa kung anong gusto mong character. Yung * yata ay '\u20cf'. di ko lang sure.😁😁
 
Status
Not open for further replies.

About this Thread

  • 15
    Replies
  • 617
    Views
  • 7
    Participants
Last reply from:
Noctivagant

Trending Topics

Online now

Members online
1,194
Guests online
1,148
Total visitors
2,342

Forum statistics

Threads
2,284,765
Posts
29,025,605
Members
1,220,106
Latest member
unontupay09
Back
Top