Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1.  
  2. //fjerner default "brukernavn" tekst ved trykk
  3. userText.addFocusListener(new FocusListener(){
  4. @Override
  5. public void focusGained(FocusEvent e){
  6. if(userText.getText().trim().equals("Brukernavn"))
  7. userText.setText("");
  8. }
  9.  
  10.  
  11. public void focusLost (FocusEvent e) {
  12. if (userText.getText().trim().equals(""))
  13. userText.setText("Brukernavn");
  14. }
  15.  
  16. });
  17.  
  18.  
  19. //legger til passordinput
  20. passwordText = new JPasswordField(20);
  21. passwordText.setBounds(105, 220, 160, 27);
  22. passwordText.setText("Passord");
  23.  
  24. //fjerner default passord ved trykk
  25. passwordText.addFocusListener(new FocusListener(){
  26. @Override
  27. public void focusGained(FocusEvent e){
  28. if(new String(passwordText.getPassword()).trim().equals("Passord")) {
  29. passwordText.setText("");
  30. }
  31. }
  32. public void focusLost(FocusEvent e) {
  33. if (passwordText.getPassword().length == 0)
  34. passwordText.setText("Passord");
  35. }
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement