You are on page 1of 29

UNIVERSITI TEKNOLOGI MARA

SERI ISKANDAR CAMPUS


FACULTY OF COMPUTER AND MATHEMATICAL SCIENCES

DIPLOMA IN COMPUTER SCIENCE

OBJECT ORIENTED PROGRAMMING II (CSC218)

GRAPHICAL USER INTERFACE


GUI PROJECT
-H & H MUSIC STORE-

Compiled by:
MUHAMMAD HANIS HASSIM MOHD HAFEEZ JOHARI
2008226726 2008228374

For
CIK MASURAH MOHAMAD
OBJECT ORIENED PROGRAMMING II (CSC218)

Due Date
12 OCTOBER 2009
PROJECT EXPLANATION

H & H MUSIC STORE IS A WELL KNOWN MUSIC STORE IN PERAK.


IT PROVIDES RENTAL AS WELL AS BUY MUSICAL INSTRUMENTS SERVICES. THE
STORE MANAGER PLANNED TO DESIGN A USER FRIENDLY PROGRAM THAT WILL
HELP TO MANAGE THE STORE IN MORE EFFICIENT WAY, AND ALSO TARGETS TO
GIVE CONVINIENCE TO THE STORE CUSTOMERS.

IN FIRST WINDOW, THE MAIN WINDOW DISPLAYS AND ACCQUIRE USER TO


ENTER THE USER’S NAME.
IF THE USER HAVE ENTERED NAME, A NEW POP-OUT WINDOW THAT DISPLAYS
THE INSTRUCTIONS TO USE THE PROGRAM WILL APPEAR AND THE PREVIOUS
WINDOW WILL DISAPPEAR.

THEN A NEW WINDOW WILL APPEAR AFTER THE USER CLICKED THE OK BUTTON
OF THE INSTRUCTION WINDOW. THIS NEW WINDOW IS CALLED AS PROCESS
WINDOW. THE WINDOW RECEIVES USER INPUT AND DATA, SUCH AS CHOOSING
OPTIONS OF TO BUY INSTRUMENTS, TO RENT INSTRMENTS, OR EITHER TO RENT
JAMMING STUDIO. BASED ON WHAT THE USERS OPTION, IT THEN ASK TO TICK A
BOX THAT CONTAINS OPTIONS OF WHAT MUSICAL INSTRUMENT THE USER
WANTS TO REPAIR, IF NOT THE USER SHOULD TICK THE ‘NONE’ CHECKBOX.
LATER ON, THE USER WILL HAVE TO PROCEED TO THE NEXT STEP BASED ON THE
PREVIOUS POP OUT WINDOW INSTRUCTIONS, THAT IS TO CHOOSE MUSICAL
INSTRUMENTS ACESSORIES. THE ACESSORIES THAT CAN BE CHOOSE IS AVAILABLE
FROM VARIOUS BRANDS. AMONG THEM INCLUDES CAP IBU DAN AYAH, KAPOK,

1
YAMAHA, ETC. THE USER WILL HAVE TO CLICK THE ACESSORIES BUTTON AGAIN
TO DISPLAY THE ITEM.
LASTLY, THE USER WILL HAVE TO ENTER THE AMOUNT OF DISCOUNT GIVEN BY
THE STORE, IF ANY, OR IF NO DISCOUNT GIVEN, THE USER SHOULD FILL THE
DISCOUNT TEXT FIELD WITH 100. THIS THEN FOLLOWED BY CLICKING THE
CALCULATE BUTTON TO CALCULATE THE TOTAL AMOUNT THAT THE USER HAS TO
PAY.

THE LAST WINDOW, CALLED GALLERY, WILL APPEAR IF THE USER CLICK ON THE
‘NEXT TO SEE GALLERY’ BUTTON ON THE PREVIOUS PROCESS WINDOW. IT
DISPLAYS PICTURES THAT WAS INTENDED TO GIVE INFORMATION. ONE OF THE
EXAMPLE PICTURE IS ABOUT TO WISH THE USER SELAMAT HARI RAYA. IF THE
USER CLICKED ON THE EXIT BUTTON, THE PROGRAM ENDS AND WILL BE
TERMINATED.

2
JAVA CODES
hhStore,java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;

public class hhStore extends JFrame implements ActionListener


