BIT202344995 Assignment 2
BIT202344995 Assignment 2
DATE: 09/04/24
BIT/2023/44995
1. Using GUI, write a program code that uses four checkboxes for selecting four
units in BSC IT of your choice.
import javax.swing.*;
import java.awt.event.*;
public BscIT() {
setSize(300, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
selectButton.addActionListener(this);
panel.add(unit1Checkbox);
panel.add(unit2Checkbox);
panel.add(unit3Checkbox);
panel.add(unit4Checkbox);
panel.add(selectButton);
add(panel);
BIT/2023/44995
setVisible(true);
if (e.getSource() == selectButton) {
if (unit1Checkbox.isSelected()) {
if (unit2Checkbox.isSelected()) {
if (unit3Checkbox.isSelected()) {
if (unit4Checkbox.isSelected()) {
JOptionPane.showMessageDialog(this, selectedUnits);
SwingUtilities.invokeLater(new Runnable() {
new BscIT();
});
BIT/2023/44995
2. Write a simple MIDlet application to display your name and Registration
number on the screen.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public Mydetails() {
infoForm.append(nameItem);
infoForm.append(regNumberItem);
display = Display.getDisplay(this);
display.setCurrent(infoForm);
BIT/2023/44995
3. Write a MIdlet application to create a list of all the subjects pursued in your
year of study.
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public Subjects() {
subjectList.append("TQM", null);
display.setCurrent(subjectList);
BIT/2023/44995
4. Write a MIDlet application with the following functionalities.
a. Add record
b. Delete record
c. Replace record
This MIDlet application consists of a form with a text field (recordField) to input records and a list
(recordList) to display the records. It provides functionalities to add, delete, and replace records. The
records are stored in a vector (records). When a record is added, deleted, or replaced, the list of records
is updated accordingly by calling the updateRecordList() method.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Vector;
public RecordManagerMIDlet() {
BIT/2023/44995
recordList = new List("Records", List.IMPLICIT);
mainForm.append(recordField);
mainForm.addCommand(addCommand);
mainForm.addCommand(deleteCommand);
mainForm.addCommand(replaceCommand);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener(this);
display = Display.getDisplay(this);
display.setCurrent(mainForm);
if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();
} else if (c == addCommand) {
addRecord(newRecord);
recordField.setString("");
} else if (c == deleteCommand) {
records.removeElementAt(selectedIndex);
updateRecordList();
BIT/2023/44995
}
} else if (c == replaceCommand) {
records.setElementAt(updatedRecord, selectedIndex);
updateRecordList();
recordField.setString("");
if (!newRecord.equals("")) {
records.addElement(newRecord);
updateRecordList();
recordList.deleteAll();
display.setCurrent(recordList);
BIT/2023/44995