Hi javaAddict.
OP has a panel (class DescriptionPanel)already populated with components, so all he needs to do is to create the JFrame, add an instance of his DescriptionPanel and make the JFrame visible.

If we all go back to the OP's very first post - that's exactly what his original code wasdoing, it's just one line of declaration failed to reference his DescriptionPanel class properly.

You are right to what you are saying and I am aware with the code the OP was using. But since it was so confusing, and we have seen different codes in various places in this thread I thought it would be a good idea to give the general idea and wait for the posters latest code.

wht do i have to do now?

wht do i have to do now?

You have your extended JPanel. Add whatever you want to be displayed to it. Then create an instance of it and add it to a JFrame, or your extended JFrame. Then make that JFrame visible. You already do what I just described in your original code. The problem was with the JPanel class. Just give it a try.

/**
 * @(#)DescriptionPanel.java
 *
 *
 * @author 
 * @version 1.00 2010/10/8
 */
import javax.swing.*;
import java.awt.*;


public class DescriptionPanel {
	
private JLabel imageText=new JLabel();
private JTextArea tdes=new JTextArea();

    public DescriptionPanel() {
    	
    imageText.setHorizontalAlignment(JLabel.CENTER);
   imageText.setHorizontalTextPosition(JLabel.CENTER);
    imageText.setVerticalTextPosition(JLabel.BOTTOM);
    
    imageText.setFont(new Font("Sanserif",Font.BOLD,16));
    tdes.setFont(new Font("Sanserif",Font.BOLD,16));
    
    tdes.setLineWrap(true);
    tdes.setWrapStyleWord(true);
    tdes.setEditable(false);
    
    JScrollPane scroll=new JScrollPane(tdes);
    
    setLayout(new BorderLayout(5,5));
    add(scroll, BorderLayout.CENTER);
    add(tdes,BorderLayout.WEST);
    }
    
    public void setTitle(String title){
    	imageText.setText(title);
    }
    
    public void setImageIcon(ImageIcon icon){
    	imageText.setIcon(icon);
    }
    public void setDescription(String text){
    	imageText.setText(text);
    }   
    	
    public static void main(String args[]){
    	new DescriptionPanel();
    
    }	 
};

Did you even read out suggestions? That has nothing to do with what you have been told.

proList.addListSelectionListener(new ListSelectionListener(){
why there is an error saying cannot find symbol class ListSelectionListener

? tq urgent

wht is wrong with this code?

/**
 * @(#)pro.java
 *
 *
 * @author 
 * @version 1.00 2010/10/8
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event;
 
public class pro extends JFrame {

final int num_of_pro=5;
private String[] proNames={"Ice Blended","Fresh Juice","Bubble Juice","Milk Shake","Ice","Smoothie"};
private JList proList=new JList(proNames);
private ImageIcon[] proimages={
new ImageIcon("ice.jpg"),	
new ImageIcon("juice1.jpg"),	
new ImageIcon("bubbles.jpg"),	
new ImageIcon("milk.jpg"),
new ImageIcon("dragon.jpg"),	
new ImageIcon("smoothie.jpg"),	
};
private JLabel[] fruitsviewer=new JLabel[num_of_pro];
    
    public pro() {
    JPanel p1=new JPanel(new GridLayout(3,2,5,5));
    
    for(int i=0;i<num_of_pro;i++){
    	p1.add(fruitsviewer[i]=new JLabel());
    	fruitsviewer[i].setHorizontalAlignment(SwingConstants.CENTER);
    }
    
    add(p1,BorderLayout.CENTER);
    add(new JScrollPane(proList),BorderLayout.WEST);
    
        proList.addListSelectionListener(new ListSelectionListener(){
    	public void valueChanged(ListSelectionEvent e){
    		int[] index=proList.getSelectedIndices();
    		int i;
    		for(i=0;i<index.length;i++){
    			fruitsviewer[i].setIcon(ImageIcon[index[i]]);
    		}
    		
    	for(;i<=num_of_pro;i++){
    		    fruitsviewer[i].setIcon(null);
    	}	
    	}
    });
    }
     
    public static void main(String args[]){
    	pro p=new pro();
    	p.setSize(500,600);
    	p.setTitle("Products");
    	p.setLocationRelativeTo(null);
    	p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	p.setVisible(true);
    } 
    
}

wht is wrong with this code?

Do you get errors?
Please copy the full text of the error messages and paste them here.

wht is wrong with this code?

Is this some kind of quiz?

the errors are
cannot find symbol class event line 11
cannot find symbol class ListSelesctionListener line 39
I have no idea what to do. pls help

Why do you code line 11 differently than you coded line 10 which is OK?
To allow the compiler to find ALL of the classes in a package, you need to end the package with an * (see line 10);

When you fix that, the other problem will be fixed.

i saw it in the net. line 11 is class for the listener.
wht do i need to do? remove it then others prob will occurs
pls help

i tried to remove it there is a error msg as below:
cannot find symbol class ListSelesctionListener line 39

Please read my post again. I recommended you add an .* to the end of the line so that it was the same as the line before it.

fruitsviewer[i].setIcon(imageIcons[index[i]]);

cannot find symbol

what is wrong with this code?

/**
 * @(#)pro.java
 *
 *
 * @author 
 * @version 1.00 2010/10/8
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
 
public class pro extends JFrame {

final int num_of_pro=5;
private String[] proNames={"Ice Blended","Fresh Juice","Bubble Juice","Milk Shake","Ice","Smoothie"};
private JList proList=new JList(proNames);
private ImageIcon[] proimages={
new ImageIcon("ice.jpg"),	
new ImageIcon("juice1.jpg"),	
new ImageIcon("bubbles.jpg"),	
new ImageIcon("milk.jpg"),
new ImageIcon("dragon.jpg"),	
new ImageIcon("smoothie.jpg"),	
};
private JLabel[] fruitsviewer=new JLabel[num_of_pro];
    
    public pro() {
    JPanel p1=new JPanel(new GridLayout(3,2,5,5));
    
    for(int i=0;i<num_of_pro;i++){
    	p1.add(fruitsviewer[i]=new JLabel());
    	fruitsviewer[i].setHorizontalAlignment(SwingConstants.CENTER);
    }
    
    add(p1,BorderLayout.CENTER);
    add(new JScrollPane(proList),BorderLayout.WEST);
    
        proList.addListSelectionListener(new ListSelectionListener(){
    	public void valueChanged(ListSelectionEvent e){
    		int[] index=proList.getSelectedIndices();
    		int i;
    		for(i=0;i<index.length;i++){
    			fruitsviewer[i].setIcon(imageIcons[index[i]]);
    		}
    		
    	for(;i<=num_of_pro;i++){
    		    fruitsviewer[i].setIcon(null);
    	}	
    	}
    });
    }
     
    public static void main(String args[]){
    	pro p=new pro();
    	p.setSize(500,600);
    	p.setTitle("Products");
    	p.setLocationRelativeTo(null);
    	p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	p.setVisible(true);
    } 
    
}

what is wrong with this code?

You are wasting everyone's time by posting code and asking this question. See the previous responses to this question.

The way you post is irritating. You post some code get suggestions for that code and you post something entirely different as if you ignored those who tried to help you.

Keep in 1 post your code and the error message you get and where. Posting just the lines will not help. we are not going to count X number of lines to find the error. Indicate where the error is.

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.