student record form

storing student data to an array...tooltip here..i dunno how to use

Page 1 of 1

4 Replies - 12048 Views - Last Post: 17 December 2009 - 04:32 AM Rate Topic: -----

#1 imjuzaround  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 08-March 08

student record form

Posted 15 October 2008 - 05:41 AM

hello there...i have this homework to be pass tommorow....


i had finally made the gui....but i have problems implementing the events and i dont know how to use tooltip...


here is the program specification:

>enabloing/disabling of jbutton and Jtextfield components

details:

A. save and cancel are disabled at first run as well as Jtextfield for name,age gender and address are also disabled. Enable the navigation buttons, add/edit, delete and search buttons

B. if Add/Edit button is clicked, disable all buttons except for save and cancel buttons. Jtextfield for name,age.gender and address are enabled while jtextfield for search is disabled

C. if save is clicked. do A

> tooltip text for JButton and Jtextfield components
provide brief description for each component when hovered by the mouse. Ude the settooltip method to do this

> more importantly, make this program fully functional/operational





wheeeew....


here is my code...i do not have events for this...im still working on it...please help me :rolleyes:





import java.awt.*;
import javax.swing.*;
import java.awt.event.*;



public class bebe extends JFrame{
		
	public JButton search,addEdit,delete,save,cancel,next,prev,last,first;
	public JLabel name,gender,age,mailadd;
	public JTextField searching=null,fullname=null,edad=null,sex=null,mailaddress=null,scroll=null;
	public JComboBox kinatawo;
	public JPanel panelnorth,panelcenter,panelsouth,paneleast,panelwest,north1,north2,north3,south1,south2,south3,center;
	String str[]={"male","female","uncertain"};
		
		
		public  void oink(){
			
			setTitle("Student Record Form");
			setLayout(new BorderLayout());
/*		my panels		*/

	 panelnorth=new JPanel(new FlowLayout());
	 panelsouth=new JPanel(new FlowLayout());	
	 panelcenter=new JPanel(new BorderLayout());
	 panelwest=new JPanel(new BorderLayout());
	 paneleast=new JPanel(new BorderLayout());		
	 north1=new JPanel(new GridLayout(2,1));		
	 north2=new JPanel(new GridLayout(2,1));
	 north3=new JPanel(new GridLayout(2,2));
	 south1=new JPanel(new GridLayout(2,1));
	 south2=new JPanel(new GridLayout(2,2));	
	 south3=new JPanel(new GridLayout(2,1));	
	 center=new JPanel(new BorderLayout());	
	 	
	 	
	 	
/*		north panel		*/	
		searching=new JTextField(20);
		search=new JButton("Search");
		
		panelnorth.add(searching);
		panelnorth.add(search);

/*		center panel		*/

		addEdit=new JButton("Add/Edit");
		delete=new JButton("Delete");
		north1.add(addEdit);
		north1.add(delete);
		panelwest.add(north1,BorderLayout.NORTH);
		
		save=new JButton("Save");
		cancel=new JButton("Cancel");
		south1.add(save);
		south1.add(cancel);
		
		panelwest.add(south1,BorderLayout.SOUTH);		
		
		panelcenter.add(panelwest,BorderLayout.WEST);
		
		name=new JLabel("name");
		age=new JLabel("age");
		gender=new JLabel("Gender");
		mailadd=new JLabel("Mailing address");
		
	   fullname=new JTextField(10);
	   edad=new JTextField(10);
	   kinatawo=new JComboBox(str);
	   mailaddress=new JTextField(10);
	   
	   
	   

		north2.add(name);
		north2.add(fullname);
		north2.add(age);
		north2.add(edad);
		south2.add(gender);
		south2.add(kinatawo);
		south2.add(mailadd);
		south2.add(mailaddress);
		
		center.add(north2,BorderLayout.NORTH);
		center.add(south2,BorderLayout.SOUTH);
		
		panelcenter.add(center,BorderLayout.EAST);
		
/*		south panel			*/


next=new JButton(">");
prev=new JButton("<");
last=new JButton(">|");
first=new JButton("|<");
scroll=new JTextField(2);

panelsouth.add(first);
panelsouth.add(prev);
panelsouth.add(scroll);
panelsouth.add(next);
panelsouth.add(last);


		
		add(panelcenter,BorderLayout.CENTER);

		add(panelnorth,BorderLayout.NORTH);
		
		add(panelsouth,BorderLayout.SOUTH);
		
	pack();
	setVisible(true);
		}
		public static void main (String[] args) {
			
			
		
		bebe boink=new bebe();
		
		boink.oink();
		
		
		}
	
	
}





Is This A Good Question/Topic? 0
  • +

Replies To: student record form

#2 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

Re: student record form

Posted 15 October 2008 - 07:46 AM

Please do not double post your questions.
Was This Post Helpful? 0
  • +
  • -

#3 imjuzaround  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 08-March 08

Re: student record form

Posted 16 October 2008 - 03:00 AM

View Postjjsaw5, on 15 Oct, 2008 - 07:46 AM, said:

Please do not double post your questions.



oooops......sorry :P
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: student record form

Posted 16 October 2008 - 03:20 PM

ToolTip are easy... I have put 2 in your code
ActionListener has been added for a few buttons in your code

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

//I guess you have an ActionListener missing

public class bebe extends JFrame implements ActionListener {     // <---- actionListener

	public JButton search,addEdit,delete,save,cancel,next,prev,last,first;
	public JLabel name,gender,age,mailadd;
	public JTextField searching=null,fullname=null,edad=null,sex=null,mailaddress=null,scroll=null;
	public JComboBox kinatawo;
	public JPanel panelnorth,panelcenter,panelsouth,paneleast,panelwest,north1,north2,north3,
	south1,south2,south3,center;
	String str[]={"male","female","uncertain"};


	public  void oink(){

		setTitle("Student Record Form");
		setLayout(new BorderLayout());
		/*        my panels        */

		panelnorth=new JPanel(new FlowLayout());
		panelsouth=new JPanel(new FlowLayout());    
		panelcenter=new JPanel(new BorderLayout());
		panelwest=new JPanel(new BorderLayout());
		paneleast=new JPanel(new BorderLayout());        
		north1=new JPanel(new GridLayout(2,1));        
		north2=new JPanel(new GridLayout(2,1));
		north3=new JPanel(new GridLayout(2,2));
		south1=new JPanel(new GridLayout(2,1));
		south2=new JPanel(new GridLayout(2,2));    
		south3=new JPanel(new GridLayout(2,1));    
		center=new JPanel(new BorderLayout());    



		/*        north panel        */    
		searching=new JTextField(20);
		search=new JButton("Search");

		panelnorth.add(searching);
		panelnorth.add(search);

		/*        center panel        */

		addEdit=new JButton("Add/Edit");
		addEdit.addActionListener(this);		// add actionListener to the button
		delete=new JButton("Delete");
		delete.addActionListener(this);		// add actionListener to the button
		north1.add(addEdit);
		north1.add(delete);
		panelwest.add(north1,BorderLayout.NORTH);

		save=new JButton("Save");
		save.addActionListener(this);		// add actionListener to the button

		cancel=new JButton("Cancel");
		cancel.addActionListener(this);		// add actionListener to the button
		south1.add(save);
		south1.add(cancel);

		panelwest.add(south1,BorderLayout.SOUTH);        

		panelcenter.add(panelwest,BorderLayout.WEST);

		name=new JLabel("name");
		age=new JLabel("age");
		gender=new JLabel("Gender");
		mailadd=new JLabel("Mailing address");

		fullname=new JTextField(10);
		edad=new JTextField(10);
		kinatawo=new JComboBox(str);
		mailaddress=new JTextField(10);




		north2.add(name);
		north2.add(fullname);
		north2.add(age);
		north2.add(edad);
		south2.add(gender);
		south2.add(kinatawo);
		south2.add(mailadd);
		south2.add(mailaddress);

		center.add(north2,BorderLayout.NORTH);
		center.add(south2,BorderLayout.SOUTH);

		panelcenter.add(center,BorderLayout.EAST);

		/*        south panel            */


		next=new JButton(">");
		next.addActionListener(this);		// add actionListener to the button

		// also addActionListener for the other buttons
		prev=new JButton("<");
		prev.setToolTipText("This the text that will be showed when the mouse");  // tooltip
		last=new JButton(">|");
		last.setToolTipText("will pass over this button");					// tooltip
		first=new JButton("|<");
		scroll=new JTextField(2);

		panelsouth.add(first);
		panelsouth.add(prev);
		panelsouth.add(scroll);
		panelsouth.add(next);
		panelsouth.add(last);



		add(panelcenter,BorderLayout.CENTER);

		add(panelnorth,BorderLayout.NORTH);

		add(panelsouth,BorderLayout.SOUTH);

		pack();
		setVisible(true);
	}
	public static void main (String[] args) {



		bebe boink=new bebe();

		boink.oink();


	}
	// action listener
	public void actionPerformed(ActionEvent arg0) {
		JButton b = (JButton) arg0.getSource();

		// do what you have to do for the search button
		if(b == search) {
			return;
		}
		// to what you have to do for the addEdit button
		if(b == addEdit) {
			return;
		}

		// an so on for the other buttons

	}


}


Was This Post Helpful? 0
  • +
  • -

#5 JBeginer1987  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 02-November 09

Re: student record form

Posted 17 December 2009 - 04:32 AM

Hi everyone!
Pls help me out here.
I have this code snippet of my program, the program acts as a front end app with a database as back end.
When compiled the program shows no errors but when I run it it gives me this exception:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.


Does anyone knows what this mean?
this is referring to this code snippet of me program
	public ArrayList searchPatient(String patientNum)

	{
		try	{
String sql = "SELECT fname, sname, location, dob, dor, race, gender, status," +
		"initials, idnum FROM PatientTable WHERE patientNo =" + patientNum;

			// Create a prepared statement
 			Statement s = con.createStatement();
			String pno = "";
		String firstname="";
		String lastname="";
		String locate = "";
		String dOB="";
		String dOR="";
		String Race="";
		String Gen="";
		String Stat="";
		String Initial="";
			double id;

						ResultSet rs = s.executeQuery(sql);

		while(rs.next())
	{
					pno = rs.getString("patientNo");
			firstname = rs.getString("fname");
			lastname = rs.getString("sname");
			locate=rs.getString("location");
			dOB = rs.getString("dob");
			dOR = rs.getString("dor");
			Race=rs.getString("race");
			Gen=rs.getString("gender");
			Stat=rs.getString("initials");
			Initial=rs.getString("status");
			id = rs.getDouble("idnum");
				
				//Create a PatientInfo object
PatientInfo patient = new PatientInfo(id, pno, firstname, lastname, locate,dOB, dOR, Race, Gen, Stat, Initial);

				//Add the patient object to array list
				patientList.add(patient);
			}
		}
		catch(Exception e){
			System.out.println(e);
		}
		   
		return patientList;

	} 



Please help cause I can't get it, I'm going :crazy: now.
Thanks in advance for your support :D :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1