Hi There,
I've got some problems with constructor methods in my program, of course the constructors look fine to me, but then faulty code usually looks good to any programmer after enough hours! Here is some of my code, firstly the following snippet shows the objects being instantiated.
public static ButtonData BtData1;
public static ButtonData BtData2;
public static ButtonData BtData3;
public static ButtonData BtData4;
public static ButtonData BtData5;
public static void main(String[] args)
{
try{
inStream = new FileInputStream("ObjStore" objStreamIn = new ObjectInputStream(inStream);
if(objStreamIn.available() == 0)
{
objStreamIn.close();
inStream.close();
BtData1 = new ButtonData("Link1",null);
BtData2 = new ButtonData("Link2",null);
BtData3 = new ButtonData("Link3",null);
BtData4 = new ButtonData("Link4","Zero"
BtData5 = new ButtonData("Link5","Zero"
}
else
{
......
......
......
}
}catch(IOException e){}
GUI xyz = new GUI();
}
}
Alot of the above code is related to serialization -- mainly checking to see whether or not objects already exist on file, and if they do not, instantiating them. Notice that the above constructors have different parameters or arguments (I can't remember which word describes it best!) -- it doesn't seem to matter whether I use two strings such as ("Link4","Zero" or ("Link1",null) -- both create errors. The class that is instantiated looks like this:
import java.io.*;
public class ButtonData implements Serializable{
String Name;
String Path;
ButtonData(String Name,String Path)
{
this.Name = Name;
this.Path = Path;
}
protected String getName()
{
return Name;
}
protected String getPath()
{
return Path;
}
protected void setName()
{
Name = Begin.LinkName.getText();
}
protected void setPath()
{
Path = Begin.ExecT.getText();
}
}
As far as I can tell the constructor above follows all the relevant syntax rules, as does the first snippet of code that I provided -- where the objects are instantiated. I will probably feel like a real meat head if I have done something dump and obvious, however I have double checked the code and it looks fine to me. When trying to compile the code I get the following error messages (using JBuilder7) -- these error messages highlight the relevant sections of the first code snippet I provided:
"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, null) not found in class quicklauncher2.ButtonData at line 61, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, null) not found in class quicklauncher2.ButtonData at line 62, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, null) not found in class quicklauncher2.ButtonData at line 63, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, java.lang.String) not found in class quicklauncher2.ButtonData at line 64, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, java.lang.String) not found in class quicklauncher2.ButtonData at line 65, column 23
If anybody can shed some light on what is going on here it will be greatly appreciated.
Thanks
I've got some problems with constructor methods in my program, of course the constructors look fine to me, but then faulty code usually looks good to any programmer after enough hours! Here is some of my code, firstly the following snippet shows the objects being instantiated.
public static ButtonData BtData1;
public static ButtonData BtData2;
public static ButtonData BtData3;
public static ButtonData BtData4;
public static ButtonData BtData5;
public static void main(String[] args)
{
try{
inStream = new FileInputStream("ObjStore" objStreamIn = new ObjectInputStream(inStream);
if(objStreamIn.available() == 0)
{
objStreamIn.close();
inStream.close();
BtData1 = new ButtonData("Link1",null);
BtData2 = new ButtonData("Link2",null);
BtData3 = new ButtonData("Link3",null);
BtData4 = new ButtonData("Link4","Zero"
BtData5 = new ButtonData("Link5","Zero"
}
else
{
......
......
......
}
}catch(IOException e){}
GUI xyz = new GUI();
}
}
Alot of the above code is related to serialization -- mainly checking to see whether or not objects already exist on file, and if they do not, instantiating them. Notice that the above constructors have different parameters or arguments (I can't remember which word describes it best!) -- it doesn't seem to matter whether I use two strings such as ("Link4","Zero" or ("Link1",null) -- both create errors. The class that is instantiated looks like this:
import java.io.*;
public class ButtonData implements Serializable{
String Name;
String Path;
ButtonData(String Name,String Path)
{
this.Name = Name;
this.Path = Path;
}
protected String getName()
{
return Name;
}
protected String getPath()
{
return Path;
}
protected void setName()
{
Name = Begin.LinkName.getText();
}
protected void setPath()
{
Path = Begin.ExecT.getText();
}
}
As far as I can tell the constructor above follows all the relevant syntax rules, as does the first snippet of code that I provided -- where the objects are instantiated. I will probably feel like a real meat head if I have done something dump and obvious, however I have double checked the code and it looks fine to me. When trying to compile the code I get the following error messages (using JBuilder7) -- these error messages highlight the relevant sections of the first code snippet I provided:
"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, null) not found in class quicklauncher2.ButtonData at line 61, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, null) not found in class quicklauncher2.ButtonData at line 62, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, null) not found in class quicklauncher2.ButtonData at line 63, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, java.lang.String) not found in class quicklauncher2.ButtonData at line 64, column 23"Begin.java": Error #: 300 : constructor ButtonData(java.lang.String, java.lang.String) not found in class quicklauncher2.ButtonData at line 65, column 23
If anybody can shed some light on what is going on here it will be greatly appreciated.
Thanks