SHARE
TWEET

Untitled

a guest Nov 11th, 2019 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package hello_world;
  7.  
  8. /**
  9.  *
  10.  * @author YannErv
  11.  */
  12. /*
  13.  * To change this license header, choose License Headers in Project Properties.
  14.  * To change this template file, choose Tools | Templates
  15.  * and open the template in the editor.
  16.  */
  17.  
  18. import java.awt.*;
  19. import javax.swing.*;
  20. import java.awt.Event.*;
  21. import java.awt.event.ActionEvent;
  22. import java.awt.event.ActionListener;
  23. import java.awt.event.ItemEvent;
  24. import java.awt.event.ItemListener;
  25. import java.awt.event.TextEvent;
  26. import java.awt.event.TextListener;
  27. /**
  28.  *
  29.  * @author YannErv
  30.  */
  31. public class Menu extends JFrame implements ItemListener, ActionListener{
  32.     //field
  33.     JFrame f = new JFrame();
  34.     TextField tf1 = new TextField(" ",11);
  35.     TextField tf2 = new TextField(" ",11);
  36.     Checkbox cb1 = new Checkbox("register");
  37.     Checkbox cb2 = new Checkbox("search by id");
  38.     Checkbox cb3 = new Checkbox("list");
  39.     Checkbox cb4 = new Checkbox("number");
  40.     Checkbox cb5 = new Checkbox("exit");
  41.    
  42.    
  43.     Button b = new Button("continue");
  44.    
  45.     //method
  46.    
  47.     //const
  48.     Menu(){
  49.       f.setTitle("Employment Management System Menu");
  50.       f.setBounds(10, 10, 900, 600);
  51.       f.setForeground(Color.gray);
  52.       // grid layout to partition the number of columna nd rows
  53.      
  54.       GridLayout g1 = new GridLayout(3, 1);
  55.       //FlowLayout layout = new FlowLayout(FlowLayout.LEFT, 1, 3);
  56.       //BorderLayout layout = new BorderLayout(10, 10);
  57.       f.setLayout(g1);
  58.       //f.setLayout(layout);
  59.      
  60.       //top block
  61.       Font font= new Font("Times New Roman", Font.BOLD, 12);
  62.       Label l0 = new Label("Employment Management System", Label.CENTER);//declare the label
  63.       l0.setForeground(Color.blue);
  64.       l0.setFont(new Font("Times New Roman", Font.ITALIC, 32));
  65.       f.add(l0);
  66.      
  67.      
  68.      
  69.       //middle block
  70.       //f.add("North", l0);
  71.      // new label
  72.     cb1.addItemListener(this);
  73.     cb2.addItemListener(this);
  74.     cb3.addItemListener(this);
  75.     cb4.addItemListener(this);
  76.     cb5.addItemListener(this);
  77.        
  78.     b.addActionListener(this);
  79.    
  80.     Panel p1 = new Panel();
  81.     p1.add(cb1);p1.add(cb2);p1.add(cb3);p1.add(cb4);p1.add(cb5);p1.add(b);
  82.     f.add(p1);
  83.    
  84.        //bottom block
  85.       Label l3 = new Label("abc.com", Label.CENTER);
  86.       l3.setForeground(Color.red);
  87.       l3.setFont(new Font("Times New Roman", Font.ITALIC, 24));
  88.       f.add(l3);
  89.      
  90.       f.setVisible(true);
  91.       // f.add(pm);
  92.      
  93.     }//cons
  94.  
  95.    public void textValueChanged(TextEvent te){
  96.        
  97.    }
  98.  
  99.     @Override
  100.     public void actionPerformed(ActionEvent e) {
  101.         String str1 = e.getActionCommand();//button name
  102.         String id = tf1.getText();
  103.         String pw = tf2.getText();
  104.         if(str1.equals("enter")){
  105.            
  106.        
  107.         System.out.println("buton name: "+str1);
  108.         System.out.println("username: "+id);
  109.         System.out.println("password: "+pw);
  110.         }
  111.         //tmmp
  112.     }//ap
  113.  
  114.     @Override
  115.     public void itemStateChanged(ItemEvent e) {
  116.        
  117.     }
  118.    
  119.    
  120.    
  121.    
  122. }//class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top