From d4f5bca5c5f6c5f728a7f48747cf7810cc1e8cfe Mon Sep 17 00:00:00 2001 From: Alrott SlimRG <39348033+SlimRG@users.noreply.github.com> Date: Mon, 14 Jan 2019 19:46:49 +0300 Subject: [PATCH] FocusFix && PasswordFix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Перезалил с небольшими исправлениями --- src/net/launcher/components/Frame.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/net/launcher/components/Frame.java b/src/net/launcher/components/Frame.java index b6d8b42..8bf53db 100644 --- a/src/net/launcher/components/Frame.java +++ b/src/net/launcher/components/Frame.java @@ -153,14 +153,15 @@ public Frame() { login.setText(Message.Login); login.addActionListener(this); login.addFocusListener(this); + password.setText(Message.Password); password.setEchoChar('*'); passwordReg.setEchoChar('*'); password2Reg.setEchoChar('*'); password.addActionListener(this); password.addFocusListener(this); - Focus.setInitialFocus(this, password); + Focus.setInitialFocus(this, login); String pass = getPropertyString("password"); - if (pass == null || pass.equals("-")) { + if (pass == null || pass.equals("-") || pass == Message.Login) { b1 = true; b2 = false; } @@ -446,7 +447,8 @@ public void run() { token = "null"; login.setEditable(true); login.setText(Message.Login); - password.setText(""); + password.setText(Message.Password); + password.setEchoChar((char)0); repaint(); } @@ -556,11 +558,21 @@ public void run() { public void focusGained(FocusEvent e) { if (e.getSource() == login && login.getText().equals(Message.Login)) login.setText(empty); + String Pass = new String(password.getPassword()); + if (e.getSource() == password &&Pass.equals(Message.Password)){ + password.setText(empty); + password.setEchoChar('*'); + } } public void focusLost(FocusEvent e) { if (e.getSource() == login && login.getText().equals(empty)) login.setText(Message.Login); + String Pass = new String(password.getPassword()); + if (e.getSource() == password &&Pass.equals(empty)){ + password.setText(Message.Password); + password.setEchoChar((char)0); + } } public void setUpdateComp(String version) { @@ -687,4 +699,4 @@ public void setError(String s) { panel.setErrorState(s); addFrameComp(); } -} \ No newline at end of file +}