Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How do I access my field data?

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is almost a JDBC problem but think it is more to do with my GUI as I have tested my database connection and everything is working fine. Anyway I am trying to insert data from my form into the database but don't know how to fetch the data from the form into the query. Can anyone help?
the class with the form is

and the actual insert page is

I am guessing the problem is that I haven't really specified where the fields are but all the examples I can find create their forms in a panel and then use that but since I have created mine straight into a frame I am a little lost on how to do this.
Thanks
 
Bartender
Posts: 9615
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what you are really asking is how to add your TextFields (AWT) or JTextFields (Swing) to a Frame or JFrame?
aFrame.add(aField)
OR
jFrame.getContentPane().add(jField)
There's a little more to it, since the default layout manager for a Frame or JFrame is java.awt.BorderLayout. Just adding fields to it will put all your fields on top of each other in the center. Try a GridLayout with two rows and alternate adding a Label (or JLabel) and a field.
For more information, consult the Java Tutorial: Creating a GUI with Swing. The "Laying Out Components Within a Container" chapter will be particularly helpful.
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I am ok with the form creation, what I am really asking is how do i fetch the data the user types in?
 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your code compile ok? Are there any exceptions thrown when you run this code?
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It compiles and runs but when I click the button to insert the data I get a load of exception messages. I have tested the database connection and that is working fine the problem seems to be than the insert query doesn't know which form fields I am trying to insert from.
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have manged to fix the problems
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic