Guest User

Untitled

a guest
Jan 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. TextField yourTextField; // <-- global variable (initialized somewhere)
  2.  
  3. public void keyPressed(KeyEvent e) {
  4. // ... all the other stuff
  5.  
  6. textField.setText( Double.toString(velx) );
  7. }
  8.  
  9. void updateUI() {
  10. // ... whatever else needs doing
  11.  
  12. if( !textField.getText().equals( Double.toString(velx) ) ) {
  13. textField.setText( Double.toString(velx) );
  14. }
  15. }
  16.  
  17. void mainLoop() {
  18. updateUI()
  19. }
  20.  
  21. boolean velx_changed = false;
  22.  
  23. velx++;
  24. velx_changed = true;
  25.  
  26. void mainLoop() {
  27. if( velx_changed ) {
  28. textField.setText( Double.toString(velx) );
  29. }
  30. }
Add Comment
Please, Sign In to add comment