Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.geom.Rectangle2D;
  3. import java.awt.image.*;
  4. import java.io.BufferedReader;
  5. import java.io.File;
  6. import java.io.FileReader;
  7. import java.io.IOException;
  8.  
  9. import javax.imageio.ImageIO;
  10. import javax.swing.*;
  11.  
  12. public class Display extends JPanel{
  13. static JFrame frame = null;
  14. static String location;
  15.  
  16. // Create a constructor method
  17. public Display(){
  18. super();
  19. }
  20.  
  21. public void paintComponent(Graphics g){
  22.  
  23. BufferedImage ap = null;
  24. BufferedImage laptop = null;
  25.  
  26.  
  27. try {
  28. ap = ImageIO.read(new File("/home/arosen/ap.png"));
  29. laptop = ImageIO.read(new File("/home/arosen/laptop.jpg"));
  30. } catch (IOException e) {
  31. // TODO Auto-generated catch block
  32. e.printStackTrace();
  33. }
  34. // g.drawLine(10,10,150,150); // Draw a line from (10,10) to (150,150)
  35. ImageObserver observer = null;
  36. g.drawImage(ap, 10, 10, 55, 60, observer);
  37. g.drawImage(ap, 200, 10, 55, 60, observer);
  38. g.drawImage(ap, 390, 10, 55, 60, observer);
  39. g.drawImage(ap, 580, 10, 55, 60, observer);
  40. g.drawImage(ap, 770, 10, 55, 60, observer);
  41. g.drawImage(laptop, 350, 300, 90, 80, observer);
  42.  
  43. if(location.equals("60100")) {
  44. g.drawLine(30,30,390,300);
  45. }
  46. if(location.equals("60101"))
  47. g.drawLine(200,30,390,300);
  48. if(location.equals("60102"))
  49. g.drawLine(390,30,390,300);
  50. if(location.equals("60103"))
  51. g.drawLine(580,30,390,300);
  52. if(location.equals("60104"))
  53. g.drawLine(770,30,390,300);
  54.  
  55. }
  56.  
  57. public static void main(String arg[]){
  58.  
  59.  
  60. BufferedReader in = null;
  61.  
  62. frame = new JFrame("Wireless connection");
  63. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  64. frame.setSize(850,450);
  65.  
  66. Display panel = new Display();
  67. frame.setContentPane(panel);
  68. frame.setVisible(true);
  69. while (true) {
  70.  
  71.  
  72.  
  73. try {
  74. Thread.sleep(400);
  75. in = new BufferedReader(new FileReader("/tmp/nodes"));
  76. location = in.readLine();
  77. in.close();
  78.  
  79. } catch (InterruptedException e) {
  80. e.printStackTrace();
  81. } catch (IOException e) {
  82. }
  83.  
  84. frame.repaint();
  85.  
  86.  
  87. }
  88.  
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement