Thread: How to
View Single Post
Join Date: Aug 2007
Posts: 6
Reputation: sam18 is an unknown quantity at this point 
Solved Threads: 0
sam18 sam18 is offline Offline
Newbie Poster

How to

 
0
  #1
Aug 27th, 2007
How can i display the output of this coding in frames instead of Command Prompt.
and i want to view the result of that student only whose rollno is entered.

  1. import java.awt.*;
  2. //import java.applet.*;
  3. import java.awt.event.*;
  4. import java.lang.*;
  5. import java.sql.*;
  6.  
  7. public class wscreen extends Frame
  8. implements WindowListener,ActionListener
  9. {
  10. Button b1;
  11. TextField t1;
  12. Label l1,l2;
  13. String msg,msg1,msg2,msg3,msg4,msg5,msg6,msg7;
  14.  
  15. public wscreen()
  16. {
  17. super("imp");
  18. setLayout(null);
  19.  
  20. b1= new Button("submit");
  21.  
  22. l1=new Label("Result Declared",Label.CENTER);
  23. l2=new Label("Enter ROLL NO", Label.LEFT);
  24.  
  25. t1=new TextField(5);
  26. /*t2=new TextField(5);
  27. t3=new TextField(5);
  28. t4=new TextField(5);
  29. t5=new TextField(5);
  30. t6=new TextField(5);
  31. t7=new TextField(5);
  32. t8=new TextField(5);*/
  33.  
  34.  
  35. Font f=new Font("Impact", Font.BOLD,25);
  36. Color c1=new Color(255,200,210);
  37. Color c2=new Color(200,200,210);
  38.  
  39. l1.setFont(f);
  40. l1.setForeground(c1);
  41. l1.setBackground(c2);
  42. l1.setBounds(90,20,200,30);
  43. add(l1);
  44.  
  45. l2.setBounds(20,70,90,30);
  46. add(l2);
  47.  
  48. t1.setBounds(200,70,90,20);
  49. add(t1);
  50. /*
  51. t2.setBounds(200,200,90,10);
  52.   add(t2);
  53. t3.setBounds(200,230,90,10);
  54.   add(t3);
  55. t4.setBounds(200,250,90,20);
  56.   add(t4);
  57. t5.setBounds(200,270,90,20);
  58.   add(t5);
  59. t6.setBounds(200,290,90,20);
  60.   add(t6);
  61. t7.setBounds(200,300,90,20);
  62.   add(t7);
  63. t8.setBounds(200,310,90,20);
  64.   add(t8);*/
  65.  
  66. b1.setBounds(90,120,200,30);
  67. add(b1);
  68.  
  69. addWindowListener(this);
  70. b1.addActionListener(this);
  71.  
  72. }
  73.  
  74.  
  75. public void actionPerformed(ActionEvent ae)
  76. {
  77. Object ob=ae.getSource();
  78.  
  79. if(ob==b1);
  80.  
  81.  
  82. }
  83.  
  84. public void paint(Graphics g)
  85. {
  86. msg="ROLLNO :"+t1.getText();
  87. msg1="NAME :";
  88. msg2="RESULT :";
  89. msg3="P1 :";
  90. msg4="P2 :";
  91. msg5="P3 :";
  92. msg6="P4 :";
  93. msg7="P5 :";
  94. g.drawString(msg,90,190);
  95. g.drawString(msg1,90,210);
  96. g.drawString(msg2,90,230);
  97. g.drawString(msg3,90,250);
  98. g.drawString(msg4,90,270);
  99. g.drawString(msg5,90,290);
  100. g.drawString(msg6,90,310);
  101. g.drawString(msg7,90,330);
  102. }
  103.  
  104. public static void main(String ar[])
  105. {
  106. wscreen d=new wscreen();
  107. d.setSize(400,400);
  108. d.setVisible(true);
  109.  
  110. String Sname;
  111. String Sno,m1,m2,m3,m4,m5;
  112.  
  113.  
  114. Connection Con=null;
  115. Statement Stmt;
  116. ResultSet ERs;
  117. try
  118. {
  119. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  120. Con=DriverManager.getConnection("jdbc:odbc:data");
  121. Stmt=Con.createStatement();
  122. ERs=Stmt.executeQuery("SELECT * FROM s1");
  123.  
  124. while(ERs.next())
  125. {
  126. Sno=ERs.getString("ROLLNO");
  127. Sname=ERs.getString("NAME");
  128. m1=ERs.getString("P1");
  129. m2=ERs.getString("P2");
  130. m3=ERs.getString("P3");
  131. m4=ERs.getString("P4");
  132. m5=ERs.getString("P5");
  133.  
  134.  
  135. System.out.println(Sno+" "+Sname+" "+m1+" "+m2+" "+m3+" "+m4+""+m5+"\n");
  136.  
  137. }
  138. Stmt.close();
  139. Con.close();
  140. }
  141. catch(Exception e)
  142. {
  143. System.out.println(e);
  144. }
  145.  
  146.  
  147. }
  148.  
  149. public void windowClosing(WindowEvent we)
  150. {
  151. this.setVisible(false);
  152. System.exit(0);
  153. }
  154.  
  155. public void windowActivated(WindowEvent we)
  156. {
  157. }
  158.  
  159. public void windowDeactivated(WindowEvent we)
  160. {
  161. }
  162. public void windowOpened(WindowEvent we)
  163. {
  164. }
  165. public void windowClosed(WindowEvent we)
  166. {
  167. }
  168. public void windowIconified(WindowEvent we)
  169. {
  170. }
  171.  
  172. public void windowDeiconified(WindowEvent we)
  173. {
  174. }
  175.  
  176. }
Last edited by sam18; Aug 27th, 2007 at 4:11 pm.
Reply With Quote