This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Application frames and components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Application frames and components" Watch "Application frames and components" New topic

Application frames and components

Ronald Pruitt
Ranch Hand

Joined: Jan 15, 2001
Posts: 32
Can anyone point me to or help me with writing an application window that will allow me to open texts, insert, search etc. If I could find some basic code for writting an application window at least. This is for a class project and everything I find uses applets, which we were told not to use. I would appreciate any help. I think I can handle placing the buttons on etc. but where can I find the basics to make this work without using applets?
ryan burgdorfer
Ranch Hand

Joined: Jan 24, 2001
Posts: 219
Just make your public top-most class extend JPanel. In the constructor, create and add all components (buttons, menus, etc.), then in the main() method of the class, instantiate a new JFrame, and set it's content pane to be a new object of your class, set it visible, etc. Here is some sample code from which you can build upon:

Of course, this code is quite bare-bones...and you would have to make your class also implement Actionlistener, etc. to have the buttons/menu items function.
This is one method to setup an application window, there are others (like making your class extend JFrame instead of JPanel). This is the one I prefer though. Hope this helps you get started,
  • Ryan Burgdorfer
  • Java Acolyte

  • [This message has been edited by ryan burgdorfer (edited April 20, 2001).]

<UL TYPE=SQUARE><I><LI>Ryan Burgdorfer<BR><LI>Java Acolyte</I></UL>
I agree. Here's the link:
subject: Application frames and components
It's not a secret anymore!