🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #3117

Help: Serialized checkbox not checking

#3117
From: D.A. Mazzella
Date: Tue, 12 May 1998 00:00
252 lines
10283 bytes

--------------E8E4283A6914590B8C46D187
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

For a project I'm doing for the computer science department at UNLV.
I've created a class named Course, a class named Curriculum that uses
the Course class, and the frame that uses the Curriculum class.  The
Course class has a CheckboxControl object (along with some other stuff.

When I run the program for the first time, I can check the boxes
successfully, but after I serialize the curriculum object, exit, and
"de"serialize it, the checkbox will not check or decheck (if it was
checked when it was first serialized).  The Curriculum object has some
ChoiceControl objects that work OK when serialized and "de"serialized.

Is there something in the CheckboxControl
Here are my a sample of my classes.  If you need more, i can supply it.

The Course Class
-------------------------------------
public class Course implements Serializable
{
  public CheckboxControl checkBox = new CheckboxControl() ;
  public String name = new String() ;
  public String description = new String() ;
  public Requirement requirements ;

  public void Course()
  {

  }
}
-------------------------------------
The Curriculum Class
-------------------------------------
public class Curriculum implements Serializable
{
  String advisor = new String() ;
  String studentID = new String() ;
  Course eng101 = new Course() ;
  Course eng102 = new Course() ;
  Course phi109 = new Course() ;
...
  ChoiceControl engSlt = new ChoiceControl() ;
...
 public Curriculum()
  {
    eng101.checkBox.setLabel("ENG 101") ;
    eng102.checkBox.setLabel("ENG 102") ;
    phi109.checkBox.setLabel("PHI 109") ;
    cos101.checkBox.setLabel("COS 101") ;
    phi421.checkBox.setLabel("PHI 421") ;
    ...etc...
    engSlt.setItems(new String[] {"Select one",
                                  "ENG 231",
                                  "ENG 232"}) ;
    ...etc...
}

-------------------------------------
The Frame/input class that uses the curriculum class
-------------------------------------
public class input extends DecoratedFrame
{
  XYLayout xYLayout1 = new XYLayout();
  ...etc...
  Curriculum bsInCSC ;

public input()
  {
    try
    {
      bsInCSC = new Curriculum() ;
      System.out.println("Curriculum OK in input.java") ;
      FileInputStream fin = new FileInputStream("Student.hst") ;
      ObjectInputStream in = new ObjectInputStream(fin) ;
      bsInCSC = (Curriculum)in.readObject() ;
      in.close() ;
    }
    catch(Exception ex)
    {
      System.out.println("Curriculum NOT THERE in input.java") ;
      bsInCSC = new Curriculum() ;
    }
    try
    {
       jbInit();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

private void jbInit() throws Exception
  {
    this.addComponentListener(new input_this_componentAdapter(this));
    this.setTitle("Computer Science Curriculum for" +
bsInCSC.studentID);
    this.addWindowListener(new input_this_windowAdapter(this));
    ...etc...
    groupBox1.add(bsInCSC.eng101.checkBox, new XYConstraints(0, 3, -1,
-1)) ;
    groupBox1.add(bsInCSC.eng102.checkBox, new XYConstraints(0, 27, 94,
21)) ;
    groupBox1.add(bsInCSC.engSlt, new XYConstraints(0, 50, 104, 23)) ;
    ...etc...
  }
}

-------------------------------------
It displays OK, but just will not check after it is serialized! Thanks
for any info!

--
D.A. Mazzella   dan@mazzella.org http://dan.mazzella.org/
   mazzella@nevada.edu http://www.cep.net/~mazzella/


--------------E8E4283A6914590B8C46D187
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<TT>For a project I'm doing for the computer science department at UNLV.
I've created a class named Course, a class named Curriculum that uses the
Course class, and the frame that uses the Curriculum class.&nbsp; The Course
class has a CheckboxControl object (along with some other stuff.</TT>

<P><TT>When I run the program for the first time, I can check the boxes
successfully, but after I serialize the curriculum object, exit, and "de"serialize
it, the checkbox will not check or decheck (if it was checked when it was
first serialized).&nbsp; The Curriculum object has some ChoiceControl objects
that work OK when serialized and "de"serialized.</TT>

<P><TT>Is there something in the CheckboxControl</TT>
<BR><TT>Here are my a sample of my classes.&nbsp; If you need more, i can
supply it.</TT>

<P><TT>The Course Class</TT>
<BR><TT>-------------------------------------</TT>
<BR><TT>public class Course implements Serializable</TT>
<BR><TT>{</TT>
<BR><TT>&nbsp; public CheckboxControl checkBox = new CheckboxControl()
;</TT>
<BR><TT>&nbsp; public String name = new String() ;</TT>
<BR><TT>&nbsp; public String description = new String() ;</TT>
<BR><TT>&nbsp; public Requirement requirements ;</TT>

<P><TT>&nbsp; public void Course()</TT>
<BR><TT>&nbsp; {</TT>

<P><TT>&nbsp; }</TT>
<BR><TT>}</TT>
<BR><TT>-------------------------------------</TT>
<BR><TT>The Curriculum Class</TT>
<BR><TT>-------------------------------------</TT>
<BR><TT>public class Curriculum implements Serializable</TT>
<BR><TT>{</TT>
<BR><TT>&nbsp; String advisor = new String() ;</TT>
<BR><TT>&nbsp; String studentID = new String() ;</TT>
<BR><TT>&nbsp; Course eng101 = new Course() ;</TT>
<BR><TT>&nbsp; Course eng102 = new Course() ;</TT>
<BR><TT>&nbsp; Course phi109 = new Course() ;</TT>
<BR><TT>...</TT>
<BR><TT>&nbsp; ChoiceControl engSlt = new ChoiceControl() ;</TT>
<BR><TT>...</TT>
<BR><TT>&nbsp;public Curriculum()</TT>
<BR><TT>&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; eng101.checkBox.setLabel("ENG 101") ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; eng102.checkBox.setLabel("ENG 102") ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; phi109.checkBox.setLabel("PHI 109") ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; cos101.checkBox.setLabel("COS 101") ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; phi421.checkBox.setLabel("PHI 421") ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; ...etc...</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; engSlt.setItems(new String[] {"Select one",</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"ENG 231",</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"ENG 232"}) ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; ...etc...</TT>
<BR><TT>}</TT>

<P><TT>-------------------------------------</TT>
<BR><TT>The Frame/input class that uses the curriculum class</TT>
<BR><TT>-------------------------------------</TT>
<BR><TT>public class input extends DecoratedFrame</TT>
<BR><TT>{</TT>
<BR><TT>&nbsp; XYLayout xYLayout1 = new XYLayout();</TT>
<BR><TT>&nbsp; ...etc...</TT>
<BR><TT>&nbsp; Curriculum bsInCSC ;</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>public input()</TT>
<BR><TT>&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; try</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsInCSC = new Curriculum() ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Curriculum OK
in input.java") ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileInputStream fin = new FileInputStream("Student.hst")
;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ObjectInputStream in = new ObjectInputStream(fin)
;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsInCSC = (Curriculum)in.readObject()
;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in.close() ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; catch(Exception ex)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Curriculum NOT
THERE in input.java") ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsInCSC = new Curriculum() ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; try</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jbInit();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; catch (Exception e)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp; }</TT>

<P><TT>private void jbInit() throws Exception</TT>
<BR><TT>&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; this.addComponentListener(new input_this_componentAdapter(this));</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; this.setTitle("Computer Science Curriculum for"
+ bsInCSC.studentID);</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; this.addWindowListener(new input_this_windowAdapter(this));</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; ...etc...</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; groupBox1.add(bsInCSC.eng101.checkBox, new XYConstraints(0,
3, -1, -1)) ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; groupBox1.add(bsInCSC.eng102.checkBox, new XYConstraints(0,
27, 94, 21)) ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; groupBox1.add(bsInCSC.engSlt, new XYConstraints(0,
50, 104, 23)) ;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; ...etc...</TT>
<BR><TT>&nbsp; }</TT>
<BR><TT>}</TT>

<P><TT>-------------------------------------</TT>
<BR><TT>It displays OK, but just will not check after it is serialized!
Thanks for any info!</TT>

<P><TT>--</TT>
<BR><TT>D.A. Mazzella&nbsp;&nbsp; dan@mazzella.org <A HREF="http://dan.mazzella.org/">http://dan.mazzella.org/</A></TT>
<BR><TT>&nbsp;&nbsp; mazzella@nevada.edu <A HREF="http://www.cep.net/~mazzella/">http://www.cep.net/~mazzella/</A></TT>
<BR><TT>&nbsp;</TT></HTML>

--------------E8E4283A6914590B8C46D187--
Technical Details
Message-ID: <35592687.A9EE384@mazzella.org>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,1a9a6ec581e1516,start
X-Google-Attributes: gid1089d0,public
From: "D.A. Mazzella" <dan@mazzella.org>
Subject: Help: Serialized checkbox not checking
Date: 1998/05/12
Message-ID: <35592687.A9EE384@mazzella.org>
X-Deja-AN: 352779083
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="------------E8E4283A6914590B8C46D187"
Organization: Mazzella Internet Services
Newsgroups: borland.public.jbuilder.java.api