{
private JRadioButton rb1, rb2 ,rb3 ,rb4;
private JComboBox Jcb1, Jcb2 ,Jcb3 ,Jcb4 ,Jcb5 ,Jcb6 ,Jcb7 ,Jcb8
,Jcb9 ,Jcb10;
private JButton b1 ,b2 ,b3 ,b4 ,b5 ,b6 ,b7 ,b8 ,b9;
private JCheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9;
private JLabel
lb1,lb2,lb3,lb4,lb5,lb6,lb7,lb8,lb9,lb10,lb11,lb12,lb20,lb21;
private JTextField tf1,tf2,tf3,tf4,tf5;
private JPanel panel,pn1,pn2,pn3,pn4,pn5,pn6,pn7,pn8,pn9;
private String Num;

public hhStore()
{ Container kanvas = getContentPane();
kanvas.setLayout(new BorderLayout());
Num = "";

rb1 = new JRadioButton("BUY INSTRUMENT");


rb2 = new JRadioButton("RENT INSTRUMENT");
rb3 = new JRadioButton("RENT JAMMING STUDIO");
rb4 = new JRadioButton("OTHER");

Jcb1 = new JComboBox();


Jcb2 = new JComboBox();
Jcb3 = new JComboBox();
Jcb4 = new JComboBox();
Jcb5 = new JComboBox();
Jcb6 = new JComboBox();
Jcb7 = new JComboBox();
Jcb8 = new JComboBox();

3
Jcb9 = new JComboBox();
Jcb10 = new JComboBox();

b1 = new JButton("Guitar String");


b2 = new JButton("DrumStick");
b3 = new JButton("Guitar Pick");
b4 = new JButton("Guitar Bag");
b5 = new JButton("Paddle Drum");
b6 = new JButton("Microphone");
b7 = new JButton("CLICK TO CALCULATE");
b8 = new JButton("RESET");
b9 = new JButton("NEXT TO SEE GALLERY");

cb1 = new JCheckBox("GUITAR");


cb2 = new JCheckBox("DRUM");
cb3 = new JCheckBox("PIANO");
cb4 = new JCheckBox("MICROPHONE");
cb5 = new JCheckBox("AMPLIFIER");
cb6 = new JCheckBox("KOMPANG");
cb7 = new JCheckBox("KEYBOARD");
cb8 = new JCheckBox("FLUTE");
cb9 = new JCheckBox("NONE");

lb1 = new JLabel();


lb2 = new JLabel();
lb3 = new JLabel();
lb4 = new JLabel("Price SERVICES",SwingConstants.LEFT);
lb5 = new JLabel("RM",SwingConstants.RIGHT);
lb6 = new JLabel("Price ACCESORIES",SwingConstants.LEFT);
lb7 = new JLabel("RM",SwingConstants.RIGHT);
lb8 = new JLabel("Price REPAIR",SwingConstants.LEFT);
lb9 = new JLabel("RM",SwingConstants.RIGHT);
lb10 = new JLabel("Discount,%",SwingConstants.LEFT);
lb11 = new JLabel("Total",SwingConstants.LEFT);
lb12 = new JLabel("RM",SwingConstants.RIGHT);
lb20 = new JLabel("Please click button after -- ");
lb21 = new JLabel("choose Brand");

tf1 = new JTextField(30);

4
tf2 = new JTextField(30);
tf3 = new JTextField(30);
tf4 = new JTextField("enter discount",8);
tf5 = new JTextField(8);

panel = new JPanel();


pn1 = new JPanel();
pn2 = new JPanel();
pn3 = new JPanel();
pn4 = new JPanel();
pn5 = new JPanel();
pn6 = new JPanel();
pn7 = new JPanel();
pn8 = new JPanel();
pn9 = new JPanel();

panel.setLayout(new GridLayout(3,2));
pn1.setLayout(new GridLayout(5,1));
pn2.setLayout(new GridLayout(3,1));
pn3.setLayout(new GridLayout(8,1));
pn4.setLayout(new GridLayout(3,3));
pn5.setLayout(new GridLayout(3,3));
pn6.setLayout(new FlowLayout());
pn7.setLayout(new GridLayout(1,3));
pn9.setLayout(new GridLayout(1,2));

pn1.setBorder(BorderFactory.createTitledBorder("SERVICES"));
pn2.setBorder(BorderFactory.createEtchedBorder());

pn3.setBorder(BorderFactory.createTitledBorder("ACCESORIES"));
pn4.setBorder(BorderFactory.createEtchedBorder());
pn5.setBorder(BorderFactory.createTitledBorder("REPAIR
INSTRUMENT"));
pn6.setBorder(BorderFactory.createEtchedBorder());
pn7.setBorder(BorderFactory.createEtchedBorder());
pn9.setBorder(BorderFactory.createTitledBorder("LIST"));

Jcb1.setModel(new DefaultComboBoxModel(new String[]


{"DRUM","GUITAR","PIANO"}));

5
Jcb2.setModel(new DefaultComboBoxModel(new String[]
{"DRUM","GUITAR","PIANO"}));

Jcb3.setModel(new DefaultComboBoxModel(new String[]


{"1 DAY","2 DAYS","3 DAYS","1 WEEK"}));

Jcb4.setModel(new DefaultComboBoxModel(new String[]


{"CUSTOMER SERVICE","CARE-LINE"}));

Jcb5.setModel(new DefaultComboBoxModel(new String[]


{"CAP AYAM","CAP TALI GAJAH","YAMAHA","STYLO"}));

Jcb6.setModel(new DefaultComboBoxModel(new String[]


{"YAMAHA","CAP KAKI TIGA","CAP MUH"}));

Jcb7.setModel(new DefaultComboBoxModel(new String[]


{"HUJAN","YAMAHA","RAIN","CAP KAPAK"}));

Jcb8.setModel(new DefaultComboBoxModel(new String[]


{"YAMAHA","CAP AYAM","KAPOK"}));

Jcb9.setModel(new DefaultComboBoxModel(new String[]


{"KAPOK","RYTHM BRAND","GORENG SAMA"}));

Jcb10.setModel(new DefaultComboBoxModel(new String[]


{"CAP IBU DAN AYAH","YAMAHA","RHYTHM BRAND"}));

b1.setBackground(Color.blue);
b2.setBackground(Color.red);
b3.setBackground(Color.red);
b4.setBackground(Color.blue);
b5.setBackground(Color.blue);
b6.setBackground(Color.red);
panel.setBackground(Color.blue);
pn2.setBackground(Color.yellow);
pn6.setBackground(Color.white);
pn5.setBackground(Color.white);

6
tf1.setBackground(Color.green);
tf2.setBackground(Color.green);
tf3.setBackground(Color.green);
tf4.setBackground(Color.yellow);
tf5.setBackground(Color.yellow);

rb1.setToolTipText("buy Instrument");
rb2.setToolTipText("rent Instrument");
rb3.setToolTipText("rent jamming studio");
rb4.setToolTipText("other");

b7.setToolTipText("Click to CLICK TO CALCULATE");


b8.setToolTipText("Click to RESET");
b9.setToolTipText("Click to exit");

tf1.setEditable(false);
tf2.setEditable(false);
tf3.setEditable(false);
tf5.setEditable(false);

Jcb1.setVisible(true);
Jcb2.setVisible(true);
Jcb3.setVisible(true);
Jcb4.setVisible(true);
Jcb5.setVisible(true);
Jcb6.setVisible(true);
Jcb7.setVisible(true);
Jcb8.setVisible(true);
Jcb9.setVisible(true);
Jcb10.setVisible(true);

Jcb1.setEnabled(false);
Jcb2.setEnabled(false);
Jcb3.setEnabled(false);
Jcb4.setEnabled(false);
Jcb5.setEnabled(false);
Jcb6.setEnabled(false);
Jcb7.setEnabled(false);
Jcb8.setEnabled(false);

7
Jcb9.setEnabled(false);
Jcb10.setEnabled(false);

pn1.add(rb1);
pn1.add(rb2);
pn1.add(rb3);
pn1.add(rb4);
pn1.add(Jcb1);
pn1.add(Jcb2);
pn1.add(Jcb3);
pn1.add(Jcb4);

pn2.add(lb1);
pn2.add(lb2);
pn2.add(lb3);

pn3.add(b1);
pn3.add(b2);
pn3.add(b3);
pn3.add(b4);
pn3.add(b5);
pn3.add(b6);
pn3.add(Jcb5);
pn3.add(Jcb6);
pn3.add(Jcb7);
pn3.add(Jcb8);
pn3.add(Jcb9);
pn3.add(Jcb10);
pn3.add(lb20);
pn3.add(lb21);

pn4.add(lb4);
pn4.add(lb5);
pn4.add(tf1);
pn4.add(lb6);
pn4.add(lb7);
pn4.add(tf2);
pn4.add(lb8);
pn4.add(lb9);

8
pn4.add(tf3);

pn5.add(cb1);
pn5.add(cb2);
pn5.add(cb3);
pn5.add(cb4);
pn5.add(cb5);
pn5.add(cb6);
pn5.add(cb7);
pn5.add(cb8);
pn5.add(cb9);

pn6.add(lb10);
pn6.add(tf4);
pn6.add(lb11);
pn6.add(lb12);
pn6.add(tf5);

pn7.add(b7);
pn7.add(b8);
pn7.add(b9);

pn9.add(pn2);
pn9.add(pn8);

panel.add(pn1);

panel.add(pn3);
panel.add(pn5);
panel.add(pn9);

panel.add(pn4);
panel.add(pn6);

ButtonGroup group = new ButtonGroup();


group.add(rb1);
group.add(rb2);
group.add(rb3);
group.add(rb4);

9
ButtonGroup group2 = new ButtonGroup();
group2.add(cb1);
group2.add(cb2);
group2.add(cb3);
group2.add(cb4);
group2.add(cb5);
group2.add(cb6);
group2.add(cb7);
group2.add(cb8);
group2.add(cb9);

kanvas.add(panel,BorderLayout.CENTER);
kanvas.add(pn7,BorderLayout.SOUTH);
pn1.setBackground(Color.white);
pn3.setBackground(Color.white);
pn4.setBackground(Color.white);
pn5.setBackground(Color.white);
pn6.setBackground(Color.white);
pn7.setBackground(Color.white);
pn8.setBackground(Color.white);
pn9.setBackground(Color.white);

rb1.addActionListener(this);
rb2.addActionListener(this);
rb3.addActionListener(this);
rb4.addActionListener(this);

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);

cb1.addActionListener(this);

10
cb2.addActionListener(this);
cb3.addActionListener(this);
cb4.addActionListener(this);
cb5.addActionListener(this);
cb6.addActionListener(this);
cb7.addActionListener(this);
cb8.addActionListener(this);
cb9.addActionListener(this);

Jcb1.addActionListener(this);
Jcb2.addActionListener(this);
Jcb3.addActionListener(this);
Jcb4.addActionListener(this);
Jcb5.addActionListener(this);
Jcb6.addActionListener(this);
Jcb7.addActionListener(this);
Jcb8.addActionListener(this);
Jcb9.addActionListener(this);
Jcb10.addActionListener(this);
}

public void actionPerformed(ActionEvent e)


{ { if(rb1.isSelected())
{Jcb1.setEnabled(true);
Jcb2.setEnabled(false);
Jcb3.setEnabled(false);
Jcb4.setEnabled(false);

if(Jcb1.getSelectedIndex() == 0)
{ tf1.setText("700");
lb1.setText("BUY INSTRUMENT - DRUM");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("drum.png")));
}

if(Jcb1.getSelectedIndex() == 1)
{ tf1.setText("600");
lb1.setText("BUY INSTRUMENT - GUITAR");
pn8.setBorder(new javax.swing.border.MatteBorder(new

11
javax.swing.ImageIcon("guitar.png")));
}

if(Jcb1.getSelectedIndex() == 2)
{ tf1.setText("500");
lb1.setText("BUY INSTRUMENT - PIANO");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("piano.jpg")));
}
}

