Source Code

// CS111 Group Project
// Members: John Hiew, Alex Chen
// Copyright (c) 1999 John Hiew & Alex Chen. All rights reserved.
// Virtual Java Shopper -- Version 1.0b.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class vshopper extends Applet
implements MouseListener, MouseMotionListener, ActionListener, ItemListener

{
private Image category[], cpu[], gfx[], snd[], spk[], misc[];
private List shoppingList;
private Panel panel;
int xPos, yPos, axPos, ayPos, dxPos, dyPos, cat, pro, total;
Button buy, remove, checkout;

public void init()
{
total = 0;

addMouseListener(this);
addMouseMotionListener(this);

setBackground(Color.white);
setLayout(null);

category = new Image[10];

buy = new Button("Add to shopping cart");
remove = new Button("Remove");
checkout = new Button("Check Out");
shoppingList = new List (10, false);

buy.addActionListener(this);
remove.addActionListener(this);
checkout.addActionListener(this);
shoppingList.addItemListener(this);
add(buy);
add(remove);
add(checkout);
add(shoppingList);

buy.setLocation(367,210);
buy.setSize(115,20);

remove.setLocation(140,365);
remove.setSize(60,20);

checkout.setLocation(210,365);
checkout.setSize(60,20);

shoppingList.setLocation(140,260);
shoppingList.setSize(350,100);

for (int i = 0; i < category.length; i++)
category[i]=getImage(getDocumentBase(),
"images/category/cat" + i + ".gif");

cpu = new Image[4];

for (int i = 0; i < cpu.length; i++)
cpu[i]=getImage(getDocumentBase(),
"images/cpu" + i + ".jpg");

gfx = new Image[4];

for (int i = 0; i < gfx.length; i++)
gfx[i]=getImage(getDocumentBase(),
"images/gfx" + i + ".jpg");

snd = new Image[4];

for (int i = 0; i < snd.length; i++)
snd[i]=getImage(getDocumentBase(),
"images/snd" + i + ".jpg");

spk = new Image[4];

for (int i = 0; i < spk.length; i++)
spk[i]=getImage(getDocumentBase(),
"images/spk" + i + ".jpg");

misc = new Image[4];

for (int i = 0; i < misc.length; i++)
misc[i]=getImage(getDocumentBase(),
"images/misc" + i + ".jpg");

}

public void update(Graphics g)
{ paint(g); }

public void start()
{
}

public void destroy()
{
removeMouseListener(this);
removeMouseMotionListener(this);
}

public void paint(Graphics g)
{
g.drawLine(0,0,599,0);
g.drawLine(0,399,599,399);
g.drawLine(0,0,0,399);
g.drawLine(599,0,599,399);

g.drawLine(20,80,99,80);
g.drawLine(20,159,99,159);
g.drawLine(20,238,99,238);
g.drawLine(20,317,99,317);
g.drawLine(20,396,99,396);

Image sidebar;
sidebar = getImage(getDocumentBase(),
"images/sidebar.gif");

g.drawImage(sidebar, 10, 80, this);

Image description;
description = getImage(getDocumentBase(),
"images/pro_description.gif");

g.drawImage(description, 120, 10, this);

Image background;
background = getImage(getDocumentBase(),
"images/background.jpg");

g.drawImage(background, 509, 1, this);


int catxPos = 10, catyPos = 10, k = 0;
for (int j = 0; j < 5; j++)
{
g.drawImage(category[j], catxPos, catyPos, this);
catyPos += 11;
}

catyPos = 10;

if (xPos >= 10 && xPos <= 110)
{
if (yPos >= 10 && yPos <= 21)
{ g.drawImage(category[5], catxPos, catyPos, this);
processors(g,20,80);
cat = 1;
}
else if (yPos >= 22 && yPos <= 33)
{ g.drawImage(category[6], catxPos, catyPos + 11, this);
graphicscard(g,20,80);
cat = 2;
}
else if (yPos >= 34 && yPos <= 45)
{ g.drawImage(category[7], catxPos, catyPos + 22, this);
soundcard(g,20,80);
cat = 3;
}
else if (yPos >= 46 && yPos <= 57)
{ g.drawImage(category[8], catxPos, catyPos + 33, this);
speakers(g,20,80);
cat = 4;
}
else if (yPos >= 58 && yPos <= 69)
{ g.drawImage(category[9], catxPos, catyPos + 44, this);
miscellaneous(g,20,80);
cat = 5;
}
}

g.drawRect(140,80,350,160);
g.setColor(new Color(255,255,197));
g.fillRect(141,81,349,159);

switch (cat)
{
case 1: {
g.setColor(new Color(255,255,197));
if (xPos >= 10 && xPos <= 90)
{
if (yPos >= 81 && yPos <= 160)
{ g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Intel Pentium III Processor - 500MHz",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("100MHz FSB",150,130);
g.drawString("512KB Cache",150,150);
g.drawString("new KNI instructions",150,170);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM1799",150,190);
pro = 11;
}

else if (yPos >= 161 && yPos <= 240)
{ g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Intel Pentium III Xeon Processor - 550MHz",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("100MHz FSB",150,130);
g.drawString("2MB Cache",150,150);
g.drawString("new KNI instructions",150,170);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM3799",150,190);
pro = 12;
}

else if (yPos >= 241 && yPos <= 320)
{ g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("AMD K6-2 3DNow! Processor - 450MHz",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("100MHz FSB, Super Socket7 Interface",150,130);
g.drawString("64KB L1-Internal Cache",150,150);
g.drawString("3DNow! instructions",150,170);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM520",150,190);
pro = 13;
}

else if (yPos >= 321 && yPos <= 400)
{ g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("AMD K6-3 3DNow! Processor - 500MHz",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("100MHz FSB, Super Socket7 Interface",150,130);
g.drawString("256KB L2-On Die Cache",150,150);
g.drawString("3DNow! instructions",150,170);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM1799",150,190);
pro = 14;
}

} break; }

case 2: {
g.setColor(new Color(255,255,197));
if (xPos >= 10 && xPos <= 90)
{
if (yPos >= 81 && yPos <= 160)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Creative Riva TNT2 Ultra",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("150/183MHz Core/Memory Clock Speed",150,130);
g.drawString("32MB Frame buffer/Dedicated Texture Memory",150,150);
g.drawString("TV-out function",150,170);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM789",150,190);
pro = 21;
}

else if (yPos >= 161 && yPos <= 240)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Diamond Viper 770 Ultra",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("150/183MHz Core/Memory Clock Speed",150,130);
g.drawString("32MB Frame buffer/Dedicated Texture Memory",150,150);
g.drawString("TV-out function",150,170);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM899",150,190);
pro = 22;
}

else if (yPos >= 241 && yPos <= 320)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("3Dfx Voodoo3 3000",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("200MHz Core/Memory Clock Speed",150,130);
g.drawString("16MB Frame buffer/Dedicated Texture Memory",150,150);
g.drawString("Glide/OpengL/Direct3D support",150,170);
g.drawString("TV-out function",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM799",150,210);
pro = 23;
}

else if (yPos >= 321 && yPos <= 400)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("ATI Rage Fury",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("ATI Rage 128-bit chipset",150,130);
g.drawString("32MB Frame buffer/Dedicated Texture Memory",150,150);
g.drawString("TV-out function",150,170);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM550",150,190);
pro = 24;
}


} break; }

case 3: {
g.setColor(new Color(255,255,197));
if (xPos >= 10 && xPos <= 90)
{
if (yPos >= 81 && yPos <= 160)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Diamond Monster Sound MX300",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("Aureal Vortex A3D2.0 Chipset",150,130);
g.drawString("4MB Onboard instrument set",150,150);
g.drawString("Exceptional 3D Positional Audio",150,170);
g.drawString("10-band Graphic Equalizer",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM399",150,210);
pro = 31;
}

else if (yPos >= 161 && yPos <= 240)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Sound Blaster Live!",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("EMU10K Chipset",150,130);
g.drawString("4MB Onboard instrument set",150,150);
g.drawString("Environmental Audio Effects",150,170);
g.drawString("Digital Daughtercard",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM688",150,210);
pro = 32;
}

else if (yPos >= 241 && yPos <= 320)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Sound Blaster Live! Value",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("EMU10K1 Chipset",150,130);
g.drawString("4MB Onboard instrument set",150,150);
g.drawString("Environmental Audio Effects",150,170);
g.drawString("Best Value",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM230",150,210);
pro = 33;
}

else if (yPos >= 321 && yPos <= 400)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Yamaha Waveforce 192XG",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("SoundBlaster Pro Compatibility",150,130);
g.drawString("192-Note Polyphony",150,150);
g.drawString("676 Instruments / 21 Drum Kits",150,170);
g.drawString("PCI Bus Technology",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM200",150,210);
pro = 34;
}

} break; }

case 4: {
g.setColor(new Color(255,255,197));
if (xPos >= 10 && xPos <= 90)
{
if (yPos >= 81 && yPos <= 160)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Altec Lansing PowerCube ACS45.1",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("4-inch Long Throw Subwoofer",150,130);
g.drawString("1x 3in full-range driver per satellite",150,150);
g.drawString("6 Watts per satellite / 20 Watts Subwoofer",150,170);
g.drawString("Best Value, Excellent Performance",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM299",150,210);
pro = 41;
}

else if (yPos >= 161 && yPos <= 240)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Altec Lansing PowerCube ACS48",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("6-inch Long Throw Subwoofer",150,130);
g.drawString("1x 3in full-range / 1x 3/4in tweeter per satellite",150,150);
g.drawString("20 Watts per satellite / 40 Watts Subwoofer",150,170);
g.drawString("Excellent, room-shaking bass",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM699",150,210);
pro = 42;
}

else if (yPos >= 241 && yPos <= 320)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Altec Lansing PowerPlay Plus ACS54",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("4-inch Long Throw Subwoofer",150,130);
g.drawString("1x 3in full-range driver per satellite",150,150);
g.drawString("5 Watts per satellite / 20 Watts Subwoofer",150,170);
g.drawString("Gaming-geared 5-piece System",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM399",150,210);
pro = 43;
}

else if (yPos >= 321 && yPos <= 400)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Altec Lansing Home Theater ADA106",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("8-inch Long Throw Subwoofer",150,130);
g.drawString("5 x 3in full-range driver / 2 x 1in tweeter ",150,150);
g.drawString("20 Watts per satellite / 50 Watts Subwoofer",150,170);
g.drawString("Convenient, Powerful Home Theater Experience",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM3099",150,210);
pro = 44;
}

} break; }

case 5: {
g.setColor(new Color(255,255,197));
if (xPos >= 10 && xPos <= 90)
{
if (yPos >= 81 && yPos <= 160)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("AverMedia TV Genie with Remote Control",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("Watch TV on your desktop",150,130);
g.drawString("181-Channel TV Tuner",150,150);
g.drawString("Full Remote Control",150,170);
g.drawString("External Interface",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM499",150,210);
pro = 51;
}

else if (yPos >= 161 && yPos <= 240)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("AverMedia Fun TV Lite",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("Watch TV on your desktop",150,130);
g.drawString("Monitor Stock Market, News, or Sport",150,150);
g.drawString("Multimedia Presentation System",150,170);
g.drawString("Security & Surveillance System",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM399",150,210);
pro = 52;
}

else if (yPos >= 241 && yPos <= 320)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("AverMedia TV Phone",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("Watch TV on your desktop",150,130);
g.drawString("Listen to FM Radio",150,150);
g.drawString("Captures Video/Audio",150,170);
g.drawString("Internet/Intranet Video Conferencing",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM599",150,210);
pro = 53;
}

else if (yPos >= 321 && yPos <= 400)
{
g.fillRect(141,81,349,159);
g.setColor(Color.darkGray);
g.setFont(new Font("Arial", Font.PLAIN, 18) );
g.drawString("Opti UPS PowerES 640VA/650W",150,105);
g.setColor(Color.black);
g.drawLine(140,110,490,110);
g.setFont(new Font("Arial", Font.PLAIN, 10) );
g.drawString("Dataline Protection",150,130);
g.drawString("Adjustable Low/High Voltage Transfer Point",150,150);
g.drawString("Auto-Shutdown with software suite",150,170);
g.drawString("Schedule Reboot & Remote Shutdown",150,190);
g.setFont(new Font("Arial", Font.PLAIN, 14) );
g.drawString("RM1299",150,210);
pro = 54;
}

} break; }

}

g.setColor(new Color(83,124,178));
g.fillRect(380,366,110,18);
g.setColor(Color.white);
g.setFont(new Font("Arial", Font.BOLD, 14) );
g.drawString("Total: RM"+total,383,380);

drawBar(g, axPos, ayPos);
}

private void drawBar(Graphics g, int axPos, int ayPos)
{
if (axPos >= 20 && axPos <= 100)
{
if (ayPos >= 81 && ayPos <= 160)
{ g.setColor(new Color(83,124,178));
g.fillRect(100,80,10,317);
g.setColor(new Color(102,153,255));
g.fillRect(100,80,10,79); }
else if (ayPos >= 161 && ayPos <= 240)
{ g.setColor(new Color(83,124,178));
g.fillRect(100,80,10,317);
g.setColor(new Color(102,153,255));
g.fillRect(100,159,10,79); }
else if (ayPos >= 241 && ayPos <= 300)
{ g.setColor(new Color(83,124,178));
g.fillRect(100,80,10,317);
g.setColor(new Color(102,153,255));
g.fillRect(100,238,10,79); }
else if (ayPos >= 301 && ayPos <= 360)
{ g.setColor(new Color(83,124,178));
g.fillRect(100,80,10,317);
g.setColor(new Color(102,153,255));
g.fillRect(100,317,10,79); }
}
else
{ g.setColor(new Color(83,124,178));
g.fillRect(100,80,10,317); }


}

private void processors(Graphics g, int pxPos, int pyPos)
{
for (int q = 0; q < 4; q++)
{
g.drawImage(cpu[q], pxPos, pyPos, this);
pyPos += 79;
}
}

private void graphicscard(Graphics g, int pxPos, int pyPos)
{
for (int q = 0; q < 4; q++)
{
g.drawImage(gfx[q], pxPos, pyPos, this);
pyPos += 79;
}
}

private void soundcard(Graphics g, int pxPos, int pyPos)
{
for (int q = 0; q < 4; q++)
{
g.drawImage(snd[q], pxPos, pyPos, this);
pyPos += 79;
}
}

private void speakers(Graphics g, int pxPos, int pyPos)
{
for (int q = 0; q < 4; q++)
{
g.drawImage(spk[q], pxPos, pyPos, this);
pyPos += 79;
}
}

private void miscellaneous(Graphics g, int pxPos, int pyPos)
{
for (int q = 0; q < 4; q++)
{
g.drawImage(misc[q], pxPos, pyPos, this);
pyPos += 79;
}
}

private void pressLocation(int x, int y)
{
xPos = x;
yPos = y;
repaint();
}

private void floatLocation(int a, int b)
{
axPos = a;
ayPos = b;
repaint();
}

public void actionPerformed(ActionEvent e)
{
switch (pro)
{
case 11:
{
if (e.getSource() == buy)
{
shoppingList.add("Intel Pentium III 500MHz - RM1799");
total += 1799;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Intel Pentium III 500MHz - RM1799");
total -= 1799;
}
break;
}

case 12:
{
if (e.getSource() == buy)
{
shoppingList.add("Intel Pentium III Xeon 550MHz - RM3799");
total += 3799;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Intel Pentium III Xeon 550MHz - RM3799");
total -= 3799;
}
break;
}

case 13:
{
if (e.getSource() == buy)
{
shoppingList.add("AMD K6-2 3DNow! 450MHz - RM520");
total += 520;
}
else if (e.getSource() == remove)
{
shoppingList.remove("AMD K6-2 3DNow! 450MHz - RM520");
total -= 520;
}
break;
}

case 14:
{
if (e.getSource() == buy)
{
shoppingList.add("AMD K6-3 3DNow! 500MHz - RM799");
total += 799;
}
else if (e.getSource() == remove)
{
shoppingList.remove("AMD K6-3 3DNow! 500MHz - RM799");
total -= 799;
}
break;
}

case 21:
{
if (e.getSource() == buy)
{
shoppingList.add("Creative Riva TNT2 Ultra - RM789");
total += 789;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Creative Riva TNT2 Ultra - RM789");
total -= 789;
}
break;
}

case 22:
{
if (e.getSource() == buy)
{
shoppingList.add("Diamond Viper 770 Ultra - RM899");
total += 899;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Diamond Viper 770 Ultra - RM899");
total -= 899;
}
break;
}

case 23:
{
if (e.getSource() == buy)
{
shoppingList.add("3Dfx Voodoo3 3000 - RM799");
total += 799;
}
else if (e.getSource() == remove)
{
shoppingList.remove("3Dfx Voodoo3 3000 - RM799");
total -= 799;
}
break;
}

case 24:
{
if (e.getSource() == buy)
{
shoppingList.add("ATI Rage Fury - RM550");
total += 550;
}
else if (e.getSource() == remove)
{
shoppingList.remove("ATI Rage Fury - RM550");
total -= 550;
}
break;
}

case 31:
{
if (e.getSource() == buy)
{
shoppingList.add("Diamond Monster Sound MX300 - RM399");
total += 399;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Diamond Monster Sound MX300 - RM399");
total -= 399;
}
break;
}

case 32:
{
if (e.getSource() == buy)
{
shoppingList.add("Creative SoundBlaster Live! - RM688");
total += 688;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Creative SoundBlaster Live! - RM688");
total -= 688;
}
break;
}

case 33:
{
if (e.getSource() == buy)
{
shoppingList.add("Creative SoundBlaster Live! Value - RM230");
total += 230;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Creative SoundBlaster Live! Value - RM230");
total -= 230;
}
break;
}

case 34:
{
if (e.getSource() == buy)
{
shoppingList.add("Yamaha WaveForce 192XG - RM200");
total += 200;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Yamaha WaveForce 192XG - RM200");
total -= 200;
}
break;
}

case 41:
{
if (e.getSource() == buy)
{
shoppingList.add("Altec Lansing PowerCube ACS45.1 - RM299");
total += 299;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Altec Lansing PowerCube ACS45.1 - RM299");
total -= 299;
}
break;
}

case 42:
{
if (e.getSource() == buy)
{
shoppingList.add("Altec Lansing PowerCube ACS48 - RM699");
total += 699;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Altec Lansing PowerCube ACS48 - RM699");
total -= 699;
}
break;
}

case 43:
{
if (e.getSource() == buy)
{
shoppingList.add("Altec Lansing PowerPlay Plus ACS54 - RM399");
total += 399;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Altec Lansing PowerPlay Plus ACS54 - RM399");
total -= 399;
}
break;
}

case 44:
{
if (e.getSource() == buy)
{
shoppingList.add("Altec Lansing Home Theater ADA106 - 3099");
total += 3099;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Altec Lansing Home Theater ADA106 - 3099");
total -= 3099;
}
break;
}

case 51:
{
if (e.getSource() == buy)
{
shoppingList.add("AverMedia TV Genie with Remote Control - RM499");
total += 499;
}
else if (e.getSource() == remove)
{
shoppingList.remove("AverMedia TV Genie with Remote Control - RM499");
total -= 499;
}
break;
}

case 52:
{
if (e.getSource() == buy)
{
shoppingList.add("AverMedia Fun TV Lite - RM399");
total += 399;
}
else if (e.getSource() == remove)
{
shoppingList.remove("AverMedia Fun TV Lite - RM399");
total -= 399;
}
break;
}

case 53:
{
if (e.getSource() == buy)
{
shoppingList.add("AverMedia TV Phone - RM599");
total += 599;
}
else if (e.getSource() == remove)
{
shoppingList.remove("AverMedia TV Phone - RM599");
total -= 599;
}
break;
}

case 54:
{
if (e.getSource() == buy)
{
shoppingList.add("Opti UPS PowerES 640VA/650W - RM1299");
total += 1299;
}
else if (e.getSource() == remove)
{
shoppingList.remove("Opti UPS PowerES 640VA/650W - RM1299");
total -= 1299;
}
break;
}
}

if (e.getSource() == checkout)
{
showStatus("Feature not available at this moment.");
}

repaint();

}

public void itemStateChanged(ItemEvent e)
{
if ("Intel Pentium III 500MHz - RM1799"== shoppingList.getSelectedItem())
pro = 11;
else if ("Intel Pentium III Xeon 550MHz - RM3799"== shoppingList.getSelectedItem())
pro = 12;
else if ("AMD K6-2 3DNow! 450MHz - RM520"== shoppingList.getSelectedItem())
pro = 13;
else if ("AMD K6-3 3DNow! 500MHz - RM799"== shoppingList.getSelectedItem())
pro = 14;
else if ("Creative Riva TNT2 Ultra - RM789"== shoppingList.getSelectedItem())
pro = 21;
else if ("Diamond Viper 770 Ultra - RM899"== shoppingList.getSelectedItem())
pro = 22;
else if ("3Dfx Voodoo3 3000 - RM799"== shoppingList.getSelectedItem())
pro = 23;
else if ("ATI Rage Fury - RM550"== shoppingList.getSelectedItem())
pro = 24;
else if ("Diamond Monster Sound MX300 - RM399"== shoppingList.getSelectedItem())
pro = 31;
else if ("Creative SoundBlaster Live! - RM688"== shoppingList.getSelectedItem())
pro = 32;
else if ("Creative SoundBlaster Live! Value - RM230"== shoppingList.getSelectedItem())
pro = 33;
else if ("Yamaha WaveForce 192XG - RM200"== shoppingList.getSelectedItem())
pro = 34;
else if ("Altec Lansing PowerCube ACS45.1 - RM299"== shoppingList.getSelectedItem())
pro = 41;
else if ("Altec Lansing PowerCube ACS48 - RM699"== shoppingList.getSelectedItem())
pro = 42;
else if ("Altec Lansing PowerPlay Plus ACS54 - RM399"== shoppingList.getSelectedItem())
pro = 43;
else if ("Altec Lansing Home Theater ADA106 - 3099"== shoppingList.getSelectedItem())
pro = 44;
else if ("AverMedia TV Genie with Remote Control - RM499"== shoppingList.getSelectedItem())
pro = 51;
else if ("AverMedia Fun TV Lite - RM399"== shoppingList.getSelectedItem())
pro = 52;
else if ("AverMedia TV Phone - RM599"== shoppingList.getSelectedItem())
pro = 53;
else if ("Opti UPS PowerES 640VA/650W - RM1299"== shoppingList.getSelectedItem())
pro = 54;
}

public void mouseClicked(MouseEvent e){}

public void mouseMoved(MouseEvent e)
{
floatLocation(e.getX(), e.getY());
}

public void mousePressed(MouseEvent e)
{
pressLocation(e.getX(), e.getY());
}

public void mouseDragged(MouseEvent e){}

public void mouseReleased(MouseEvent e){}

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}
}

< | Back to contents