Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. class SwingUI extends JFrame implements IUpdater{
  2.  
  3. @Override
  4. public void askPermission(String str) {
  5. int i = JOptionPane.showConfirmDialog(this, str);
  6. // (?)Send i back
  7. }
  8.  
  9. }
  10.  
  11. class Connection implements Runnable{
  12.  
  13. IUpdater updater;
  14.  
  15. Connection(IUpdater u){updater = u;}
  16.  
  17. @Override
  18. public void run() {
  19. String command = "download_file"; //=getCommand(); from a socket
  20. if(command.equals("download_file")){
  21.  
  22. SwingUtilities.invokeLater(new Runnable() {
  23.  
  24. @Override
  25. public void run() {
  26. updater.askPermition(command);
  27. }
  28. });
  29. // (?)wait until user answers
  30. // int answ = getAnswer();
  31. // if answ == OK
  32. System.out.println("Sending_File");
  33. // if answ == DENY
  34. //System.out.println("Denied");
  35. }
  36. }
  37.  
  38. }
  39.  
  40.  
  41.  
  42. interface IUpdater{
  43. void askPermission(String str);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement