The OtherDetails isn't important but herre are the other 2:
import java.awt.event.*;
import java.awt.Color;
import java.awt.Choice;
import javax.swing.*;
import javax.swing.JScrollPane; //for scroll bars
import javax.swing.text.JTextComponent;
import java.sql.*;
import java.applet.*;
import java.awt.*;
class PersonalDetails extends JPanel implements ActionListener
{
/* ------ FIELDS ------ */
// GUI features
private JTextField firstNameField;
private JTextField middleNameField;
private JTextField surnameField;
private JTextField maidenNameField;
private JTextField photoField;
private JTextField dobField;
private JTextField notesField;
privateChoice backgroundMenu;
private JButton submit;
private JPanel inputPanel;
/** Output panel */
private JPanel outputPanel;
protected JComponent makePersonalDetails()
{
inputPanel = new JPanel();
inputPanel.setLayout(null);
inputPanel.setBorder(BorderFactory.createTitledBorder("Input"));
// Add Labels
JLabel first = new JLabel("First Name");
first.setBounds( 10, 15, 80, 20 );
JLabel middle = new JLabel("Middle Name");
middle.setBounds( 210, 15, 80, 20 );
JLabel surname= new JLabel("Surname");
surname.setBounds( 420, 15, 80, 20 );
JLabel maiden = new JLabel("Maiden Name");
maiden.setBounds( 10, 65, 80, 20 );
JLabel gender= new JLabel("Gender");
gender.setBounds( 210, 65, 80, 20 );
JLabel photo= new JLabel("Photo");
photo.setBounds( 10, 115, 80, 20 );
JLabel notes= new JLabel("Notes");
notes.setBounds( 210, 115, 80, 20 );
submit = new JButton("Submit");
submit.setBounds( 10, 165, 80, 20 );
submit.addActionListener(this);
firstNameField = new JTextField("Jack");
firstNameField.setBounds( 90, 15, 80, 20 );
firstNameField.addActionListener(this);
middleNameField = new JTextField("Paul");
middleNameField.setBounds( 290, 15, 80, 20 );
middleNameField.addActionListener(this);
surnameField = new JTextField("Smith");
surnameField.setBounds( 490, 15, 80, 20 );
surnameField.addActionListener(this);
maidenNameField = new JTextField("N/A");
maidenNameField.setBounds( 90, 65, 80, 20 );
maidenNameField.addActionListener(this);
backgroundMenu = makeMenu("Choose");
backgroundMenu.setBounds( 290, 65, 60, 20 );
this.add(backgroundMenu);
photoField = new JTextField("Photo");
photoField.setBounds( 90, 115, 80, 20 );
photoField.addActionListener(this);
notesField = new JTextField("random stuff");
notesField.setBounds( 290, 115, 80, 20 );
notesField.addActionListener(this);
// Add to panel
inputPanel.add(submit);
inputPanel.add(first);
inputPanel.add(firstNameField);
inputPanel.add(middle);
inputPanel.add(middleNameField);
inputPanel.add(surname);
inputPanel.add(surnameField);
inputPanel.add(maiden);
inputPanel.add(maidenNameField);
inputPanel.add(gender);
inputPanel.add(backgroundMenu);
inputPanel.add(photo);
inputPanel.add(photoField);
inputPanel.add(notes);
inputPanel.add(notesField);
inputPanel.validate();
return inputPanel;
}
public void actionPerformed(ActionEvent event)
{
if (event.getActionCommand().equals("Submit"))
inputData();
else
System.out.println("fdsdafas");
}
private Choice makeMenu(String inIntialChoice)
{
Choice menu = new Choice();
String theString = "male";
menu.add(theString);
theString = "female";
menu.add(theString);
theString = "unknown";
menu.add(theString);
theString = "other";
menu.add(theString);
return menu;
}
private void inputData()
{
String firstName = firstNameField.getText();
String middleName = middleNameField.getText();
String surname = surnameField.getText();
String maidenName = maidenNameField.getText();
String gender = backgroundMenu.getSelectedItem();
String photo = photoField.getText();
//String dob = dobField.getText();
String notes = notesField.getText();
Connection conn = null;
// try-catch needed when connecting to the database in case of connection disruption
try
{
//
Java DataBase Connection driver
//Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// passing in the parameters for the DB conenction
conn = DriverManager.getConnection("jdbc
racle:thin:@oracle.isg.computing.dcu.ie:1521
racle","username","password");
// creation and execution of the SQL query to check the username and password againt the DB
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT max(individid) FROM people");
int count = 0;
if(rs.next())
count = rs.getInt("max(individid)");
count++;
System.out.println(count);
String query = "INSERT INTO people VALUES("+count+",'"+firstName+"','"+middleName+"','"+surname
+"','"+maidenName+"','"+gender.substring(0,1)+"','"+photo+"','"+notes+"')";
System.out.println(query);
stmt.executeQuery(query);
stmt.executeQuery("commit");
}
catch(SQLException e) // catch Exceptions realating to SQL commands
{
System.out.println("SQLException: " + e.getMessage());
while((e = e.getNextException()) != null)
System.out.println(e.getMessage() + "<BR>");
}
finally // only completes the following if after successful run of try block
{
//Clean up resources, close the connection.
if(conn != null)
{
try
{
conn.close();
}
catch (Exception ignored)
{
}
}
}
}
}
import java.awt.event.*;
import java.awt.Color;
import java.awt.Choice;
import javax.swing.*;
import javax.swing.JScrollPane; //for scroll bars
import javax.swing.text.JTextComponent;
import java.sql.*;
import java.applet.*;
import java.awt.*;
class EventDetails extends JPanel implements ActionListener
{
private JTextField firstNameField;
private JTextField middleNameField;
private JTextField surnameField;
private JTextField maidenNameField;
private Choice eventList;
private Choice peopleList;
private Choice dayList;
private Choice monthList;
private Choice yearList;
private JButton submit;
private JPanel inputPanel;
protected JComponent makeEventDetails(String text)
{
inputPanel = new JPanel();
inputPanel.setBorder(BorderFactory.createTitledBorder("Events"));
JLabel event = new JLabel("Choose Event");
event.setBounds( 100, 15, 80, 20 );
eventList = makeEventMenu("Choose");
eventList.setBounds( 190, 15, 150, 60 );
this.add(eventList);
JLabel people = new JLabel("Choose person this relates to");
people.setBounds( 210, 215, 180, 20 );
peopleList = makePeopleMenu("Choose");
peopleList.setBounds( 410, 215, 150, 60 );
this.add(peopleList);
DateComboBox date = new DateComboBox();
date.setBounds( 10, 215, 80, 20 );
this.add(new DateComboBox());
submit = new JButton("Submit");
submit.setBounds( 190, 415, 80, 20 );
inputPanel.add(event);
inputPanel.add(eventList);
inputPanel.add(people);
inputPanel.add(peopleList);
inputPanel.add(date);
inputPanel.add(submit);
return inputPanel;
}
public void actionPerformed(ActionEvent event)
{
if (event.getActionCommand().equals("Submit"))
inputData();
else
System.out.println("fdsdafas");
}
private Choice makeEventMenu(String inIntialChoice)
{
Choice menu = new Choice();
Connection conn = null;
// try-catch needed when connecting to the database in case of connection disruption
try
{
// Java DataBase Connection driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// passing in the parameters for the DB conenction
conn = DriverManager.getConnection("jdbc
racle:thin:@oracle.isg.computing.dcu.ie:1521
racle","username","password");
// creation and execution of the SQL query to check the username and password againt the DB
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT count(*) FROM eventcode");
int count = 0;
if(rs.next())
count = rs.getInt("count(*)");
String [] list = new String [count];
rs = stmt.executeQuery("SELECT Type FROM eventcode");
int i=0;
while(rs.next() == true)
{
list[i] = rs.getString("Type");
i++;
}
for (i=0;i<count ;i++ )
{
String theString =list[i];
menu.add(theString);
}
}
catch(SQLException e) // catch Exceptions realating to SQL commands
{
System.out.println("SQLException: " + e.getMessage());
while((e = e.getNextException()) != null)
System.out.println(e.getMessage());
}
return menu;
}
private Choice makePeopleMenu(String inIntialChoice)
{
Choice menu = new Choice();
Connection conn = null;
// try-catch needed when connecting to the database in case of connection disruption
try
{
// Java DataBase Connection driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// passing in the parameters for the DB conenction
conn = DriverManager.getConnection("jdbc
racle:thin:@oracle.isg.computing.dcu.ie:1521
racle","username","password");
// creation and execution of the SQL query to check the username and password againt the DB
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT count(*) FROM people");
int count = 0;
if(rs.next())
count = rs.getInt("count(*)");
String [] list = new String [count];
rs = stmt.executeQuery("SELECT fname, lname FROM people");
int i=0;
while(rs.next() == true)
{
list[i] = rs.getString("fname");
list[i] += " " +rs.getString("lname");
i++;
}
for (i=0;i<count ;i++ )
{
String theString =list[i];
menu.add(theString);
}
}
catch(SQLException e) // catch Exceptions realating to SQL commands
{
System.out.println("SQLException: " + e.getMessage());
while((e = e.getNextException()) != null)
System.out.println(e.getMessage());
}
return menu;
}
Choice [] MakeCalendar()
{
Choice [] menu;
dayList = makePeopleMenu("Choose");
for(int i =0;i<31;i++)
dayList.add(""+i);
dayList.setBounds( 190, 65, 150, 60 );
monthList = makePeopleMenu("Choose");
for(int i =0;i<12;i++)
dayList.add(""+i);
monthList.setBounds( 190, 65, 150, 60 );
yearList = makePeopleMenu("Choose");
for(int i =1600;i<2500;i++)
dayList.add(""+i);
yearList.setBounds( 190, 65, 150, 60 );
this.add(dayList);
this.add(monthList);
this.add(yearList);
return null;
}
private void inputData()
{
}
}