🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17734

Re: Newbie Help

#17734
From: Dillan Fernando
Date: Wed, 07 Oct 1998 00:00
81 lines
3538 bytes
Hi Joseph!

I went through your code. The problem was with the GradeBookApplet class.
Just replace you code with the following code;

void btnReset_actionPerformed(ActionEvent e) {

       //clears values in textfields and labels
       txtStudentName.setText("");
       txtSSN.setText("");
       txtSmallStuff1.setText("");
       txtSmallStuff2.setText("");
       txtSmallStuff3.setText("");
       txtSmallStuff4.setText("");
       txtSmallStuff5.setText("");
       txtExam1.setText("");
       txtExam2.setText("");
       txtExam3.setText("");
       txtFinalExam.setText("");

       Student1.name="";
       Student1.ssNum=0;
       Student1.ss1=0;
       Student1.ss2=0;
       Student1.ss3=0;
       Student1.ss4=0;
       Student1.ss5=0;
       Student1.ex1=0;
       Student1.ex2=0;
       Student1.ex3=0;
       Student1.finalEx=0;
       Student1.smallStuffAvgScore=0;
       Student1.examAvgScore=0;
       Student1.finalExamAvgScore=0;
       Student1.finalCourseScore=0;

Let me give you some hints to improve you programming skills.
Write methods to set and get methods in the class itself, in other words
write interfaces to the users of the class. Example you could've saved a lot
of time by writing setSSN(String ssn), setAverage(String avg); and you
could've done the conversion from String to a number inside the class
itself. You can even change the colour of the txt box inside the method
itself..... Anyway hope the above solves you problem

Regards

Dillan Fernando
Senior Analyst
Palmware (pvt) Ltd

    Joseph Urbanek wrote in message <6vc77j$hgh13@forums.borland.com>...
    Subject: Help for Novice Java programmer.

    I am a Java novice.  I love the language but I need some help. I would
be
    very appreciative if someone could be of assistance.  I am learning to
    program in java. I have included my source code.  I have created a GUI
    interface that inputs a student's grade from the user. The instance
    variables that hold the data and the method that computes the course
    averages are contained in an external class that is part of the same
package
    as the interface.  What occures when I run the program is this.  The
program
    creates an object called student1 containing the instance variables in
the
    external public class.  The user enters the students name, ssn, and
various
    scores into text feilds.  When the user presses the Calculate button the
    program gets the data from the text fields and then places them in the
    student1 object.  A calculateaverages method is called.  The averages
are
    calculated. Then the the output is displayed in lables in a output
display
    window.  Everything good so far.  I also have a Reset button that clears
the
    data in the text feilds and the lables.  That works OK.  But if you
enter
    more data in the textfields and press the Calculate button the reset
values
    do not change.  I am at a loss.  Any assistance in this matter will be
    greatly appreciated
Technical Details
Message-ID: <6vdrl9$kr13@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6vc77j$hgh13@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,e95574622edef673,start
X-Google-Attributes: gidf74b3,public
From: "Dillan Fernando" <dillan@geocities.com>
Subject: Re: Newbie Help
Date: 1998/10/07
Message-ID: <6vdrl9$kr13@forums.borland.com>
X-Deja-AN: 398373089
References: <6vc77j$hgh13@forums.borland.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: Palmware
Newsgroups: borland.public.jbuilder.java.language