else if(rb2.isSelected())
{ Jcb1.setEnabled(false);
Jcb2.setEnabled(true);
Jcb3.setEnabled(false);
Jcb4.setEnabled(false);

if(Jcb2.getSelectedIndex() == 0)
{ tf1.setText("100");
lb1.setText("RENT INSTRUMENT - DRUM");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("drum.png")));
}

if(Jcb2.getSelectedIndex() == 1)
{ tf1.setText("80");
lb1.setText("RENT INSTRUMENT - GUITAR");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("guitar.png")));
}

if(Jcb2.getSelectedIndex() == 2)
{ tf1.setText("70");
lb1.setText("RENT INSTRUMENT - PIANO");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("piano.jpg")));
}
}

12
else if(rb3.isSelected())
{ Jcb1.setEnabled(false);
Jcb2.setEnabled(false);
Jcb3.setEnabled(true);
Jcb4.setEnabled(false);

if(Jcb3.getSelectedIndex() == 0)
{ tf1.setText("50");
lb1.setText("RENT JAMMING STUDIO - 1 DAY");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("metallica.jpg")));
}

if(Jcb3.getSelectedIndex() == 1)
{ tf1.setText("80");
lb1.setText("RENT JAMMING STUDIO - 2 DAYS");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("metallica.jpg")));
}

