Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application frames and components

 
Ronald Pruitt
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic