The moose likes Beginning Java and the fly likes Application Trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Application Trouble" Watch "Application Trouble" New topic

Application Trouble

Peter Phung
Ranch Hand

Joined: Dec 06, 2001
Posts: 138
I'm trying to write a database querying application. I've never written an application before, and i can't get my application to appear.
the code compiles fine and appears to run properly. can anyone help?
Here's the code

edited by Dave to format the code with code tags

[ January 30, 2002: Message edited by: Dave Vick ]

Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Where to start???
First you are writing an application - not an Applet. the init() method is something that applets use - because the browser uses that method to initiate the applet. An application needs to use a constructor to create the instance.
Next, using GridBagLayout on your first application is a masochistic thing to do. I commented that stuff out till later.
Theh, when you create a Frame - you need to give it a size bigger than 0x0.
Play with this.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
You define lots of stuff in your init( ) method but it is never called in the code you supplied. Is there more code?
Also, in the code you supply you never instantiate the variables gbMain or gbcMain so in the init method you're going to get a null pointer exception when you try to use them.
At the end of the init method you have:
because it is a JFrame you need to add to the contentPane so it should be changed to
The following code compiles and displays a really small jframe that you have to expand manually (you can set the size of some its internal components and it should display so you can see it).

hope that helps
[ January 30, 2002: Message edited by: Dave Vick ]

Peter Phung
Ranch Hand

Joined: Dec 06, 2001
Posts: 138
Thank's for the help guys, but i decided to leave the class as an applet and write a simple application to create a frame with the class inside.
I agree. Here's the link:
subject: Application Trouble
jQuery in Action, 3rd edition