if(Jcb3.getSelectedIndex() == 2)
{ tf1.setText("110");
lb1.setText("RENT JAMMING STUDIO - 3 DAYS");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("metallica.jpg")));
}

if(Jcb3.getSelectedIndex() == 3)
{ tf1.setText("400");
lb1.setText("RENT JAMMING STUDIO - 1 WEEK");
pn8.setBorder(new javax.swing.border.MatteBorder(new
javax.swing.ImageIcon("metallica.jpg")));
}
}

else if(rb4.isSelected())
{ Jcb1.setEnabled(false);
Jcb2.setEnabled(false);
Jcb3.setEnabled(false);

13
Jcb4.setEnabled(true);

if(Jcb4.getSelectedIndex() == 0)
{ tf1.setText("0");
lb1.setText("CUSTOMER SERVICE - Visit Branch");
}

if(Jcb4.getSelectedIndex() == 1)
{ tf1.setText("0");
lb1.setText("CARE-LINE - 03433443");
}
}

if(cb1.isSelected())
{ tf3.setText("90");
lb3.setText("REPAIR - GUITAR");
}

else if(cb2.isSelected())
{ tf3.setText("190");
lb3.setText("REPAIR - DRUM");
}

else if(cb3.isSelected())
{ tf3.setText("110");
lb3.setText("REPAIR - PIANO");
}

