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

public class aboutUs extends JFrame{
private desPanel des=new desPanel();

    public static void main(String args[]){
    	aboutUs frame=new aboutUs();
    	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	frame.setVisible(true);
    }
    public aboutUs() {
    desPanel.setTitle("About us");
    String desc="This Choose Your Flavor is a shop that allows customers to customize their drink.\n"+
    	"There are several franchise across Malaysia. We serve the freshesh and healtiest\n"+
    		"fresh juice. What best about Us is that we provide free of charge delivery.";
    desPanel.setDescription(desc);
    desPanel.setImageIcon("all.jpg");	
    		
    setLayout(new BorderLayout());
    add(desPanel,BorderLayout.CENTER);
    }
    
    
}

Recommended Answers

All 47 Replies

Do you have a question or error?

it is an error. I am not sure what is wrong with the code.

How do you know it is an error? Does the compiler print out an error message?
Please copy and paste here the full text of the error

cannot find symbol class desPanel
cannot find symbol variable class desPanel
pls run in prog then u'll see the error
tq

I'm hoping you will take the time to show what the problem is so I can answer it.


Where is the class desPanel defined?

Norm 1 RUN THE CODE!! then YOU WILL SEE THE PROB.

Norm 1 RUN THE CODE!! then YOU WILL SEE THE PROB.

No need to shout. The problem has already been spotted. No need to run the program. Norm1 has told you what the problem is. Read his post. Not to mention that the error message says the same thing, which you didn't bother to spend 2 seconds try to understand it

javaAddict i am not shouting tesnion explaining the prob

private desPanel des=new desPanel();

Let me repeat:
Where is the desPanel class defined?

private desPanel des=new desPanel();

Let me repeat:
Where is the desPanel class defined?

Line 12 is an attempt to define a variable des to point to an instance of the desPanel class.
For the fourth and last time:
Where is the desPanel class defined?
Where is the file: desPanel.java and/or desPanel.class?

i dont know? it is just a class no other desPanel.java and/or desPanel.class

Why do you have line 12 in your program?

Try changing line 12 to

private desPanel des=new JPanel();

No, don't bother. If desPanel is not available then that revised line 12 won't work either.

I

import javax.swing.*;
import java.awt.*;

public class aboutUs extends JFrame{
private desPanel des=new desPanel();// creating new Panel

    public static void main(String args[]){
    	aboutUs frame=new aboutUs();
    	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	frame.setVisible(true);
    }
    public aboutUs() {
    desPanel.setTitle("About us");
    String desc="This Choose Your Flavor is a shop that allows customers to customize their drink.\n"+
    	"There are several franchise across Malaysia. We serve the freshesh and healtiest\n"+
    		"fresh juice. What best about Us is that we provide free of charge delivery.";
    desPanel.setDescription(desc);
    desPanel.setImageIcon("all.jpg");	
    		
    setLayout(new BorderLayout());
    add(desPanel,BorderLayout.CENTER);
    }
    
    
}

Sorry, I meant

private JPanel des=new JPanel();

Why do you have line 13 in your program?

Lines 13, 17, 18 are interesting. Are these class methods? I think not.
And "des" is never used anyway.
My guess is that line 5 is a total screw-up, maybe needs to be
private something? desPanel = new something?();
Where something? is a class that has setTitle, setDescription. and setImageIcon methods.

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

public class DescriptionPanel extends JPanel{
	
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();
    }	 
};

Why this is not showing?

Because you haven't done anything to make it show.
You create a new panel, but you need to place that in a visible window such as (for example) a JFrame

i have tried that then how do i add my components?
do i have to add scroll and desc into my j?
or just f.show(true);
JFrame j=new JFrame();

and I have no idea why I rerun it without the JFrame.
it still show cannot find symbol setLayout?

LOL, Actually had a good laugh reading this :-)

what? i need to finish my homework. i m not pro like u ..

Sorry I didn't mean it in a bad way, I'm not saying you hopeless. There's just confusion going on here that's funny. I'm no pro, I'm still a student, don't hardly have a year experience with java.

Just create a JFrame instance and a JPanel instance. Add your components to the JPanel, then add the JPanel to the JFrame and make the JFrame visible.

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.

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.