NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package Lab4;

import java.awt.Color;
import java.awt.event.*;
import javax.swing.*;

public class ExsFour extends JFrame implements ActionListener{
private JLabel lb1, lb2, lb3;
private JComboBox co;
private JRadioButton rb1, rb2, rb3, rb4;
private ButtonGroup bg;
private JCheckBox cb1, cb2, cb3, cb4, cb5, cb6;
private JButton b1, b2;
private JTextArea tf;
private ImageIcon im1, im2, im3, im4, im5;
String grade = "freshman";
String dep = "MM";

public ExsFour () {

lb1 = new JLabel("Grade");
lb1.setBounds(20, 20, 70, 30);

String[] itemList = {"1", "2", "3", "4"};
co = new JComboBox(itemList);
co.setBounds(120, 20, 150, 30);
co.addActionListener(this);

lb2 = new JLabel("Department");
lb2.setBounds(20, 60, 70, 30);

rb1 = new JRadioButton("MM", true);
rb1.setBounds(120, 60, 50, 30);
rb1.addActionListener(this);
rb2 = new JRadioButton("CS");
rb2.setBounds(180, 60, 50, 30);
rb2.addActionListener(this);
rb3 = new JRadioButton("IC");
rb3.setBounds(230, 60, 50, 30);
rb3.addActionListener(this);
rb4 = new JRadioButton("EE");
rb4.setBounds(280, 60, 50, 30);
rb4.addActionListener(this);

bg = new ButtonGroup();
bg.add(rb1);
bg.add(rb2);
bg.add(rb3);
bg.add(rb4);

lb3 = new JLabel("Courses");
lb3.setBounds(20, 100, 70, 30);

cb1 = new JCheckBox("JAVA");
cb1.setBounds(120, 100, 100, 20);
cb1.addActionListener(this);

cb2 = new JCheckBox("Network");
cb2.setBounds(120, 130, 100, 20);
cb2.addActionListener(this);

cb3 = new JCheckBox("Web Design");
cb3.setBounds(120, 160, 100, 20);
cb3.addActionListener(this);

cb4 = new JCheckBox("Security");
cb4.setBounds(240, 100, 100, 20);
cb4.addActionListener(this);

cb5 = new JCheckBox("C++");
cb5.setBounds(240, 130, 100, 20);
cb5.addActionListener(this);

cb6 = new JCheckBox("Circuit");
cb6.setBounds(240, 160, 100, 20);
cb6.addActionListener(this);

b1 = new JButton("Show");
b1.setBounds(120, 200, 90, 20);

b2 = new JButton("Clear");
b2.setBounds(240, 200, 90, 20);

tf = new JTextArea();
tf.setBounds(20, 250, 345, 130);

b1.addActionListener(this);
b2.addActionListener(this);

this.add(lb1);
this.add(lb2);
this.add(lb3);
this.add(co);
this.add(rb1);
this.add(rb2);
this.add(rb3);
this.add(rb4);
this.add(cb1);
this.add(cb2);
this.add(cb3);
this.add(cb4);
this.add(cb5);
this.add(cb6);
this.add(b1);
this.add(b2);
this.add(tf);

this.setLayout(null);
this.setSize(400, 450);
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == co) {
if (co.getSelectedIndex() == 0) {
grade = "Freshman";
}
if (co.getSelectedIndex() == 1) {
grade = "Sophomore";
}
if (co.getSelectedIndex() == 2) {
grade = "Senior";
}
if (co.getSelectedIndex() == 3) {
grade = "Junior";
}
}
if (e.getSource() == rb1) {
dep = rb1.getText();
}
if (e.getSource() == rb2) {
dep = rb2.getText();
}
if (e.getSource() == rb3) {
dep = rb3.getText();
}
if (e.getSource() == rb4) {
dep = rb4.getText();
}

if(e.getSource() == b1) {
tf.append("You are " + grade + " in " + dep + " department. nYou selected following course: ");

if(cb1.isSelected() == true) {
tf.append(" n" + cb1.getText());
}

if(cb2.isSelected() == true) {
tf.append(" n" + cb2.getText());
}

if(cb3.isSelected() == true) {
tf.append(" n" + cb3.getText());
}

if(cb4.isSelected() == true) {
tf.append(" n" + cb4.getText());
}

if(cb5.isSelected() == true) {
tf.append(" n" + cb5.getText());
}
if(cb6.isSelected() == true) {
tf.append(" n" + cb6.getText());
}

}if (e.getSource() == b2) {
tf.setText(null);
co.setSelectedIndex(0);
cb1.setSelected(false);
cb2.setSelected(false);
cb3.setSelected(false);
cb4.setSelected(false);
cb5.setSelected(false);
cb6.setSelected(false);
bg.clearSelection();

}

}
}





package Lab4;

import java.awt.event.*;
import javax.swing.*;