else if(cb4.isSelected())
{ tf3.setText("20");
lb3.setText("REPAIR - MICROPHONE");
}

else if(cb5.isSelected())
{ tf3.setText("70");
lb3.setText("REPAIR - AMPLIFIER");
}

14
else if(cb6.isSelected())
{ tf3.setText("20");
lb3.setText("REPAIR - KOMPANG");
}

else if(cb7.isSelected())
{ tf3.setText("50");
lb3.setText("REPAIR - KEYBOARD");
}

else if(cb8.isSelected())
{ tf3.setText("10");
lb3.setText("REPAIR - FLUTE");
}

else if(cb9.isSelected())
{ tf3.setText("0");
lb3.setText("NONE");
}
}

String t = e.getActionCommand();

if(t.equals("Guitar String"))
{ Jcb5.setEnabled(true);
Jcb6.setEnabled(false);
Jcb7.setEnabled(false);
Jcb8.setEnabled(false);
Jcb9.setEnabled(false);
Jcb10.setEnabled(false);

if(Jcb5.getSelectedIndex() == 0)
{ tf2.setText("5");
lb2.setText("Guitar String - Cap Ayam");
}

if(Jcb5.getSelectedIndex() == 1)
{ tf2.setText("7");
lb2.setText("Guitar String - Cap Tali Gajah");

15
}

if(Jcb5.getSelectedIndex() == 2)
{ tf2.setText("10");
lb2.setText("Guitar String - Yamaha");
}

if(Jcb5.getSelectedIndex() == 3)
{ tf2.setText("9");
lb2.setText("Guitar String - Stylo");
}
}

if(t.equals("DrumStick"))
{ Jcb5.setEnabled(false);
Jcb6.setEnabled(true);
Jcb7.setEnabled(false);
Jcb8.setEnabled(false);
Jcb9.setEnabled(false);
Jcb10.setEnabled(false);

if(Jcb6.getSelectedIndex() == 0)
{ tf2.setText("40");
lb2.setText("Drumstick - YAMAHA");
}

if(Jcb6.getSelectedIndex() == 1)
{ tf2.setText("30");
lb2.setText("Drumstick - CAP TALI GAJAH");
}

if(Jcb6.getSelectedIndex() == 2)
{ tf2.setText("35");
lb2.setText("Drumstick - CAP MUH");
}
}

