Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.geom.Rectangle2D;
- import java.awt.image.*;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- public class Display extends JPanel{
- static JFrame frame = null;
- static String location;
- // Create a constructor method
- public Display(){
- super();
- }
- public void paintComponent(Graphics g){
- BufferedImage ap = null;
- BufferedImage laptop = null;
- try {
- ap = ImageIO.read(new File("/home/arosen/ap.png"));
- laptop = ImageIO.read(new File("/home/arosen/laptop.jpg"));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // g.drawLine(10,10,150,150); // Draw a line from (10,10) to (150,150)
- ImageObserver observer = null;
- g.drawImage(ap, 10, 10, 55, 60, observer);
- g.drawImage(ap, 200, 10, 55, 60, observer);
- g.drawImage(ap, 390, 10, 55, 60, observer);
- g.drawImage(ap, 580, 10, 55, 60, observer);
- g.drawImage(ap, 770, 10, 55, 60, observer);
- g.drawImage(laptop, 350, 300, 90, 80, observer);
- if(location.equals("60100")) {
- g.drawLine(30,30,390,300);
- }
- if(location.equals("60101"))
- g.drawLine(200,30,390,300);
- if(location.equals("60102"))
- g.drawLine(390,30,390,300);
- if(location.equals("60103"))
- g.drawLine(580,30,390,300);
- if(location.equals("60104"))
- g.drawLine(770,30,390,300);
- }
- public static void main(String arg[]){
- BufferedReader in = null;
- frame = new JFrame("Wireless connection");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(850,450);
- Display panel = new Display();
- frame.setContentPane(panel);
- frame.setVisible(true);
- while (true) {
- try {
- Thread.sleep(400);
- in = new BufferedReader(new FileReader("/tmp/nodes"));
- location = in.readLine();
- in.close();
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- }
- frame.repaint();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement