hello guys, i am calling method of a class Two(extending JFrame) from within constructor Class One(implementing Runnable) steps: 1.i made the object of class two in a thread in class one and calls a method of it there in run.ex:thread.run() in one()//constructor 2.now,i call same method of class two,thsi time in constructor one() after i call thread.run() in one()but it is giving null pointer exception i also used thread.join() but doing that the two loses it's component and shows empty frame. my coding is mport java.util.*; import java.sql.*; import java.awt.*; public class One implements Runnable { public Thread thread=new Thread(this);
public Process p; public Logout logout; public String Login_Name,Time_db,login_time;
} } //destroy the browser,do necessary updations p.destroy(); System.out.println("process destroyed"); if(!(str1.equals(guest))) { try{ AddTime two=new AddTime(); String sql9="select * from database where Login_Name='"+str1+"';"; System.out.println("in registered"); stmt2=con.createStatement();
result2=stmt2.executeQuery(sql9); boolean b=result2.next(); System.out.println(sql9); String TTA=result2.getString("Total_Time_Accessed"); System.out.println(TTA); String total_time_accessed=two.con(TTA,str2); sql2="update database set Total_Time_Remaining='00:00',Total_Time_Accessed='"+total_time_accessed+"' where Login_Name='"+str1+"';"; System.out.println(sql2);
stmt4=con.createStatement(); int i=stmt4.executeUpdate(sql2); }catch(Exception e){System.out.println("HELLO"+e);} } sql3="delete welcome where Machine_No='"+str3+"';"; stmt3=con.createStatement(); int i=stmt3.executeUpdate(sql3); logout.dispose(); new New(); } }catch (Exception e) { System.out.println("Error Executing Notepad: "+e); } } public void run() { if(Thread.currentThread()==thread) { logout=new Logout(Login_Name); System.out.println("before function"); p=logout.LogoutFunction(login_time,Time_db); System.out.println("after function"); thread.stop(); } } }
plz do help me.it's a matter of life/death amit
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
"grover_mickey", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements. Thanks.