if(t.equals("Guitar Pick"))
{ Jcb5.setEnabled(false);

16
Jcb6.setEnabled(false);
Jcb7.setEnabled(true);
Jcb8.setEnabled(false);
Jcb9.setEnabled(false);
Jcb10.setEnabled(false);

if(Jcb7.getSelectedIndex() == 0)
{ tf2.setText("3");
lb2.setText("GuitarPick - Hujan");
}

if(Jcb7.getSelectedIndex() == 1)
{ tf2.setText("4");
lb2.setText("GuitarPick - YAMAHA");
}

if(Jcb7.getSelectedIndex() == 2)
{ tf2.setText("3");
lb2.setText("GuitarPick - Rain");
}

if(Jcb7.getSelectedIndex() == 3)
{ tf2.setText("2");
lb2.setText("GuitarPick - CAP KAPAK");
}
}

if(t.equals("Guitar Bag"))
{ Jcb5.setEnabled(false);
Jcb6.setEnabled(false);
Jcb7.setEnabled(false);
Jcb8.setEnabled(true);
Jcb9.setEnabled(false);
Jcb10.setEnabled(false);

if(Jcb8.getSelectedIndex() == 0)
{ tf2.setText("50");
lb2.setText("Guitar Bag - Yamaha");
}

17
if(Jcb8.getSelectedIndex() == 1)
{ tf2.setText("20");
lb2.setText("Guitar Bag - Cap AYam");
}

if(Jcb8.getSelectedIndex() == 2)
{ tf2.setText("40");
lb2.setText("Guitar Bag - Kapok");
}
}

if(t.equals("Paddle Drum"))
{ Jcb5.setEnabled(false);
Jcb6.setEnabled(false);
Jcb7.setEnabled(false);
Jcb8.setEnabled(false);
Jcb9.setEnabled(true);
Jcb10.setEnabled(false);

if(Jcb9.getSelectedIndex() == 0)
{ tf2.setText("90");
lb2.setText("Paddle Drum - Kapok");
}

if(Jcb9.getSelectedIndex() == 1)
{ tf2.setText("80");
lb2.setText("Paddle Drum - RHYTHM");
}

if(Jcb9.getSelectedIndex() == 2)
{ tf2.setText("60");
lb2.setText("Paddle Drum - Goreng Sama");
}
}

if(t.equals("Microphone"))
{ Jcb5.setEnabled(false);
Jcb6.setEnabled(false);

18
Jcb7.setEnabled(false);
Jcb8.setEnabled(false);
Jcb9.setEnabled(false);
Jcb10.setEnabled(true);

if(Jcb10.getSelectedIndex() == 0)
{ tf2.setText("30");
lb2.setText("Microphone - CAP IBU DAN AYAH");
}

if(Jcb10.getSelectedIndex() == 1)
{ tf2.setText("70");
lb2.setText("Microphone - YAMAHA");
}

if(Jcb10.getSelectedIndex() == 2)
{ tf2.setText("50");
lb2.setText("Microphone - RHYTHM");
}
}

if(t.equals("CLICK TO CALCULATE"))
{ double total_1 = Double.parseDouble(tf1.getText().trim());
double total_2 = Double.parseDouble(tf2.getText().trim());
double total_3 = Double.parseDouble(tf3.getText().trim());
double discount =
Double.parseDouble(tf4.getText().trim());
double harga = total_1 + total_2 + total_3;
double totalSum = (harga - (harga * discount/100));

String totalprice = (new Double(totalSum)).toString();


tf5.setText(totalprice);
}

else if(t.equals("RESET"))
{ tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");

19
tf5.setText("");
lb1.setText("");
lb2.setText("");
lb3.setText("");
tf4.setText("enter discount");
}

else if(t.equals("NEXT TO SEE GALLERY"))


{ setVisible(false);
hhStore2 music = new hhStore2();
music.setTitle("H & H MUSIC STORE");
music.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
music.setSize(530,450);
music.setLocation(400,80);
music.setVisible(true);
}
}

public static void main(String[] args)


{ hhStore frame = new hhStore();
frame.setTitle("H&H MUSIC STORE");
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setSize(700,600);
frame.setVisible(true);
frame.setResizable(false);
}
}

20
hhStore1,java
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

public class hhStore1 extends JFrame implements ActionListener