public class ExsOne extends JFrame implements ActionListener {

private JRadioButton rb1, rb2, rb3, rb4, rb5;
private JLabel lb;
private ButtonGroup bg;
private ImageIcon i1, i2, i3, i4,i5;
public ExsOne() {
i1 = new ImageIcon("Image/Dog.gif");
i2 = new ImageIcon("Image/Bird.gif");
i3 = new ImageIcon("Image/Rabbit.gif");
i4 = new ImageIcon("Image/Cat.gif");
i5 = new ImageIcon("Image/Pig.gif");

lb = new JLabel();
lb.setIcon(i1);

rb1 = new JRadioButton("Dog", true);
rb2 = new JRadioButton("Bird");
rb3 = new JRadioButton("Rabbit");
rb4 = new JRadioButton("Cat");
rb5 = new JRadioButton("Pig");

bg = new ButtonGroup();
bg.add(rb1);
bg.add(rb2);
bg.add(rb3);
bg.add(rb4);
bg.add(rb5);

lb.setBounds(170, 40, 300, 300);

rb1.addActionListener(this);
rb1.setBounds(50, 10, 80, 30);
rb2.addActionListener(this);
rb2.setBounds(130, 10, 80, 30);
rb3.addActionListener(this);
rb3.setBounds(210, 10, 80, 30);
rb4.addActionListener(this);
rb4.setBounds(310, 10, 80, 30);
rb5.addActionListener(this);
rb5.setBounds(390, 10, 80, 30);

this.add(lb);
this.add(rb1);
this.add(rb2);
this.add(rb3);
this.add(rb4);
this.add(rb5);

this.setLayout(null);
this.setSize(500, 350);
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == rb1) {
lb.setIcon(i1);
}if (e.getSource() == rb2) {
lb.setIcon(i2);
}if (e.getSource() == rb3) {
lb.setIcon(i3);
}if (e.getSource() == rb4) {
lb.setIcon(i4);
}if (e.getSource() == rb5) {
lb.setIcon(i5);
}

}

}




package Lab4;

import java.awt.Color;
import java.awt.event.*;
import javax.swing.*;

public class ExsThree extends JFrame implements ActionListener {
private JComboBox co;
private JLabel lb;
private ImageIcon im1, im2, im3, im4, im5;

public ExsThree() {

im1 = new ImageIcon("Image/Dog.gif");
im2 = new ImageIcon("Image/Pig.gif");
im3 = new ImageIcon("Image/Rabbit.gif");
im4 = new ImageIcon("Image/Bird.gif");
im5 = new ImageIcon("Image/Cat.gif");

String[] itemList = {"Dog", "Pig", "Rabbit", "Bird", "Cat"};
co = new JComboBox(itemList);
co.setBounds(15, 20, 160, 20);
co.setBackground(Color.gray);
co.addActionListener(this);

this.add(co);

lb = new JLabel();
lb.setBounds(30, 70, 150, 150);
lb.setIcon(im1);
this.add(lb);

this.setLayout(null);
this.setSize(200, 300);
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}


@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == co) {
if (co.getSelectedIndex() == 0) {
lb.setIcon(im1);
}else if (co.getSelectedIndex() == 1) {
lb.setIcon(im2);
}else if (co.getSelectedIndex() == 2) {
lb.setIcon(im3);
}else if (co.getSelectedIndex() == 3) {
lb.setIcon(im4);
}else if (co.getSelectedIndex() == 4) {
lb.setIcon(im5);
}
}
}

}



package Lab4;

import java.awt.event.*;
import javax.swing.*;

public class ExsTwo extends JFrame implements ItemListener {
private JCheckBox cb1, cb2, cb3, cb4, cb5;
private JLabel lb1, lb2, lb3, lb4, lb5;
private ImageIcon i1, i2, i3, i4, i5;

public ExsTwo() {

i1 = new ImageIcon("Image/Dog.gif");
i2 = new ImageIcon("Image/Bird.gif");
i3 = new ImageIcon("Image/Rabbit.gif");
i4 = new ImageIcon("Image/Cat.gif");
i5 = new ImageIcon("Image/Pig.gif");

lb1 = new JLabel();
lb1.setIcon(i1);
lb1.setBounds(20, 20, 100, 100);
lb2 = new JLabel();
lb2.setBounds(130, 20, 100, 100);
lb3 = new JLabel();
lb3.setBounds(240, 20, 100, 100);
lb4 = new JLabel();
lb4.setBounds(350, 20, 100, 100);
lb5 = new JLabel();
lb5.setBounds(460, 20, 100, 100);

cb1 = new JCheckBox("Dog", true);
cb1.setBounds(50, 150, 60, 30);
cb2 = new JCheckBox("Pig");
cb2.setBounds(160, 150, 60, 30);
cb3 = new JCheckBox("Cat");
cb3.setBounds(265, 150, 60, 30);
cb4 = new JCheckBox("Bird");
cb4.setBounds(370, 150, 60, 30);
cb5 = new JCheckBox("Rabbit");
cb5.setBounds(480, 150, 80, 30);

cb1.addItemListener(this);
cb2.addItemListener(this);
cb3.addItemListener(this);
cb4.addItemListener(this);
cb5.addItemListener(this);

this.add(cb1);
this.add(cb2);
this.add(cb3);
this.add(cb4);
this.add(cb5);
this.add(lb1);
this.add(lb2);
this.add(lb3);
this.add(lb4);
this.add(lb5);

this.setLayout(null);
this.setSize(595, 250);
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

@Override
public void itemStateChanged(ItemEvent e) {
if(e.getSource() == cb1) {
if (cb1.isSelected() == true ) {
lb1.setIcon(i1);
}else {
lb1.setIcon(null);
}}

if(e.getSource() == cb2) {
if (cb2.isSelected() == true ) {
lb2.setIcon(i2);
}else {
lb2.setIcon(null);
}}

if(e.getSource() == cb3) {
if (cb3.isSelected() == true ) {
lb3.setIcon(i3);
}else {
lb3.setIcon(null);
}}

if(e.getSource() == cb4) {
if (cb4.isSelected() == true ) {
lb4.setIcon(i4);
}else {
lb4.setIcon(null);
}}

if(e.getSource() == cb5) {
if (cb5.isSelected() == true ) {
lb5.setIcon(i5);
}else {
lb5.setIcon(null);
}}

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.