| import java.awt.BorderLayout; |
| import java.awt.Color; |
| import java.awt.Dimension; |
| import java.awt.Font; |
| import java.awt.Graphics2D; |
| import java.awt.Image; |
| import java.awt.event.ActionEvent; |
| import java.awt.event.ActionListener; |
| import java.awt.event.KeyEvent; |
| import java.io.IOException; |
| import javax.swing.ImageIcon; |
| import javax.swing.JButton; |
| import javax.swing.JDesktopPane; |
| import javax.swing.JFileChooser; |
| import javax.swing.JFrame; |
| import javax.swing.JInternalFrame; |
| import javax.swing.JLabel; |
| import javax.swing.JPanel; |
| import javax.swing.JTabbedPane; |
| import javax.swing.JTextArea; |
| import javax.swing.JTextField; |
| import javax.swing.filechooser.FileSystemView; |
| import javax.swing.JOptionPane; |
| import java.awt.image.BufferStrategy; |
| import java.awt.font.*; |
| |
| public class Fire |
| { |
| public static void main(String[] args) |
| { |
| JFrame f = new JFrame(); |
| int temp = 950; |
| int humidity = 15; |
| int loc_x = 23; |
| int loc_y = 45; |
| f.setTitle("My App"); |
| //set background |
| BufferStrategy bufferStrategy; |
| |
| // Graphics2D graphic = (Graphics2D) bufferStrategy.getDrawGraphics(); |
| // graphic.setBackground(Color.GREEN); |
| // graphic.fillRect(0, 0, 400, 700); |
| |
| f.setPreferredSize(new Dimension(400,750)); |
| JPanel last_panel = new JPanel(); |
| JPanel panel = new JPanel(); |
| JOptionPane popup = new JOptionPane(); |
| panel.setLayout(new BorderLayout()); |
| JPanel btn_panel = new JPanel(); |
| //panel.setBackground(Color.red); |
| JPanel firstPanel = new JPanel(); |
| |
| JTextArea Textarea; |
| |
| Textarea = new JTextArea(50,50); |
| Textarea.setEditable(true); |
| Textarea.setLineWrap(true); |
| Textarea.append("The Authorities Have Been Contacted \n"); |
| Textarea.append("Warning! Fire hazard nearby. \nWARN OTHERS IMMEDIATELY \n" ); |
| Textarea.append("Temperature: " + temp + " F\n"); |
| Textarea.append("Humidity: " + humidity+" %\n"); |
| Textarea.append("Location: " + loc_x + ", " + loc_y+"\n"); |
| Textarea.setBackground(Color.black); |
| Textarea.setFont(new Font("Verdana", Font.BOLD, 16)); |
| Textarea.setForeground(Color.RED); |
| JButton btn1 = new JButton ("Things to do"); |
| |
| panel.add(Textarea,BorderLayout.NORTH); |
| panel.setPreferredSize(new Dimension(350,150)); |
| btn_panel.add(btn1, BorderLayout.EAST); |
| last_panel.add(panel, BorderLayout.NORTH); |
| |
| //picturer |
| ImageIcon image; |
| |
| JPanel Image_pal = new JPanel(new BorderLayout()); |
| JLabel mapLabel; |
| image = new ImageIcon("Fires.png"); |
| Image scaleImage = image.getImage().getScaledInstance(380,500,Image.SCALE_DEFAULT); |
| image = new ImageIcon(scaleImage); |
| mapLabel = new JLabel(image); |
| |
| Image_pal.add(mapLabel,BorderLayout.CENTER); |
| last_panel.add(mapLabel,BorderLayout.SOUTH); |
| last_panel.add(btn_panel,BorderLayout.SOUTH); |
| |
| class MyListerner implements ActionListener |
| { |
| @Override |
| public void actionPerformed(ActionEvent e) |
| { |
| if (e.getSource()== btn1) |
| { |
| popup.showMessageDialog(btn1, " Things to do immediately:" +"\n" + |
| "-Let's people near you know there is a growing WILD FIRE in the Area ! "+ "\n" |
| +"-Let fire hazard apartment know about it Call 911" +"\n" |
| +"-Stay away from the fire and get somewhere safe"); |
| } |
| } |
| }; |
| |
| MyListerner listener1 = new MyListerner(); |
| |
| btn1.addActionListener(listener1); |
| last_panel.setBackground(new Color(107,106,104)); |
| f.add(last_panel); |
| f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| f.pack(); |
| f.setVisible(true); |
| } |
| } |