{
private JPanel panel, panelbg, pn1, pn3, pnPix;
private JTextField tf1;
private JButton b1, b2;
private JCheckBox cb1;
private JLabel lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8;
hhStore abc = new hhStore();

public hhStore1()
{
Container kanvas = getContentPane();
kanvas.setLayout(new BorderLayout());
panel = new JPanel();
panelbg = new JPanel();
pn1 = new JPanel();
pn3 = new JPanel();
pnPix = new JPanel();
panel.setLayout(new GridLayout(1,1));
panelbg.setLayout(new BorderLayout());
pn1.setLayout(new GridLayout(5,1));
pn3.setLayout(new GridLayout(1,4));
pnPix.setLayout(new BorderLayout());
lb1 = new JLabel("H & H Music Store");
lb2 = new JLabel("At H & H Music Store, We Sell",
SwingConstants.CENTER);
lb3 = new JLabel("and Provide Rental Service of",
SwingConstants.CENTER);
lb4 = new JLabel("Our Musical Instruments as well",
SwingConstants.CENTER);
lb5 = new JLabel("as Rental of Jamming Studio.",
SwingConstants.CENTER);
lb6 = new JLabel("We Are Glad to Serve You",
SwingConstants.CENTER);
lb1.setFont(new Font("Magneto",Font.BOLD,30));
lb2.setFont(new Font("Jokerman",Font.BOLD,17));
lb3.setFont(new Font("Jokerman",Font.BOLD,17));
lb4.setFont(new Font("Jokerman",Font.BOLD,17));
lb5.setFont(new Font("Jokerman",Font.BOLD,17));
lb6.setFont(new Font("Jokerman",Font.BOLD,17));

lb1.setForeground(Color.red);
pn1.add(lb2);
pn1.add(lb3);
pn1.add(lb4);

21
pn1.add(lb5);
pn1.add(lb6);

pn1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtc
hedBorder(), "WELCOME "));

pnPix.setBorder(BorderFactory.createEtchedBorder());

lb7 = new JLabel("Enter Name :", SwingConstants.CENTER);


tf1 = new JTextField(20);
b1 = new JButton("OK");
b2 = new JButton("EXIT");

ImageIcon image = new ImageIcon("anigif.gif");


pnPix.add(new JLabel(image, SwingConstants.CENTER));

pn1.setOpaque(false);

pn3.add(lb7);
pn3.add(tf1);
pn3.add(b2);
pn3.add(b1);

panel.add(pn1);

panel.setOpaque(false);
pn3.setOpaque(false);

panelbg.add(lb1, BorderLayout.NORTH);
panelbg.add(panel);
panelbg.add(pn3, BorderLayout.SOUTH);
kanvas.add(panelbg, BorderLayout.CENTER);
kanvas.add(pnPix, BorderLayout.EAST);

b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent x){

String t = x.getActionCommand();

if(t.equals("OK"))
{ String out = "Information How To use This System \n"+"1st
- select 1 of the services \n"+"2nd - Select Accesories you want,
remember to click button after choose brand \n"+"3rd- Select repair
instrument,NONE if not \n"+"4th - Enter Discount then Calculate";
JOptionPane.showMessageDialog(null,out);
setVisible(false);
hhStore obj = new hhStore();
obj.setSize(700,600);
obj.setLocation(400,80);
obj.setVisible(true);
}
}

22
public static void main(String[]args){

hhStore1 music = new hhStore1();


music.setTitle("H & H MUSIC STORE");
music.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
music.setSize(520,450);
music.setLocation(400,80);
music.setVisible(true);
}
}

23
hhStore2,java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class hhStore2 extends JFrame implements ActionListener


{
private JPanel pnPix;
private JButton b1;

public hhStore2()
{
Container kanvas = getContentPane();
kanvas.setLayout(new BorderLayout());
b1 = new JButton("EXIT");

pnPix = new JPanel();


pnPix.setLayout(new BorderLayout());
ImageIcon image = new ImageIcon("anigif2.gif");
pnPix.add(new JLabel(image, SwingConstants.CENTER));

kanvas.add(pnPix, BorderLayout.CENTER);
kanvas.add(b1, BorderLayout.SOUTH);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String t = e.getActionCommand();

if(t.equals("EXIT"))
{System.exit(0);}
}
public static void main(String[]args){

hhStore2 music = new hhStore2();


music.setTitle("H & H MUSIC STORE");
music.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
music.setSize(530,450);
music.setLocation(400,80);
music.setVisible(true);
}
}

24
Output
Main window

Pop out window after ‘OK’ is clicked

25
Process window without input

26
Process window with input

27
Window appear when the ‘NEXT TO SEE GALLERY’ button is clicked

28