ok so the thing is im trying to save information from a register page into a file

else if(ae.getSource()==b1)
{

fname=t1.getText();
lname=t2.getText();
rol=t3.getText();
branch=cb1.getSelectedItem().toString();
username=t5.getText();
password=t6.getText();

username.savedata();

setVisible(false);
}

the username file is---

package Proj;

import java.io.*;

public class username
{

public static void savedata()
{
try
{
FileWriter obj=new FileWriter("usr",true);
obj.write(register.fname+"^^"+register.lname+"^^"+register.rol+"^^"+register.branch+"^^"+register.username+"^^"+register.password+"&"+"\n");
obj.flush();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

im getting an error a cannot find symbol error while compiling register.java

at username.savedata(); (with ^ pointing to (.) {dot})

i wanna use the savedata() from the username.java file in register.java to save the contents of the text boxes.....

what am i doing wrong???? i declared savedata() as public,static..what else????

Recommended Answers

All 3 Replies

btw

ive written only a part of the register.java page....just that portion is posing some problems!!! and yes i have written package Proj at the top of register.java file to include it in the project

im getting an error a cannot find symbol error

Please post the FULL text of the error message with all its information.

A comment on your coding style:
public class username

Class names should have Uppercase first letters: public class Username

When you're reading code and see a lowercase first letter you know its a variable.
Your code: username=t5.getText();
is confusing because username is the name of a class but it's used here like a variable.

oh hey thanks! ! ! it worked

sorry,but ive just started learning JAVA and dunno why but the main principle of writing class names with starting capital letters left my mind....

thanks a lot! !

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.