NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//ex 1
package Homework3;

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

public class Exercise1 extends JFrame implements ActionListener {

JLabel lb1, lb2, lb3;
JButton b1, b2;
JRadioButton rb1, rb2, rb3, rb4;
JCheckBox chb1, chb2, chb3, chb4, chb5, chb6;
JTextArea ta;
JComboBox<String> combo1;
String[] list = { "1", "2", "3", "4" };
ButtonGroup bg;

public Exercise1() {

b2 = new JButton("Clear");
b2.setBounds(250, 220, 100, 30);
b2.addActionListener(this);

b1 = new JButton("Show");
b1.setBounds(130, 220, 100, 30);
b1.addActionListener(this);

ta = new JTextArea();
ta.setBounds(30, 260, 430, 90);

chb6 = new JCheckBox("Circuit");
chb6.setBounds(260, 180, 100, 30);
chb6.addActionListener(this);

chb5 = new JCheckBox("C++");
chb5.setBounds(260, 150, 100, 30);
chb5.addActionListener(this);

chb4 = new JCheckBox("Security");
chb4.setBounds(260, 120, 100, 30);
chb4.addActionListener(this);

chb3 = new JCheckBox("Web design");
chb3.setBounds(130, 180, 100, 30);
chb3.addActionListener(this);

chb2 = new JCheckBox("Network");
chb2.setBounds(130, 150, 100, 30);
chb2.addActionListener(this);

chb1 = new JCheckBox("Java");
chb1.setBounds(130, 120, 100, 30);
chb1.addActionListener(this);

rb4 = new JRadioButton("EE");
rb4.setBounds(280, 70, 50, 50);
rb4.addActionListener(this);

rb3 = new JRadioButton("IC");
rb3.setBounds(230, 70, 50, 50);
rb3.addActionListener(this);

rb2 = new JRadioButton("CS");
rb2.setBounds(180, 70, 50, 50);
rb2.addActionListener(this);

rb1 = new JRadioButton("MM");
rb1.setBounds(130, 70, 50, 50);
rb1.addActionListener(this);

combo1 = new JComboBox<>(list);
combo1.setBounds(150, 40, 200, 30);
combo1.addActionListener(this);

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

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

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

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

this.add(b1);
this.add(b2);
this.add(lb1);
this.add(lb2);
this.add(lb3);
this.add(combo1);
this.add(rb1);
this.add(rb2);
this.add(rb3);
this.add(rb4);
this.add(chb1);
this.add(chb2);
this.add(chb3);
this.add(chb4);
this.add(chb5);
this.add(chb6);
this.add(ta);
this.setLayout(null);
this.setVisible(true);
this.setSize(500, 400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

@Override
public void actionPerformed(ActionEvent e) {

if (e.getSource() == b1) {

if (combo1.getSelectedIndex() == 0) {
ta.setText("You are Freshman ");
}
else if (combo1.getSelectedIndex() == 1) {
ta.setText("You are Sophomore ");
}
else if (combo1.getSelectedIndex() == 2) {
ta.setText("You are Junior ");
}
else if (combo1.getSelectedIndex() == 3) {
ta.setText("You are Senior ");
}

if (rb1.isSelected()) {
ta.append(" in " + rb1.getText() + " department. n");
}
else if (rb2.isSelected()) {
ta.append(" in " + rb2.getText() + " department. n");
}
else if (rb3.isSelected()) {
ta.append(" in " + rb3.getText() + " department. n");
}
else if (rb4.isSelected()) {
ta.append(" in " +rb4.getText() + " department. n");
}


if (chb1.isSelected()) {
ta.append("You selected following course: " + chb1.getText() + " ");
}
if (chb2.isSelected()) {
ta.append(chb2.getText() + " ");
}
if (chb3.isSelected()) {
ta.append(chb3.getText() + " ");
}
if (chb4.isSelected()) {
ta.append(chb4.getText() + " ");
}
if (chb5.isSelected()) {
ta.append(chb5.getText() + " ");
}
if (chb6.isSelected()) {
ta.append(chb6.getText() + " ");
}

}
if (e.getSource() == b2) {
ta.setText("");
}

}

}

// ex 2
package Homework3;

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Exercise2 extends JFrame implements ActionListener{

JRadioButton rb1, rb2, rb3, rb4, rb5;
ImageIcon icon, icon1, icon2, icon3, icon4, icon5;
JLabel lb1, lb2, lb3, lb4, lb5;
ButtonGroup bg;

public Exercise2 () {

icon = new ImageIcon();
icon1 = new ImageIcon("image/Dog.gif");
icon2 = new ImageIcon("image/Pig.gif");
icon3 = new ImageIcon("image/Cat.gif");
icon4 = new ImageIcon("image/Bird.gif");
icon5 = new ImageIcon("image/Rabbit.gif");

lb1 = new JLabel();
lb1.setBounds(40,80,150,150);
lb1.setIcon(icon);

lb2 = new JLabel();
lb2.setBounds(190,80,150,150);
lb2.setIcon(icon);

lb3 = new JLabel();
lb3.setBounds(340,80,150,150);
lb3.setIcon(icon);

lb4 = new JLabel();
lb4.setBounds(490,80,150,150);
lb4.setIcon(icon);

lb5 = new JLabel();
lb5.setBounds(40,230,150,150);
lb5.setIcon(icon);

rb1 = new JRadioButton("Dog");
rb1.setBounds(30, 20, 70, 70);
rb1.addActionListener(this);

rb2 = new JRadioButton("Pig");
rb2.setBounds(100, 20, 70, 70);
rb2.addActionListener(this);

rb3 = new JRadioButton("Cat");
rb3.setBounds(170, 20, 70, 70);
rb3.addActionListener(this);

rb4 = new JRadioButton("Bird");
rb4.setBounds(240, 20, 70, 70);
rb4.addActionListener(this);

rb5 = new JRadioButton("Rabbit");
rb5.setBounds(310, 20, 70, 70);
rb5.addActionListener(this);


this.add(rb1);
this.add(rb2);
this.add(rb3);
this.add(rb4);
this.add(rb5);
this.add(lb1);
this.add(lb2);
this.add(lb3);
this.add(lb4);
this.add(lb5);
this.setLayout(null);
this.setSize(700,700);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

@Override
public void actionPerformed(ActionEvent e) {

if(e.getSource() == rb1) {
lb1.setIcon(icon1);
}
if(e.getSource() == rb2) {
lb2.setIcon(icon2);
}
if(e.getSource() == rb3) {
lb3.setIcon(icon3);
}
if(e.getSource() == rb4) {
lb4.setIcon(icon4);
}
if(e.getSource() == rb5) {
lb5.setIcon(icon5);
}

}
}
// ex3

package Homework3;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Exercise3 extends JFrame implements ActionListener {
private ImageIcon icon, icon1, icon2, icon3, icon4, icon5;
private JLabel lb1, lb2, lb3, lb4, lb5;
private JCheckBox chb1, chb2, chb3, chb4, chb5, chb6;
public Exercise3() {
icon1 = new ImageIcon("Image/Dog.gif");
icon2 = new ImageIcon("Image/Pig.gif");
icon3 = new ImageIcon("Image/Cat.gif");
icon4 = new ImageIcon("Image/Bird.gif");
icon5 = new ImageIcon("Image/Rabbit.gif");
icon = new ImageIcon();
lb1 = new JLabel();
lb1.setBounds(10, 10, 150, 150);
lb1.setIcon(icon);
chb1 = new JCheckBox("Dog");
chb1.setBounds(10, 160, 100, 30);
chb1.addActionListener(this);
lb2 = new JLabel();
lb2.setBounds(160, 10, 150, 150);
lb2.setIcon(icon);
chb2 = new JCheckBox("Pig");
chb2.setBounds(160, 160, 100, 30);
chb2.addActionListener(this);
lb3 = new JLabel();
lb3.setBounds(310, 10, 150, 150);
lb3.setIcon(icon);
chb3 = new JCheckBox("Cat");
chb3.setBounds(310, 160, 100, 30);
chb3.addActionListener(this);
lb4 = new JLabel();
lb4.setBounds(460, 10, 150, 150);
lb4.setIcon(icon);
chb4 = new JCheckBox("Bird");
chb4.setBounds(460, 160, 100, 30);
chb4.addActionListener(this);
lb5 = new JLabel();
lb5.setBounds(610, 10, 150, 150);
lb5.setIcon(icon);
chb5 = new JCheckBox("Rabbit");
chb5.setBounds(610, 160, 100, 30);
chb5.addActionListener(this);
this.add(lb1);
this.add(chb1);
this.add(lb2);
this.add(chb2);
this.add(lb3);
this.add(chb3);
this.add(lb4);
this.add(chb4);
this.add(lb5);
this.add(chb5);
this.setLayout(null);
this.setSize(800, 400);
this.setBackground(Color.red);
this.setVisible(true);
this.setResizable(false);
this.setTitle("Turshilt1");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chb1) {
if (chb1.isSelected()) {
lb1.setIcon(icon1);
} else {
lb1.setIcon(icon);
}
}
if (e.getSource() == chb2) {
if (chb2.isSelected()) {
lb2.setIcon(icon2);
} else {
lb2.setIcon(icon);
}
}
if (e.getSource() == chb3) {
if (chb3.isSelected()) {
lb3.setIcon(icon3);
} else {
lb3.setIcon(icon);
}
}
if (e.getSource() == chb4) {
if (chb4.isSelected()) {
lb4.setIcon(icon4);
} else {
lb4.setIcon(icon);
}
}
if (e.getSource() == chb5) {
if (chb5.isSelected()) {
lb5.setIcon(icon5);
} else {
lb5.setIcon(icon);
}
}
}
}
     
 
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.