Saturday 15 September 2012

java - JFrame does not display correctly -


I was practicing a tutorial on YouTube. Here it is - & gt;

I have checked dozens of codes below but I still can not understand why Jeffrey did not show up correctly. Although I put size 600x400 (or greater), but whenever I did not change anything on running the project, there was no change in the size of JFrame , labels did not even show where the problem is?

This is my code:

  package doanjava; Import java.sql *; Public Sector DB {Connection Con; Statement cents; Reset the result; Public DB () {Connect (); } Public Zero Connect () {try {string driver = "sun.jdbc.odbc.JdbcOdbcDriver"; Class.forName (driver); String db = "jdbc: odbc: catonoai"; Con = DriverManager.getConnection (DB); St = con.createStatement (); String sql = "Choose from HoSoSinhVien '; Rs = st.executeQuery (SQL); while (rsnext ()) {string ho = r.jest string (" ho "); string ten = r.jest string (" ten " String toei = R.getString ("Tuoi"); String Lop = R.Jest String ("Lop"); String Sovanettiyei = R.Jest String ("SodentiOi"); String Dei = R.Jest String ("Dai "); System.out.println (ho +" "+ ten +" | "+" Tuoi: "+ Tuoi +" | "+" omitted: "+ + + +" + "SDT:" + SoDienThoai + " | "+" Diya Chi: "+ DiaChi); }} Hold (exception before) {}} public static zero main (string [] args) {new db (); New gui (); }}   

and

  package doanjava; Import javax.swing *; Public class GUI {JFrame f; Be Jebelbell; Jlabal ten; Jellabal Tuai; JLABL omitted; JTextField T; JTextField T1; JTextField T2; JTextField T3; Public GUI () {frame (); } Public Zero Frame () {f = New JFrame (); F.setVisible (true); F.setSize (600,400); F.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Ho = new jlabel ("ho"); Ten = new jellabell ("ten"); Tuoi = new jellabell ("Tuoi"); Elimination = new JLABEL ("omitted"); T = new JTextField (10); T1 = new JTextField (10); T2 = new JTextField (10); T3 = new JTextField (10); Jpnal p = new jepinal (); P.add (ho); P.add (t); P.add (ten); P.add (T1); P.add (Tuoi); P.add (t2); P.add (pen); P.add (T3); F.add (p); }}    

  string = rsgetstring ("ho");   

beyond system.out.println (); These values ​​are omitted, and there is no effect on JLabel

  ho = new jellabell ("ho");   
  1. Do not set the size of the top-level containers instead the content layout & amp; Call pack () .
  2. Swing GUI should be initialized and updated on EDT.
  3. Please know general (especially case names) category, method and amp; Attribute name & amp; Use them continuously
  4. Post soon, for better support.
  5. Change the form code:
      hold (exception e) {.   

    From:

      hold (exception e) {e.printStackTrace (); // very informative! ..    

No comments:

Post a Comment