Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

help me in this program pls. to calculat GPA

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

I need help, I have a project that calculating the GPA
on java applet what I am planing to do
first, when the applet start ask for name and password
after that, select the department .....etc

the problem that in the init() method I write code for name and password also for
check box group to select the department but this should be appear when the stat = 1
how can i solve it ???

this my code :

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/* <applet code="Password" width=400 height=200>
</applet>*/

public class PAS extends Applet implements ActionListener, TextListener,ItemListener{
TextField tf,tf2;
Label name;
Label password;
Label l3;
String a,a1,state="";
Button b;
int stat=0;

public void init(){

if( stat == 1)
{
CheckboxGroup cbg= new CheckboxGroup();
Checkbox cb1 = new Checkbox("Computer Scince",cbg,true) ;
cb1.addItemListener( this ) ;
add(cb1) ;

Checkbox cb2 = new Checkbox("Appl. Electricl Eng. ",cbg, false ) ;
cb2.addItemListener( this ) ;
add(cb2);
Checkbox cb3= new Checkbox("Accounting and M.I.S.",cbg, false ) ;
cb3.addItemListener( this ) ;
add(cb3) ;
}
else if ( stat == 0)
{
name = new Label("Name :") ;
add( name ) ;
tf= new TextField(20) ;
tf.addActionListener ( this ) ;
tf.addTextListener ( this ) ;
add ( tf ) ;

password = new Label("Password :") ;
add( password ) ;
tf2= new TextField(8) ;
tf2.setEchoChar('*') ;
tf2.addActionListener ( this ) ;
tf2.addTextListener ( this ) ;
add ( tf2 ) ;

l3 = new Label(" ") ;
add(l3) ;
b = new Button("OK");
b.addActionListener( this ) ;
add( b ) ;

setLayout ( new GridBagLayout()) ;

GridBagConstraints gbc = new GridBagConstraints() ;
gbc.fill = GridBagConstraints.NONE; //Set the "global" constraintes
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.weightx = 1;
gbc.weighty = 0;
addUsingGBL ( name, gbc, 0,0,1,2); //Add the componets using the
addUsingGBL ( tf, gbc,1,0,1,2); // constraints
addUsingGBL ( password, gbc, 0,2,2,2) ;
addUsingGBL ( tf2, gbc, 1,2,2,1) ;
addUsingGBL ( b, gbc, 1,3,4,2) ;
addUsingGBL ( l3, gbc, 0,3,4,2) ;
}
}
void addUsingGBL (Component comp, GridBagConstraints gbc, int x, int y, int w, int h) {
gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = w;
gbc.gridheight = h;
add(comp, gbc) ;
}

public void actionPerformed( ActionEvent ae){
a = tf2.getText() ;
a1 = ae.getActionCommand() ;
if ( a1.equals("OK") )
{
if ( a.equals( "s19980094"))
{
stat =1;
init() ;
}
}
}
public void textValueChanged(TextEvent te)
{
}
public void itemStateChanged(ItemEvent ie){

}
}
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,

I know I'm a little late here, but just wanted to offer some advice in case you plan on sticking around. Use the [CODE] tags when posting code because it will help to retain formatting and make your code easier to read. Also, consider pinpointing your code down to a particular section and post only that code...chances are you'll receive more responses as many people don't like to read through 50+ lines of code.

Thanks,
David
 
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ditto Dave's welcome and his comments. I don't respond to posts that don't use the CODE tags to demark and format code, and I know other Ranchers who feel the same way. Also, you'll probably get a message from the Sheriff about the JavaRanch name policy...
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jeff Bosch:
Also, you'll probably get a message from the Sheriff about the JavaRanch name policy...


Sultan is an acceptable Arabic name that doesn't violate JR naming policy.
 
I knew that guy would be trouble! Thanks tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic