Case Study Spring 2016 || Object Oriented Programming

Case Study Spring 2016

Case Study Spring 2016

The answer to the Case Study Spring 2016  is given below:

“a”

package personal.assignment;

import javax.swing.*;

public class secondQuestionA {
public static void main(String[] args) {
JFrame frame = new JFrame(“Login Dialog”);
frame.setSize(250,150);

JPanel panel = new JPanel();
frame.add(panel);

panel.setLayout(null);

JLabel employ = new JLabel(“Employee ID: “);
employ.setBounds(10, 20, 100, 20);
panel.add(employ);

JTextField employT = new JTextField();
employT.setBounds(100, 20, 100, 20);
panel.add(employT);

JLabel password = new JLabel(“Password:”);
password.setBounds(10, 50, 100, 20);
panel.add(password);

JTextField passwordT = new JTextField();
passwordT.setBounds(100,50,100,20);
panel.add(passwordT);

frame.setVisible(true);
}

}

Case Study Spring 2016

 

“b”

package personal.assignment;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class secondQuestionB {
public static void main(String[] args) {
JFrame frame = new JFrame(“DashBoard”);
frame.setSize(500,400);

JPanel panel = new JPanel();
frame.add(panel);

panel.setLayout(null);

JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);

JMenu menu = new JMenu(“View”);
menuBar.add(menu);
JMenuItem byName = new JMenuItem(“View By Name”);
menu.add(byName);
JMenuItem byDepartment = new JMenuItem(“View By Department”);
menu.add(byDepartment);

JMenu menu1 = new JMenu(“Logout”);
menuBar.add(menu1);
JMenuItem log = new JMenuItem(“Logout”);
menu1.add(log);

JLabel name = new JLabel(“Name:”);
name.setBounds(0, 0, 100, 30);
panel.add(name);

JTextField nameT = new JTextField();
nameT.setBounds(200, 0, 287, 30);
panel.add(nameT);

JLabel address = new JLabel(“Address:”);
address.setBounds(0, 30, 100, 30);
panel.add(address);

JTextField addressT = new JTextField();
addressT.setBounds(200, 30, 287, 30);
panel.add(addressT);

JLabel gender = new JLabel(“Gender:”);
gender.setBounds(0,60,100,30);
panel.add(gender);

JRadioButton b1 = new JRadioButton(“Male”);
b1.setBounds(250, 60, 60, 30);
panel.add(b1);

JRadioButton b2 = new JRadioButton(“Female”);
b2.setBounds(320, 60, 80, 30);
panel.add(b2);

ButtonGroup bg = new ButtonGroup();
bg.add(b1);
bg.add(b2);

JLabel departments = new JLabel(“Departments:”);
departments.setBounds(0, 90, 100, 30);
panel.add(departments);

JComboBox combo = new JComboBox();
combo.setBounds(200, 90, 287, 30);
combo.addItem(“Finance”);
combo.addItem(“Admin”);
combo.addItem(“Marketing”);
combo.addItem(“Human Resource”);
panel.add(combo);

JLabel phone = new JLabel(“Phone:”);
phone.setBounds(0, 120, 100, 30);
panel.add(phone);

JTextField phoneT = new JTextField();
phoneT.setBounds(200, 120, 287, 30);
panel.add(phoneT);

JLabel email = new JLabel(“Email:”);
email.setBounds(0, 150, 100, 30);
panel.add(email);

JTextField emailT = new JTextField();
emailT.setBounds(200, 150, 287, 30);
panel.add(emailT);

JButton addB = new JButton(“Add”);
addB.setBounds(90, 190, 90, 30);
panel.add(addB);

JButton resetB = new JButton(“Reset”);
resetB.setBounds(190, 190, 100, 30);
panel.add(resetB);

JButton cancelB = new JButton(“Cancel”);
cancelB.setBounds(300, 190, 100, 30);
panel.add(cancelB);

addB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialog dialog = new JDialog(frame,”Details”);
dialog.setSize(100,200);

JPanel panel1 = new JPanel();
JLabel texts = new JLabel();
JLabel text2 = new JLabel();
JLabel text3 = new JLabel();
JLabel text4 = new JLabel();

texts.setText(nameT.getText().toString());
text2.setText(addressT.getText().toString());
text3.setText(phoneT.getText().toString());
text4.setText(emailT.getText().toString());

panel1.add(texts);
panel1.add(text2);
panel1.add(text3);
panel1.add(text4);
dialog.add(panel1);
dialog.setVisible(true);

JOptionPane.showConfirmDialog(frame,”Do you want to continue?”);
}
});

frame.setVisible(true);
}

}

Case Study Spring 2016

 

You may also like Pokhara University || Spring 2016 || Object Oriented Programming

Do like our page Facebook

Be the first to comment

Leave a Reply

Your email address will not be published.


*