|
| 1 | + |
| 2 | +package quiz.application; |
| 3 | + |
| 4 | +import javax.swing.*; |
| 5 | +import java.awt.*; |
| 6 | +import java.awt.event.*; |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +public class Login extends JFrame implements ActionListener { |
| 11 | + |
| 12 | + JButton rules, back; |
| 13 | + JTextField tfname; |
| 14 | + Login() { |
| 15 | + getContentPane().setBackground(Color.WHITE); |
| 16 | + setLayout(null); |
| 17 | + |
| 18 | + ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/login.jpeg")); |
| 19 | + JLabel image = new JLabel(i1); |
| 20 | + add(image); |
| 21 | + |
| 22 | + JLabel heading = new JLabel("QUIZ UP"); |
| 23 | + heading.setBounds(810, 60, 300, 45); |
| 24 | + heading.setFont(new Font("Consolas", Font.BOLD, 40)); |
| 25 | + heading.setForeground(Color.DARK_GRAY); |
| 26 | + add(heading); |
| 27 | + |
| 28 | + JLabel name = new JLabel("Enter Your Name"); |
| 29 | + name.setBounds(810, 150, 300, 20); |
| 30 | + name.setFont(new Font("Mongolian Baiti", Font.BOLD, 20)); |
| 31 | + name.setForeground(Color.DARK_GRAY); |
| 32 | + add(name); |
| 33 | + |
| 34 | + tfname = new JTextField(); |
| 35 | + tfname.setBounds(735, 200, 300, 25); |
| 36 | + tfname.setFont(new Font("Times New Roman", Font.BOLD, 20)); |
| 37 | + add(tfname); |
| 38 | + |
| 39 | + rules = new JButton("Proceed"); |
| 40 | + rules.setBounds(735, 270, 120, 25); |
| 41 | + add(rules); |
| 42 | + rules.setBackground(new Color(0,0,0)); |
| 43 | + rules.addActionListener(this); |
| 44 | + rules.setForeground(Color.WHITE); |
| 45 | + |
| 46 | + back = new JButton("Back"); |
| 47 | + back.setBounds(915, 270, 120, 25); |
| 48 | + add(back); |
| 49 | + back.setBackground(new Color(0,0,0)); |
| 50 | + back.addActionListener(this); |
| 51 | + back.setForeground(Color.WHITE); |
| 52 | + |
| 53 | + image.setBounds(0, 0, 600, 500); |
| 54 | + setSize(1200, 500); |
| 55 | + setLocation(200, 150); |
| 56 | + setVisible(true); |
| 57 | + } |
| 58 | + |
| 59 | + public void actionPerformed(ActionEvent ae){ |
| 60 | + if (ae.getSource() == rules) { |
| 61 | + String name = tfname.getText(); |
| 62 | + setVisible(false); |
| 63 | + new Rules(name); |
| 64 | + }else if (ae.getSource() == back) { |
| 65 | + setVisible(false); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + public static void main(String args[]) { |
| 70 | + Login login = new Login(); |
| 71 | + |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + |
| 76 | + |
0 commit comments