/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package guiapplication;
import java.awt.*;
import java.awt.event.*;
/**
* @author adminuser
*/
public class GUIApplication implements ActionListener{
/**
* @param args the command line arguments
*/
Frame f;
Label lblClass;
TextField txtInput;
CheckboxGroup chkShift;
Checkbox chkMor;
Checkbox chkAft;
Choice chCities;
Button btnRegister;
Label lblMsg;
TextArea txtArea;
Button btnClose;
GUIApplication(){
f = new Frame("First Screen");
lblClass = new Label("Class");
txtInput = new TextField();
txtArea = new TextArea();
lblMsg = new Label("Message will appear here");
Checkbox chkSE = new Checkbox("Software Engineering");
Checkbox chkCS = new Checkbox("Computer Science");
Checkbox chkEE = new Checkbox("Electrical Engineering");
chkShift = new CheckboxGroup();
chkMor = new Checkbox("Morning", chkShift, true);
chkAft = new Checkbox("Afternoon", chkShift, false);
chCities = new Choice();
chCities.add("Islamabad");
chCities.add("Peshawar");
chCities.add("Multan");
chCities.add("Quetta");
chCities.add("Rawalpindi");
btnRegister = new Button("Register");
btnRegister.setBackground(Color.yellow);
btnRegister.addActionListener(this);
btnClose = new Button("Close");
btnClose.setBackground(Color.GREEN);
btnClose.addActionListener(this);
lblClass.setBounds(20, 40, 40, 25);
txtInput.setBounds(60, 40, 150, 25);
txtArea.setBounds(20, 80, 200, 150);
chkSE.setBounds(20, 280, 150, 25);
chkCS.setBounds(20, 310, 150, 25);
chkEE.setBounds(20, 340, 150, 25);
chkMor.setBounds(20, 370, 150, 25);
chkAft.setBounds(20, 400, 150, 25);
chCities.setBounds(20, 440, 150, 25);
btnRegister.setBounds(20, 470, 100, 30);
btnClose.setBounds(140, 470, 100, 30);
lblMsg.setBounds(20, 550, 540, 25);
f.setSize(600, 800);
f.setLayout(null);
f.setVisible(true);
f.add(lblClass);
f.add(txtInput);
f.add(txtArea);
f.add(chkSE);
f.add(chkCS);
f.add(chkEE);
f.add(chkMor);
f.add(chkAft);
f.add(chCities);
f.add(btnRegister);
f.add(lblMsg);
f.add(btnClose);
@Override
public void actionPerformed(ActionEvent e){
if (e.getSource().equals(btnRegister)) {
String classtext;
String shift;
String city;
classtext = txtInput.getText();
if (chkMor.getState() == true) {
shift = "Morning Shift";
else{
shift = "Afternoon Shift";
city = chCities.getSelectedItem();
int r = 55;
txtArea.setText(classtext + " " + shift + " " + String.valueOf(r));
else if (e.getSource().equals(btnClose)){
// do what u want on Close
f.dispose();
}
public static void main(String[] args) {
// TODO code application logic here
GUIApplication gui = new GUIApplication();