ASSIGNMENT
#2
SUBJECT: ADV-OOP 2
SUBMITTED TO: SIR SHERAZ HASAN
SUBMITTED BY: ESHA SAFDAR
CLASS CODE: CU-576-2017
DATED: 27 MAY 2019
CODE:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class ListDemo extends JFrame {
private JPanel contentPane;
public static void main(String[] args) {
[Link](new Runnable() {
public void run() {
try {
ListDemo frame = new ListDemo();
[Link](true);
} catch (Exception e) {
[Link]();
}
}
});
public ListDemo() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
[Link](new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
[Link](null);
JComboBox List1 = new JComboBox();
[Link](new DefaultComboBoxModel(new String[] {"Beige", "Teal",
"Black", "Purple", "Azure", "Russet", "Turquoise"}));
[Link](71, 72, 103, 20);
[Link](List1);
JComboBox List2 = new JComboBox();
[Link](206, 72, 107, 20);
[Link](List2);
JButton Add1 = new JButton("Add Item");
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e)
{
[Link]("Beige",0);
[Link]("Item added");
});
[Link](71, 176, 103, 23);
[Link](Add1);
JButton Add2 = new JButton("Add All");
[Link](new ActionListener() {
public void actionPerformed(ActionEvent arg0)
[Link]("Beige",0);
[Link]("Teal",0);
[Link]("Black",0);
[Link]("Purple",0);
[Link]("Azure",0);
[Link]("Russet",0);
[Link]("Turquoise",0);
[Link]("All items are added");
});
[Link](209, 176, 104, 23);
[Link](Add2);
JButton Rem1 = new JButton("Remove Item");
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e)
[Link](0);
[Link]("Item removed");
});
[Link](71, 227, 103, 23);
[Link](Rem1);
JButton Rem2 = new JButton("Remove All");
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e)
[Link]();
[Link]("All items removed");
});
[Link](209, 227, 103, 23);
[Link](Rem2);
JLabel lblcolor = new JLabel("COLORS");
[Link](new Font("Sitka Text", [Link], 14));
[Link](176, 11, 75, 14);
[Link](lblcolor);
ECLIPSE VIEW: