I have this code that i used for shoopping and adding to cart. but the problem here is that when i add to cart it'll not display the artist song that i choose and add 'em to cart rather it uses the one from another class.

Please how do i make it to perform an action like this
if i choose fergi.....add to car.

shooping cart....

fergie....big girls dont cry ......$56
" hit em up $43

here's the code snipet...
and how do i show the artist picture when i click on fergie , how do i make the action listener to show her album art. Date and time at the left hand corner of this.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.Calendar;
/*
<applet code=" The.class" height=20 width=20>
</applet>
*/
public class The extends JApplet implements  ActionListener
{
/*D V*/
JPanel panel;
JLabel lo;
JLabel bo;
JLabel wo;
JLabel yo;
JLabel b1; 
JLabel l1;
JLabel l2;
JLabel display;
ImageIcon LO;
ImageIcon LO1;
ImageIcon LO2;
ImageIcon LO3;
JButton classic;
JButton western;
JButton pop;
JButton jazz;
JButton add;
JCheckBox tilo; 
JCheckBox tila;
JCheckBox tilu;
JCheckBox tile;
JCheckBox tili;
JComboBox cbta;
JTextField bu;
Font f;
GridBagLayout g;
GridBagConstraints gbc;
public void init()
{
/*I L V*/
g=new GridBagLayout(); 
gbc=new GridBagConstraints();
panel=(JPanel)getContentPane();
panel.setLayout(g);
Icon LogoImage=new ImageIcon("c:/project/music on.gif");
//you will mention the path of your jpg file
         l1=new JLabel(); 
         gbc.anchor=GridBagConstraints.EAST;
         gbc.ipady=2;
         gbc.ipadx=4;
         gbc.gridx=4;
         gbc.gridy=4;
         g.setConstraints(l1,gbc);
         panel.add(l1);
panel.setBackground(Color.blue);
/*A C P*/
classic=new JButton("Classic");
gbc.fill=GridBagConstraints.BOTH;
classic.setForeground(Color.red);
classic.setBackground(Color.blue);
    gbc.ipady=2 ;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=3;
g.setConstraints(classic, gbc);
panel.add(classic);
tilo=new JCheckBox("Gwen Stefani");
tilo.setForeground(Color.red);
tilo.setBackground (Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=3;
g.setConstraints(tilo, gbc);
panel.add(tilo);
setSize(6000,9000);
/*A C P*/
western=new JButton("Western"); 
western.setForeground(Color.red);
western.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=4;
g.setConstraints(western, gbc);
panel.add(western);
tila=new JCheckBox("topee");
tila.setForeground(Color.red);
tila.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=4;
g.setConstraints(tila, gbc); 
panel.add(tila);
/*A C P*/
pop=new JButton("Pop");
pop.setForeground(Color.red);
pop.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=5; 
g.setConstraints(pop, gbc);
panel.add(pop);

tilu=new JCheckBox("Fergie");
tilu.setForeground(Color.red);
tilu.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2 ;
    gbc.gridy=5;
g.setConstraints(tilu, gbc);
panel.add(tilu);

/*A C P*/
jazz=new JButton("Jazz");
jazz.setForeground(Color.red);
jazz.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=6;
g.setConstraints(jazz, gbc);
panel.add(jazz);
tile=new JCheckBox("10/12/07 10:25");
tile.setForeground(Color.red);
tile.setBackground(Color.blue );
    gbc.ipady=1;
    gbc.ipadx=1;
    gbc.gridx=1;
    gbc.gridy=7;
g.setConstraints(tile, gbc);
panel.add(tile);
/*A C P*/
add=new JButton("Add to cart");
add.setForeground(Color.blue );
add.setBackground(Color.green);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=4;
    gbc.gridy=7;
g.setConstraints(add, gbc);
panel.add(add);

/*A C P*/
lo=new JLabel("select the category"); 
lo.setForeground(Color.red);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=2;
g.setConstraints(lo, gbc);
lo.setFont(new Font("Helvetical",Font.BOLD,15));
panel.add (lo);
bo=new JLabel("List of all");
bo.setForeground(Color.red);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=2;
g.setConstraints(bo, gbc);
panel.add(bo);
tili=new JCheckBox("Funke"); 
tili.setForeground(Color.red);
tili.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=6;
g.setConstraints(tili, gbc);
panel.add(tili);
/*I M*/
LO=new ImageIcon("c:/project/Rihanna.gif"); 
LO2=new ImageIcon("c:/project/Gwen Stefani.gif");
LO3=new ImageIcon("c:/project/Christina Milian.gif");
LO1=new ImageIcon("c:/project/Fergie.gif");
display = new JLabel();
    gbc.anchor = GridBagConstraints.LINE_END;
   gbc.gridx = 4;
   gbc.gridy = 4;
   gbc.ipadx = 3;
   gbc.ipady = 4;
   g.setConstraints(display, gbc);
   panel.add(display);
Icon logoImage=new ImageIcon("c:/project/music on.gif");
 b1=new JLabel(logoImage);
 gbc.anchor=GridBagConstraints.NORTHEAST;
         gbc.ipady=2;
         gbc.ipadx=2;
         gbc.gridx=4;
         gbc.gridy=1;
         g.setConstraints (b1,gbc);
         panel.add(b1);
classic.addActionListener(this);
western.addActionListener(this);
pop.addActionListener(this);
jazz.addActionListener(this);
tilo.addActionListener(this);
add.addActionListener (this);
}
public void actionPerformed(ActionEvent ae)
{
Object o=ae.getSource();
if(o==classic)
{
display.setIcon(LO);
tilo.setText("Fergie");
tila.setText("Christina Milian"); 
tilu.setText("Rihanna");
tili.setText("Lagbaja");
}
if(o==western)
{
display.setIcon(LO1);
tilo.setText("Funke");
tila.setText("Keinde");
tilu.setText("T-pain"); 
tili.setText("Topee");
}
if(o==pop)
{
display.setIcon(LO2);
tilo.setText("Pink");
tila.setText("Britney Spears");
tilu.setText("Limbizkit");
tili.setText ("Kelly Clarkson");
}
if(o==jazz)
{
display.setIcon(LO3);
tilo.setText("Kenny G");
tila.setText("Yenny");
tilu.setText("JazzMan");
tili.setText("Lenny"); 
}
if(add==o)
{
Add myadd = new Add();

       /*start changes*/
       myadd.init();
       myadd.start();

     int compCount = panel.getComponentCount();
     java.util.Vector componentList = new java.util.Vector();
     for(int i = 0; i < compCount; i++)
        {
        Component c = panel.getComponent(i);
        componentList.addElement(c);
       }

     for(int i = 0; i < componentList.size (); i++)
       {
        Component c = (Component)componentList.elementAt(i);
        panel.remove(c);
       }

    panel.add(myadd);

     //use this method for thread safety
     java.awt.EventQueue.invokeLater (new Runnable()
       {
        public void run() {
           javax.swing.SwingUtilities.updateComponentTreeUI(The.this);
               }
     });
     /*end changes*/
{

---------------------------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
/*
<applet code="Too.class" height=20 width=20> 
</applet>
*/
public class Too extends JApplet implements  ActionListener
{
/*D V*/
JPanel panel;
JLabel lo;
JLabel bo;
JLabel wo;
JLabel yo;
JLabel b1;
JLabel l1;
JLabel l2;
JLabel display;
ImageIcon LO;
ImageIcon LO1;
ImageIcon LO2;
ImageIcon LO3;
JButton classic;
JButton western;
JButton pop;
JButton jazz;
JButton add;
JCheckBox tilo;
JCheckBox tila;
JCheckBox tilu; 
JCheckBox tile;
JCheckBox tili;
JComboBox cbta;
JTextField bu;
Font f;
GridBagLayout g;
GridBagConstraints gbc;
public void init()
{
/*I L V*/
g=new GridBagLayout();
gbc=new GridBagConstraints(); 
panel=(JPanel)getContentPane();
panel.setLayout(g);
/*A C P*/
classic=new JButton("Classic");
gbc.fill=GridBagConstraints.BOTH;
classic.setForeground(Color.red);
classic.setBackground(Color.blue );
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=2;
g.setConstraints(classic, gbc);
panel.add(classic);
tilo=new JCheckBox("");
tilo.setForeground(Color.blue);
tilo.setBackground (Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=2;
g.setConstraints(tilo, gbc);
panel.add(tilo);
setSize(6000,9000);
/*A C P*/
western=new JButton("Western"); 
western.setForeground(Color.red);
western.setBackground(Color.yellow);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=3;
g.setConstraints(western, gbc);
panel.add(western);
tila=new JCheckBox("David amstrong");
tila.setForeground(Color.blue);
tila.setBackground(Color.yellow);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=3;
g.setConstraints (tila, gbc);
panel.add(tila);
/*A C P*/
pop=new JButton("Pop");
pop.setForeground(Color.red);
pop.setBackground(Color.yellow);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=4;
g.setConstraints(pop, gbc);
panel.add(pop);

tilu=new JCheckBox("Tony Braxson");
tilu.setForeground(Color.blue);
tilu.setBackground(Color.yellow);
    gbc.ipady=2;
    gbc.ipadx=2 ;
    gbc.gridx=2;
    gbc.gridy=4;
g.setConstraints(tilu, gbc);
panel.add(tilu);

/*A C P*/
jazz=new JButton("Jazz");
jazz.setForeground(Color.red);
jazz.setBackground(Color.yellow); 
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=5;
g.setConstraints(jazz, gbc);
panel.add(jazz);
tile=new JCheckBox("10/07/07 10:25");
tile.setForeground(Color.red); 
tile.setBackground(Color.yellow);
    gbc.ipady=1;
    gbc.ipadx=1;
    gbc.gridx=1;
    gbc.gridy=6;
g.setConstraints(tile, gbc);
panel.add(tile);
/*A C P*/
add=new JButton("Add to cart"); 
add.setForeground(Color.blue);
add.setBackground(Color.green);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=4;
    gbc.gridy=6;
g.setConstraints(add, gbc);
panel.add(add);

/*A C P*/
lo=new JLabel("select the category");
lo.setForeground(Color.red);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=1;
    gbc.gridy=1;
g.setConstraints(lo, gbc);
lo.setFont(new Font("Helvetical", Font.BOLD,15));
panel.add(lo);
bo=new JLabel("List of all");
bo.setForeground(Color.red);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=1;
g.setConstraints(bo, gbc); 
panel.add(bo);
tili=new JCheckBox("Y clef");
tili.setForeground(Color.blue);
tili.setBackground(Color.yellow);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=2;
    gbc.gridy=5;
g.setConstraints(tili, gbc);
panel.add(tili);
/*I M*/
LO=new ImageIcon("c:/olu/4.jpg");
LO2=new ImageIcon("c:/olu/1.gif");
LO3=new ImageIcon("c:/olu/Ani.gif");
LO1=new ImageIcon("c:/olu/r.gif"); 

   display = new JLabel();
   gbc.anchor = GridBagConstraints.LINE_END;
   gbc.gridx = 3;
   gbc.gridy = 3;    gbc.ipadx = 3;
   gbc.ipady = 3;
   g.setConstraints(display, gbc);
   panel.add (display);
Icon logoImage=new ImageIcon("c:/olu/2.gif");
 b1=new JLabel(logoImage);
 gbc.anchor=GridBagConstraints.NORTHEAST;
         gbc.ipady=2;
         gbc.ipadx=2;
         gbc.gridx=3 ;
         gbc.gridy=1;
         g.setConstraints(b1,gbc);
         panel.add(b1);
panel.setBackground(Color.yellow);
classic.addActionListener(this);
western.addActionListener(this);
pop.addActionListener (this);
jazz.addActionListener(this);
tilo.addActionListener(this);
add.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
Object o=ae.getSource();
if(o==classic)
{
display.setIcon (LO);
tilo.setText("Tony Bmany");
tila.setText("Jonny allinson");
tilu.setText("Bobby clue");
tili.setText("Lagbaja");
}
if(o==western)
{
display.setIcon(LO1); 
tilo.setText("Y cleff");
tila.setText("R kelly");
tilu.setText("ike clolins");
tili.setText("Plantason");
}
if(o==pop)
{
display.setIcon(LO2);
tilo.setText ("Brasxon");
tila.setText("Nelly coll");
tilu.setText("Psquare");
tili.setText("2pac chacole");
}
if(o==jazz)
{
display.setIcon(LO3);
tilo.setText("Olandoowo"); 
tila.setText("M.jackson");
tilu.setText("cyclear O");
tili.setText("Billy nnot");
}
if(add==o)
{
Add myadd = new Add();

       /*start changes*/
       myadd.init ();
       myadd.start();

     int compCount = panel.getComponentCount();
     java.util.Vector componentList = new java.util.Vector();
     for(int i = 0; i < compCount; i++)
        {
        Component c = panel.getComponent(i);
        componentList.addElement(c);
       }

     for(int i = 0; i < componentList.size(); i++)
       {
        Component c = (Component)componentList.elementAt(i);
        panel.remove(c);
       }

    panel.add(myadd);

     //use this method for thread safety
     java.awt.EventQueue.invokeLater(new Runnable()
       {
        public void run() {
            javax.swing.SwingUtilities.updateComponentTreeUI(Too.this);
               }
     });
     /*end changes*/
}
}
}
-------------------------------------------
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.event.*;
/*
<applet code="Buy.class" height=300 width=300>
</applet>
*/
public class Buy extends JApplet implements ActionListener
{
/*D V*/
JPanel panel;
JLabel lo; 
JButton love;
JButton hate;
JCheckBox tilo;
JCheckBox tila;
JCheckBox tilu;
GridBagLayout g;
GridBagConstraints gbc;
public void init()
{
/*I L V*/
g=new GridBagLayout();
gbc=new GridBagConstraints(); 
panel=(JPanel)getContentPane();
panel.setLayout(g);
/*A C P*/
love=new JButton("Please Select Payment Mode");
gbc.fill=GridBagConstraints.BOTH;
love.setForeground(Color.red);
love.setBackground (Color.green);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=0;
    gbc.gridy=1;
g.setConstraints(love, gbc);
panel.add(love);
panel.setBackground(Color.blue);
/*A C C*/
tilo=new JCheckBox("Demand Draft"); 
tilo.setForeground(Color.red);
tilo.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=0;
    gbc.gridy=2;
g.setConstraints(tilo, gbc);
panel.add(tilo);
/*A C C*/
tila=new JCheckBox("Cash On Delivery(COD)");
tila.setForeground(Color.red);
tila.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=0;
    gbc.gridy=3;
g.setConstraints (tila, gbc);
panel.add(tila);
/*A C C*/
tilu=new JCheckBox("Creadit Card");
tilu.setForeground(Color.red);
tilu.setBackground(Color.blue);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=0 ;
    gbc.gridy=4;
g.setConstraints(tilu, gbc);
panel.add(tilu);
/*A C P*/
hate=new JButton("OK");
gbc.fill=GridBagConstraints.BOTH;
hate.setForeground(Color.red);
hate.setBackground(Color.blue );
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=9;
    gbc.gridy=5;
g.setConstraints(hate, gbc);
panel.add(hate);
hate.addActionListener(this);
/*A C P*/
lo=new JLabel("TO PLACE ORDER"); 
lo.setForeground(Color.red);
lo.setBackground(Color.green);
    gbc.ipady=2;
    gbc.ipadx=2;
    gbc.gridx=0;
    gbc.gridy=0;
g.setConstraints(lo, gbc);
panel.add(lo);
lo.setFont(new Font("Arial", Font.BOLD,18));
tilo.addActionListener(this);
tilu.addActionListener(this);
tila.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
Object o=ae.getSource();
if(tilo==o)
{
tila.setText("*");
tilu.setText("*");
tilo.setText("Demand Draft");
}
if(tila==o)
{
tilo.setText("*");
tilu.setText("*");
tila.setText("Cash On Delivery(COD)"); 
}
if(tilu==o)
{
tilo.setText("*");
tila.setText("*");
tilu.setText("Credit Card");
}
{
       boolean tlo=!tilo.isSelected();
       boolean tlu=!tilu.isSelected(); 
       boolean tla=!tila.isSelected();
       if(o==hate)
       {
       if((tlo)&&(tlu)&&(tla)){
       JOptionPane.showMessageDialog(this,new
              String("Choose one mode!")); 
            return;}
}
if(hate==o)
{
thanks myadd = new thanks();

       /*start changes*/
       myadd.init();
       myadd.start();

     int compCount = panel.getComponentCount(); 
     java.util.Vector componentList = new java.util.Vector();
     for(int i = 0; i < compCount; i++)
        {
        Component c = panel.getComponent(i);
        componentList.addElement(c);
       }

     for(int i = 0; i < componentList.size(); i++)
       {
        Component c = (Component)componentList.elementAt(i);
        panel.remove(c);
       }

    panel.add(myadd); 

     //use this method for thread safety
     java.awt.EventQueue.invokeLater(new Runnable()
       {
        public void run() {
           javax.swing.SwingUtilities.updateComponentTreeUI(Buy.this );
               }
     });
     /*end changes*/
}
}
}
}

i am totally lost here...

still need help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.