pls help............

hello frnds i ma mukul
i am working on a java project in netbeans
i am using swing application
there is a use of JTabbedPane
for which i have to give the object of other class as a Parameter
but when i create another class outside the previous class it shows error that cannot find symbol;
the code below will will explain more

package ssca;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;

/**
 *
 * @author mukul
 */
public class Main extends JFrame{
JTabbedPane tab1,tab2,tab3,tab4;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Main obj=new Main();

        obj.run();
    }
    void run()
    {
        Cities obj2=new Cities();
       tab1=new javax.swing.JTabbedPane();

       tab1.addTab("cities",new CitiesPanel());
       tab1.addTab("color",new ColorPanel());
       tab1.addTab("flavor",new FlavorPanel());
       tab1.addTab("taste",new TastePanel());
    tab1.addTab("country",new CountriesPanel());//here is the error rest is working fine
        tab1.addTab("tast",obj2);
       getContentPane().add(tab1);
       setSize(600,600);
       setDefaultCloseOperation(EXIT_ON_CLOSE);
       setVisible(true);
    }


}
class CitiesPanel extends JPanel
{
public CitiesPanel()
{

JButton btn=new JButton("Cities");
add(btn);
JTextField txt=new JTextField();
add(txt);
String s=txt.getText();
btn.setText(s);
add(btn);
}
}
class ColorPanel extends JPanel
{
    public ColorPanel()
{
    JButton btn=new JButton("Color");
add(btn);


    }

}
class FlavorPanel extends JPanel
{

    public FlavorPanel()
{
    JButton btn=new JButton("Flavor");
add(btn);
    }
}
class TastePanel extends JPanel
{

    public TastePanel()
{

    JButton btn=new JButton("Taste");
add(btn);
    }
}

now i have made another class CountriesPanel outside this class in same package...........

pls.help......

Recommended Answers

All 7 Replies

when i create the classs outside the class Main
it doesnt cals that class but shos error tha it cnnot find symbol

shos error tha it cnnot find symbol

Please copy and paste full text of the error message here.

What is the classpath set to when you compile the program?
It must point to the folder containing the package folder.

i am using netbeans so it shows error at the time of writing the code........
the error is
cannot find symbol
symbol Method AddTab(java.lang.String,ssca.home2)
location class javax.swing.JTabbedPane

and the other class is in same package

Sorry, I'm not familiar with the IDE's output.
Can you use the javac command to compile the program?
Here is a sample of its output:

TestSorts.java:138: cannot find symbol
symbol  : variable var
location: class TestSorts
         var = 2;
         ^

What will make it easier for us to diagnose is sending us the package that is giving you trouble. Just Zip the whole netbeans project and upload it so we can take a better look at it and see where you went wrong.

help required in modifiyng user interface for a desktop appilcation developed using swings. I need help in alignment and bascially giving my user interface a better look and feel.plz rfeply to sidhu220409@gmail.com

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.