Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

[an error occurred while processing this directive]

Java Notes

About Examples

This series of progressive examples shows a typical pattern for building simple applications with a window.
  • Example - First Window shows a main program that creates an empty window (JFrame).
  • Example - Second Window shows a main program with a subclass of JPanel to build a customized GUI (Graphical User Interface) with one (useless) button. This is the real beginning of the pattern that will be used in many examples in these notes.
  • Example - ToUppercase is an application that extends the above pattern to build a running program with labels, text fields, and buttons. It's a simple application that converts strings to uppercase, but can be the basis for many useful programs.

Rationale for some decisions

Java offers many ways to make simple programs. Here is why I made certain choices.
  • Applications, not Applets - The early hype about applets has passed, and they haven't provided as many solutions as applications. Anyway, the applet idea for distributed software is probably better done with Java WebStart. By far the best single use of Java is for applications, so the almost all examples are shown as applications. However, the programs are organized in a way (GUI as a sublcass of JPanel) that makes is very easy to use them as applets also.
  • Subclassing JPanel - Building a GUI entirely in a static main program may be possible, but it's not an OOP way of thinking. Defining classes with constructors is how programming is generally done in OOP, and these examples do that from the very beginning. Simple, useful, realistic, examples of OOP are hard to find, but a Graphical User Interface is an excellent example.
  • Put main in separate class - The main method can be put in any class.
    • Students find this easier to understand. Most students feel uncomfortable when main creates an object of its own class. Moving main to its own class is simple, and makes the code easier to understand.
    • Separating main makes it easier to change between an application and an applet without confusion. It's possible to put main in a JApplet subclass, but again it leads to confusion with no special advantage.
    • If moves the relatively unchanging window handling code into one place, so the student needn't worry about it.
    However, there's also no problem putting main in any class, if you're comfortable with it.

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (
post your own) View All Comments Latest 10 Comments:
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.