• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Displaying Data in JTextfield from DB in Swing

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DB Description

Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production"
TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production



Operating System Windows XP
IDE: Eclipse

I have successfully connected to DB. However I have following code which runs fine. (Due to the length of the code I am posting a single Jtextfield to avoid confusion). If anyone would like to see full code. please let me know


My Requirement I want to display data from database when user enters this field which is (JTextfield f2) and presses ENTER key. and the selected data gets displayed in this Jtextfield.

Here is the DB Connection code


Please remember Jtextfield and the above DB connection code are separate classes. I am new to java any hint will be appreciated.

Please refer to the attachment to understand the requirement.

Thanks
untitled.JPG
[Thumbnail for untitled.JPG]
 
Greenhorn
Posts: 6
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying that when the user goes to the text field and presses the enter button on the keyboard you want the information from the database to be displayed?, am i understanding correctly
 
Riyasat Tabrez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes exactly you got it right. For more information please refer to the attachment. I would like to have the same feature as in the attachment. User goes to the Jtextfield and presses ENTER key and the all available records from the DB are presented to the user
 
Davian Ramsay
Greenhorn
Posts: 6
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am not certain which textfield in the image you assign to the variable(f2) so my suggestions: JTextField would not be appropriate to display all the information in a large database because it will only display all the names in a single line so JTextArea would be more appropriate as it may display the data line by line, also to have that being done with the enter key you would then have to assign a KeyListener instead of an action Listener, so i would recommend doing a little reading up on them,
 
Riyasat Tabrez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, f2 is not attached to any field in the image. However I want the mentioned functionality to be on the below portion of the code,



Yes I have also noted that instead of Action Listener Key Listener be used. I once again put-forth my requirement. After the JTestfield f2, there are more Jtextfields which would display other personal information for eg: User presses ENTER and a whole list pops up from the DB (student_name,student_fname,student_dob,_student_address etc..) for all available students user can select the required student, once this selection is made all the remaining JTextfield must get populated with data selected by user. for eg: student_name should go to JTextfield f2, student_fname goes to Jtextfield f3, student_DOB goes to Jtextfield f4 and finally student_address goes to Jtextfield f5.

Please remember I have the above Jtextfields in public class named Swing1 and I am connecting to DB by writing other public class named Oraclejdbc.

Could you please tell me what type of attachment are accepted on this forum (I have tried attaching .txt,.doc,.docx,.java) its not accepting it

Regards
Riyasat

 
reply
    Bookmark Topic Watch Topic
  • New Topic