• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application Trouble

 
Peter Phung
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter
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:
add(options);
because it is a JFrame you need to add to the contentPane so it should be changed to
getContentPane().add(options);
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
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Pete
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic