| Author |
help me in this program pls. to calculat GPA
|
Sultan A. A
Greenhorn
Joined: Sep 30, 2004
Posts: 4
|
|
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){ } }
|
 |
Dave Mace
Greenhorn
Joined: Jan 04, 2005
Posts: 11
|
|
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
|
Dad always thought laughter was the best medicine, which I guess is why several of us died of tuberculosis. -Jack Handy
|
 |
Jeff Bosch
Ranch Hand
Joined: Jul 30, 2003
Posts: 804
|
|
|
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...
|
Give a man a fish, he'll eat for one day. <br />Teach a man to fish, he'll drink all your beer.<br /> <br />Cheers,<br /> <br />Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
|
 |
Vicken Karaoghlanian
Ranch Hand
Joined: Jul 21, 2003
Posts: 522
|
|
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.
|
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. <br />- What truth? <br />- That there is no spoon!!!
|
 |
 |
|
|
subject: help me in this program pls. to calculat GPA
|
|
|