Hey guys,I make a coding a subject system for my internship project, I use JComboBox to choose name of faculty. I want to call selected item of faculty from another class to choose subject under the selected faculty.
How can I call selected item from another class? Please help me.. thanks.
This is my coding for select faculty.
public class lectInterface(){
private void saveDataActionPerformed(java.awt.event.ActionEvent evt) {
String staff_id=staffID.getText();
int staff_Id=Integer.parseInt(staff_id);
String Name=staffName.getText();
String Cpost=currPos.getText();
String DPost=durrPos.getText();
Object prog=textProgram.getSelectedItem();
String hrs=hoursExcept.getText();
int hours=Integer.parseInt(hrs);
}
and below is coding for another class
try{
LectInterface lI = new LectInterface();
String host = "jdbc:derby://localhost:1527/STUDLECDB";
String uName = "studlecdb";
String uPass = "studlecdb";
Connection con = DriverManager.getConnection( host, uName, uPass );
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSIT IVE, ResultSet.CONCUR_UPDATABLE);
Object unit=lI.textProgram.getSelectedItem();
if(lI.textProgram.getSelectedItem().equals("CS230 - BACHELOR OF COMPUTER SCIENCE(HONS)(SESSION 1 2015/2016)")){
String sql = "SELECT SubjectName FROM Subject WHERE Program = 'CS230(1)'";
rs = stmt.executeQuery(sql);
while (rs.next()){
String subj = rs.getString("SubjectName");
SubjectList.addItem(subj);}
}
}
catch(SQLException err){
JOptionPane.showMessageDialog(LectInterface2.this, err.getMessage());
}
}