package final;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.util.ArrayList.*;
import java.util.Arrays.*;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Fi extends JFrame implements ActionListener, ItemListener{
JTextArea Text,j,k,l,m;
JRadioButton Boy,Girl;
JCheckBox a,b,c,d,e,f,g;
JComboBox h;
String i[]={"Select","Car","Bike","Motorcycle"};
public JPanel createContentPane (){
JPanel totalGUI = new JPanel();
totalGUI.setLayout(null);
Text = new JTextArea();
Text.setLocation(10, 10);
Text.setSize(370, 250);
Text.setEditable(false);
totalGUI.add(Text);
j = new JTextArea();
j.setLocation(10, 10);
j.setSize(370, 30);
j.setFont(new Font("Serif", Font.BOLD, 14));
totalGUI.add(j);
k = new JTextArea();
k.setLocation(10, 30);
k.setSize(370, 30);
k.setFont(new Font("Serif", Font.BOLD, 14));
totalGUI.add(k);
l = new JTextArea();
l.setLocation(10, 50);
l.setSize(370, 30);
l.setFont(new Font("Serif", Font.BOLD, 14));
totalGUI.add(l);
m = new JTextArea();
m.setLocation(160, 10);
m.setSize(220, 30);
m.setFont(new Font("Serif", Font.BOLD, 14));
totalGUI.add(m);
h = new JComboBox(i);
h.setLocation(400, 90);
h.setSize(80, 130);
totalGUI.add(h);
h.addItemListener(this);
// Button for Logging in
Boy = new JRadioButton("Boy");
Boy.setLocation(420, 20);
Boy.setSize(50, 20);
Boy.addActionListener(this);
totalGUI.add(Boy);
Girl = new JRadioButton("Girl");
Girl.setLocation(420, 60);
Girl.setSize(50, 20);
Girl.addActionListener(this);
totalGUI.add(Girl);
ButtonGroup bg = new ButtonGroup();
bg.add(Boy);
bg.add(Girl);
a=new JCheckBox("Office");
a.setLocation(490, 10);
a.setSize(80, 40);
b=new JCheckBox("Hospital");
b.setLocation(490, 40);
b.setSize(80, 40);
c=new JCheckBox("University");
c.setLocation(490, 70);
c.setSize(100, 40);
d=new JCheckBox("Pool");
d.setLocation(490, 100);
d.setSize(80, 40);
e=new JCheckBox("Farm");
e.setLocation(490, 130);
e.setSize(80, 40);
f=new JCheckBox("Castle");
f.setLocation(490, 160);
f.setSize(80, 40);
g=new JCheckBox("Sewer");
g.setLocation(490, 190);
g.setSize(80, 40);
a.addActionListener(this);
b.addActionListener(this);
c.addActionListener(this);
d.addActionListener(this);
e.addActionListener(this);
f.addActionListener(this);
g.addActionListener(this);
totalGUI.add(a);
totalGUI.add(b);
totalGUI.add(c);
totalGUI.add(d);
totalGUI.add(e);
totalGUI.add(f);
totalGUI.add(g);
ButtonGroup cg = new ButtonGroup();
cg.add(a);
cg.add(b);
cg.add(c);
cg.add(d);
cg.add(e);
cg.add(f);
cg.add(g);
totalGUI.setOpaque(true);
return totalGUI;
}
public void actionPerformed(ActionEvent action) {
if(action.getSource()==Boy){
j.setText("When I was a little Boy.");
}
else if(action.getSource()==Girl){
j.setText("When I was a little Girl.");
}
if(action.getSource()==a){
l.setText("Sometimes I'd go and visit my Office.");
}
if(action.getSource()==b){
l.setText("Sometimes I'd go and visit my Hospital.");
}
if(action.getSource()==c){
l.setText("Sometimes I'd go and visit my University where I study.");
}
if(action.getSource()==d){
l.setText("Sometimes I'd go and visit the Pool of my friend.");
}
if(action.getSource()==e){
l.setText("Sometimes I'd go and visit our family Farm.");
}
if(action.getSource()==f){
l.setText("Sometimes I'd go and visit the Castle of the Queen and King.");
}
if(action.getSource()==g){
l.setText("Sometimes I'd go and visit my Sewer.");
}
}
public void itemStateChanged(ItemEvent event){
if (event.getSource()==h) {
if(h.getSelectedItem().equals("Car")){
m.setText("I always dreamed of having a Car.");
k.setText("I'd travel in it anywhere and go and visit my mum.");
}
if(h.getSelectedItem().equals("Mountain Bike")){
m.setText("I always dreamed of having a Car.");
k.setText("I'd travel in it anywhere and go and visit my mum.");
}
if(h.getSelectedItem().equals("Motorcycle")){
m.setText("I always dreamed of having a Car.");
k.setText("I'd travel in it anywhere and go and visit my mum.");
}
if(h.getSelectedItem().equals("Select")){
j.setText(null);
k.setText(null);
l.setText(null);
m.setText(null);
}
}
}
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Defend for Final");
Final demo = new Final();
frame.setContentPane(demo.createContentPane());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 300);
frame.setVisible(true);
}
}