Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- public class Main {
- public static void main (String[] args) throws IOException {
- // write your code here
- fly f = new fly();
- }
- }
- class fly extends JFrame implements MouseListener,ActionListener {
- JLabel label;
- JTextField username;
- ImageIcon img;
- @Override
- public void mouseClicked(MouseEvent e) {
- username.setText("");
- }
- @Override
- public void mousePressed(MouseEvent e) {
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- }
- @Override
- public void mouseExited(MouseEvent e) {
- }
- fly() throws IOException{
- img = new ImageIcon("Routes.jpg");
- setSize(800,800);
- setTitle("Fly miles");
- setVisible(true);
- GridBagLayout grid = new GridBagLayout();
- JPanel panel1 = new JPanel(grid);
- GridBagConstraints a = new GridBagConstraints();
- label = new JLabel(img);
- JLabel image = new JLabel("Welcome to Fly Miles Airlines!");
- //label.setBackground(Color.BLACK);
- label.setHorizontalAlignment(SwingConstants.CENTER);
- label.setOpaque(true);
- //label.setFont(new Font("Courier New", java.awt.Font.ITALIC, 12));
- a.weightx=0.5;
- a.fill=GridBagConstraints.BOTH;
- a.weighty=0.5;
- image.setHorizontalAlignment(SwingConstants.CENTER);
- panel1.add(image,a);
- a.gridy=1;
- panel1.add(label,a);
- a.weighty=0.1;
- a.fill=GridBagConstraints.BOTH;
- a.gridy=2;
- username = new JTextField("Enter username");
- username.addMouseListener(this);
- JPasswordField password = new JPasswordField("hello");
- password.setSize(new Dimension(100,100));
- panel1.add(username,a);
- a.gridy=3;
- panel1.add(password,a);
- a.weightx=0;
- a.weighty=0;
- a.fill=GridBagConstraints.CENTER;
- JButton login = new JButton("Login");
- a.gridy=4;
- login.addActionListener(this);
- panel1.add(login,a);
- JButton help = new JButton("About us");
- a.gridy=5;
- help.addActionListener(this);
- panel1.add(help,a);
- add(panel1);
- addMouseListener(this);
- setSize(799,799);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- JLabel details;
- if(e.getActionCommand()=="About us")
- {
- details = new JLabel("This is supposed to help you know about our product");
- }
- else
- {
- details = new JLabel("You logged in!");
- }
- JFrame helppage = new JFrame();
- JPanel a = new JPanel(new GridBagLayout());
- //JLabel details = new JLabel("This is supposed to help you know about our product");
- a.add(details);
- helppage.add(a);
- helppage.setSize(799,799);
- helppage.setVisible(true);
- helppage.setTitle("Help Page");
- helppage.setSize(798,798);
- }
- }
Add Comment
Please, Sign In to add comment