Jprisco
September 19th, 2000, 01:06 AM
Im putting together a small stupid little app using java and up to this point all has been well... However variable assignments in a particular method do not seem to work as I expect.
While I hate to post so much code Im hoping that you might just take a look and try to explain why
the assignments in openMenuItem_ActionPerformed method do not work... I used next_ActionPerformed method to test the assignment and the result is that the setText method is still performed after I have opened my file... likewise The Test object remains null....
Is there an explanation for this????????
public class Mainwin2 extends JFrame
{
private Test theTest = null;
private boolean myFlag = false;
int count =0; //master counter
//many other variables initialized
public void openMenuItem_ActionPerformed(java.awt.event.ActionEvent actionEvent)
{
utils.FileDlg dlg= new FileDlg("Open File");
File MyFile = dlg.openFile();
try
{
ObjectInputStream objectIn = new ObjectInputStream(
new BufferedInputStream(
new FileInputStream(MyFile)));
theTest = (Test)objectIn.readObject();
objectIn.close();
myFlag =true; //SEEMS AS THOUGH BOTH ASSIGNMENTS DO NOT WORK
//Yet no exceptions occur!!
}
catch(IOException e)
{
JOptionPane.showMessageDialog(this,"Ubable to openfile",
"IOException",JOptionPane.ERROR_MESSAGE);
}
catch(ClassNotFoundException e)
{
JOptionPane.showMessageDialog(this,"Ubable to open file",
"ClassNotFoundException",JOptionPane.ERROR_MESSAGE);
}
}
thanks for the time and well hopefully for some kind of explanation....
J.Prisco
52901368
While I hate to post so much code Im hoping that you might just take a look and try to explain why
the assignments in openMenuItem_ActionPerformed method do not work... I used next_ActionPerformed method to test the assignment and the result is that the setText method is still performed after I have opened my file... likewise The Test object remains null....
Is there an explanation for this????????
public class Mainwin2 extends JFrame
{
private Test theTest = null;
private boolean myFlag = false;
int count =0; //master counter
//many other variables initialized
public void openMenuItem_ActionPerformed(java.awt.event.ActionEvent actionEvent)
{
utils.FileDlg dlg= new FileDlg("Open File");
File MyFile = dlg.openFile();
try
{
ObjectInputStream objectIn = new ObjectInputStream(
new BufferedInputStream(
new FileInputStream(MyFile)));
theTest = (Test)objectIn.readObject();
objectIn.close();
myFlag =true; //SEEMS AS THOUGH BOTH ASSIGNMENTS DO NOT WORK
//Yet no exceptions occur!!
}
catch(IOException e)
{
JOptionPane.showMessageDialog(this,"Ubable to openfile",
"IOException",JOptionPane.ERROR_MESSAGE);
}
catch(ClassNotFoundException e)
{
JOptionPane.showMessageDialog(this,"Ubable to open file",
"ClassNotFoundException",JOptionPane.ERROR_MESSAGE);
}
}
thanks for the time and well hopefully for some kind of explanation....
J.Prisco
52901368