Guest User

Untitled

a guest
Aug 30th, 2018
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.39 KB | None | 0 0
  1. package com.company;
  2.  
  3. import javax.imageio.ImageIO;
  4. import javax.swing.*;
  5. import java.awt.*;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.MouseEvent;
  9. import java.awt.event.MouseListener;
  10. import java.awt.image.BufferedImage;
  11. import java.io.File;
  12. import java.io.IOException;
  13.  
  14. public class Main {
  15.  
  16.     public static void main (String[] args) throws IOException {
  17.     // write your code here
  18.         fly f = new fly();
  19.     }
  20. }
  21. class fly extends JFrame implements MouseListener,ActionListener {
  22.     JLabel label;
  23.     JTextField username;
  24.     ImageIcon img;
  25.     @Override
  26.     public void mouseClicked(MouseEvent e) {
  27.         username.setText("");
  28.     }
  29.  
  30.     @Override
  31.     public void mousePressed(MouseEvent e) {
  32.  
  33.     }
  34.  
  35.     @Override
  36.     public void mouseReleased(MouseEvent e) {
  37.  
  38.     }
  39.  
  40.     @Override
  41.     public void mouseEntered(MouseEvent e) {
  42.  
  43.     }
  44.  
  45.     @Override
  46.     public void mouseExited(MouseEvent e) {
  47.  
  48.     }
  49.  
  50.     fly() throws IOException{
  51.         img = new ImageIcon("Routes.jpg");
  52.         setSize(800,800);
  53.         setTitle("Fly miles");
  54.         setVisible(true);
  55.         GridBagLayout grid = new GridBagLayout();
  56.         JPanel panel1 = new JPanel(grid);
  57.         GridBagConstraints a = new GridBagConstraints();
  58.         label = new JLabel(img);
  59.         JLabel image = new JLabel("Welcome to Fly Miles Airlines!");
  60.         //label.setBackground(Color.BLACK);
  61.         label.setHorizontalAlignment(SwingConstants.CENTER);
  62.         label.setOpaque(true);
  63.         //label.setFont(new Font("Courier New", java.awt.Font.ITALIC, 12));
  64.         a.weightx=0.5;
  65.         a.fill=GridBagConstraints.BOTH;
  66.         a.weighty=0.5;
  67.         image.setHorizontalAlignment(SwingConstants.CENTER);
  68.         panel1.add(image,a);
  69.         a.gridy=1;
  70.         panel1.add(label,a);
  71.         a.weighty=0.1;
  72.         a.fill=GridBagConstraints.BOTH;
  73.         a.gridy=2;
  74.         username = new JTextField("Enter username");
  75.         username.addMouseListener(this);
  76.         JPasswordField password = new JPasswordField("hello");
  77.         password.setSize(new Dimension(100,100));
  78.         panel1.add(username,a);
  79.         a.gridy=3;
  80.         panel1.add(password,a);
  81.         a.weightx=0;
  82.         a.weighty=0;
  83.         a.fill=GridBagConstraints.CENTER;
  84.         JButton login = new JButton("Login");
  85.         a.gridy=4;
  86.         login.addActionListener(this);
  87.         panel1.add(login,a);
  88.         JButton help = new JButton("About us");
  89.         a.gridy=5;
  90.         help.addActionListener(this);
  91.         panel1.add(help,a);
  92.         add(panel1);
  93.         addMouseListener(this);
  94.         setSize(799,799);
  95.  
  96.  
  97.     }
  98.  
  99.     @Override
  100.     public void actionPerformed(ActionEvent e) {
  101.         JLabel details;
  102.         if(e.getActionCommand()=="About us")
  103.         {
  104.             details = new JLabel("This is supposed to help you know about our product");
  105.                    
  106.         }
  107.         else
  108.         {
  109.             details = new JLabel("You logged in!");
  110.         }
  111.         JFrame helppage = new JFrame();
  112.         JPanel a = new JPanel(new GridBagLayout());
  113.         //JLabel details = new JLabel("This is supposed to help you know about our product");
  114.         a.add(details);
  115.         helppage.add(a);
  116.         helppage.setSize(799,799);
  117.         helppage.setVisible(true);
  118.         helppage.setTitle("Help Page");
  119.         helppage.setSize(798,798);
  120.  
  121.  
  122.     }
  123. }
Add Comment
Please, Sign In to add comment