aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How do I access my field data? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do I access my field data?" Watch "How do I access my field data?" New topic
Author

How do I access my field data?

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8867
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
No I am ok with the form creation, what I am really asking is how do i fetch the data the user types in?
Eddie Vanda
Ranch Hand

Joined: Mar 18, 2003
Posts: 281
Does your code compile ok? Are there any exceptions thrown when you run this code?


The nice thing about Standards is that there are so many to choose from!
Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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

Joined: Apr 02, 2003
Posts: 280
I have manged to fix the problems
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do I access my field data?