• 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

Application Trouble

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic