<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5252893760990180746</id><updated>2011-11-27T16:29:34.579-08:00</updated><title type='text'>Art of Java</title><subtitle type='html'>&lt;b&gt;&lt;a href=http://www.artofjava.blogspot.com&gt;Art of Java&lt;/a&gt;&lt;/b&gt; is my site for Java Programming. Programming Solution,Technique,New Features, Discoveries and all related Java Topics can go here!.

I am still single and have a wonderful girl friend. I am a religious person, humble and I love to share my ideas and skills to others who loved to code too.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>52</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-2948018544032554386</id><published>2009-05-14T06:11:00.000-07:00</published><updated>2009-05-14T06:13:40.045-07:00</updated><title type='text'>What Is Inheritance?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_fKXlq2YJyKk/SgwY-8NnXOI/AAAAAAAAABk/q7myn64Vhmw/s1600-h/clip_image001.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 246px;" src="http://1.bp.blogspot.com/_fKXlq2YJyKk/SgwY-8NnXOI/AAAAAAAAABk/q7myn64Vhmw/s320/clip_image001.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5335667128121384162" /&gt;&lt;/a&gt;&lt;br /&gt;A class inherits state and behavior from its superclass. Inheritance provides a powerful and natural mechanism for organizing and structuring software programs. &lt;br /&gt;&lt;br /&gt;For example, mountain bikes, racing bikes, and tandems are all kinds of bicycles. In object-oriented terminology, mountain bikes, racing bikes, and tandems are all subclasses of the bicycle class. Similarly, the bicycle class is the superclass of mountain bikes, racing bikes, and tandems. This relationship is shown in the following figure.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-2948018544032554386?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/2948018544032554386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=2948018544032554386' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2948018544032554386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2948018544032554386'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2009/05/what-is-inheritance.html' title='What Is Inheritance?'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_fKXlq2YJyKk/SgwY-8NnXOI/AAAAAAAAABk/q7myn64Vhmw/s72-c/clip_image001.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8848627158983003358</id><published>2009-05-14T06:06:00.000-07:00</published><updated>2009-05-14T06:08:04.016-07:00</updated><title type='text'>What Is a Message?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_fKXlq2YJyKk/SgwXmp7bcQI/AAAAAAAAABc/n0h6SQw-dWg/s1600-h/clip_image001.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 205px; height: 118px;" src="http://4.bp.blogspot.com/_fKXlq2YJyKk/SgwXmp7bcQI/AAAAAAAAABc/n0h6SQw-dWg/s320/clip_image001.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5335665611384779010" /&gt;&lt;/a&gt;&lt;br /&gt;Software objects interact and communicate with each other using messages. This may be termed as argument or a parameter&lt;br /&gt;&lt;br /&gt;A single object alone is generally not very useful. Instead, an object usually appears as a component of a larger program or application that contains many other objects. Through the interaction of these objects, programmers achieve higher-order functionality and more complex behavior. Your bicycle hanging from a hook in the garage is just a bunch of titanium alloy and rubber; by itself, the bicycle is incapable of any activity. The bicycle is useful only when another object (you) interacts with it (pedal). &lt;br /&gt;&lt;br /&gt;Software objects interact and communicate with each other by sending messages to each other. When object A wants object B to perform one of B's methods, object A sends a message to object B &lt;br /&gt;&lt;br /&gt;Sometimes, the receiving object needs more information so that it knows exactly what to do; for example, when you want to change gears on your bicycle, you have to indicate which gear you want. This information is passed along with the message as parameters. &lt;br /&gt;&lt;br /&gt;The next figure shows the three components that comprise a message: &lt;br /&gt;The object to which the message is addressed (YourBicycle) &lt;br /&gt;The name of the method to perform (changeGears) &lt;br /&gt;Any parameters needed by the method (lowerGear)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8848627158983003358?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8848627158983003358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8848627158983003358' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8848627158983003358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8848627158983003358'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2009/05/what-is-message.html' title='What Is a Message?'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_fKXlq2YJyKk/SgwXmp7bcQI/AAAAAAAAABc/n0h6SQw-dWg/s72-c/clip_image001.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4153381296822360287</id><published>2009-05-14T06:03:00.000-07:00</published><updated>2009-05-14T06:05:56.359-07:00</updated><title type='text'>What Is an Object?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_fKXlq2YJyKk/SgwXE5uYyeI/AAAAAAAAABU/b9BFXZFT2Cc/s1600-h/clip_image001.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 317px; height: 133px;" src="http://2.bp.blogspot.com/_fKXlq2YJyKk/SgwXE5uYyeI/AAAAAAAAABU/b9BFXZFT2Cc/s320/clip_image001.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5335665031509494242" /&gt;&lt;/a&gt;&lt;br /&gt;An object is a software bundle of related variables and methods. Software objects are often used to model real-world objects you find in everyday life. &lt;br /&gt;&lt;br /&gt;They all have state and behavior. For example, dogs have state (name, color, breed, hungry) and behavior (barking, fetching, and wagging tail). Bicycles have state (current gear, current pedal cadence, two wheels, number of gears) and behavior (braking, accelerating, slowing down, changing gears). &lt;br /&gt;&lt;br /&gt;Software objects are modeled after real-world objects in that they too have state and behavior. A software object maintains its state in one or more variables. A variable is an item of data named by an identifier. A software object implements its behavior with methods. A method is a function (subroutine) associated with an object. &lt;br /&gt;&lt;br /&gt;Definition: An object is a software bundle of variables and related methods.&lt;br /&gt;&lt;br /&gt;In addition to its variables, an object, say a bicycle would also have methods to brake, change the pedal cadence, and change gears. (The bike would not have a method for changing the speed of the bicycle, as the bike's speed is just a side effect of what gear it's in, how fast the rider is pedaling, whether the brakes are on, and how steep the hill is.) These methods are formally known as instance methods because they inspect or change the state of a particular bicycle instance.&lt;br /&gt;&lt;br /&gt;The object diagrams show that the object's variables make up the center, or nucleus, of the object. Methods surround and hide the object's nucleus from other objects in the program. Packaging an object's variables within the protective custody of its methods is called encapsulation This conceptual picture of an object-a nucleus of variables packaged within a protective membrane of methods-is an ideal representation of an object and is the ideal that designers of object-oriented systems strive for. However, it's not the whole story. Often, for practical reasons, an object may wish to expose some of its variables or hide some of its methods.&lt;br /&gt;• Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Also, an object can be easily passed around in the system. You can give your bicycle to someone else, and it will still work. &lt;br /&gt;• Information hiding: An object has a public interface that other objects can use to communicate with it. The object can maintain private information and methods that can be changed at any time without affecting the other objects that depend on it. You don't need to understand the gear mechanism on your bike to use it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4153381296822360287?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4153381296822360287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4153381296822360287' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4153381296822360287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4153381296822360287'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2009/05/what-is-object_2137.html' title='What Is an Object?'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_fKXlq2YJyKk/SgwXE5uYyeI/AAAAAAAAABU/b9BFXZFT2Cc/s72-c/clip_image001.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-1187465244082188149</id><published>2009-05-14T06:00:00.000-07:00</published><updated>2009-05-14T06:02:20.895-07:00</updated><title type='text'>Java Basics</title><content type='html'>History&lt;br /&gt;James Gosling was not satisfied with C++.  There were several insufficiencies which hindered his plans.  So, he created his own.  Initially called Oak by James Gosling for the Green Project. However, since that name was already taken, it was later named Java.&lt;br /&gt;&lt;br /&gt;Language Features&lt;br /&gt;Platform Independent – can run on any environment&lt;br /&gt;Garbage Collection – objects are automatically destroyed from memory&lt;br /&gt;Object Oriented&lt;br /&gt;Multithreaded – can perform several tasks at the same time&lt;br /&gt;Dynamically Linked -  classes are loaded as needed&lt;br /&gt;&lt;br /&gt;OOP Concepts&lt;br /&gt;If you've never used an object-oriented language before, you need to understand the underlying concepts before you begin writing code. You need to understand what an object is, what a class is, how objects and classes are related, and how objects communicate by using messages. The first few sections of this trail describe the concepts behind object-oriented programming. The last section shows how these concepts translate into code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-1187465244082188149?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/1187465244082188149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=1187465244082188149' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1187465244082188149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1187465244082188149'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2009/05/java-basics_14.html' title='Java Basics'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-2327354995524949962</id><published>2007-05-01T17:59:00.000-07:00</published><updated>2007-05-01T18:00:13.934-07:00</updated><title type='text'>WinDerivedClassCatTest</title><content type='html'>import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;&lt;br /&gt;public class WinDerivedClassCatTest extends JFrame{&lt;br /&gt; &lt;br /&gt; //ds&lt;br /&gt; int row = 10, col = 10;&lt;br /&gt; String output = "";&lt;br /&gt; &lt;br /&gt; public static void main(String[] args){&lt;br /&gt;  WinDerivedClassCatTest cattest = new WinDerivedClassCatTest();&lt;br /&gt;  cattest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;  cattest.setBounds(150,150,400,300);&lt;br /&gt;  cattest.setVisible(true);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public WinDerivedClassCatTest(){&lt;br /&gt;  super("Inheritance Demo For Cats");&lt;br /&gt;  &lt;br /&gt;  Container pane = getContentPane();&lt;br /&gt;  pane.setLayout(new BorderLayout());&lt;br /&gt;  pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;  pane.setBackground(new Color(250,100,50));&lt;br /&gt;  &lt;br /&gt;  //add text area&lt;br /&gt;  JTextArea textarea = new JTextArea(row,col);&lt;br /&gt;  //pane.add(textarea);&lt;br /&gt;  &lt;br /&gt;  DerivedClass aCat = new DerivedClass("Toger","Tiger");&lt;br /&gt;  Cat bCat = new Cat("Meeeiaow");&lt;br /&gt;  &lt;br /&gt;  //output here&lt;br /&gt;  &lt;br /&gt;  output += aCat+"\n";&lt;br /&gt;  output += bCat+"\n";&lt;br /&gt;  &lt;br /&gt;  //display here&lt;br /&gt;  textarea.setText(output);&lt;br /&gt;  pane.add(textarea,BorderLayout.NORTH);&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-2327354995524949962?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/2327354995524949962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=2327354995524949962' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2327354995524949962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2327354995524949962'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/05/winderivedclasscattest.html' title='WinDerivedClassCatTest'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8592140666605285913</id><published>2007-05-01T17:58:00.000-07:00</published><updated>2007-05-01T17:59:11.923-07:00</updated><title type='text'>Cat</title><content type='html'>public class Cat extends SuperClass{&lt;br /&gt; &lt;br /&gt; //name and breed&lt;br /&gt; private String name;&lt;br /&gt; private String breed;&lt;br /&gt; &lt;br /&gt; public Cat(String animalName){&lt;br /&gt;  super("Cat");&lt;br /&gt;  name = animalName;&lt;br /&gt;  breed = "Unknown";&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //animal constructor&lt;br /&gt; public Cat(String animalName,String animalBreed){&lt;br /&gt;  super("Cat");&lt;br /&gt;  name = animalName;&lt;br /&gt;  breed = animalBreed;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //convert to String&lt;br /&gt; public String toString(){&lt;br /&gt;  return super.toString() + "\n" + name + "is a" + breed + "type of cat.\n";&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8592140666605285913?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8592140666605285913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8592140666605285913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8592140666605285913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8592140666605285913'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/05/cat.html' title='Cat'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-2198624312195280456</id><published>2007-05-01T17:57:00.001-07:00</published><updated>2007-05-01T17:57:25.601-07:00</updated><title type='text'>DerivedClass</title><content type='html'>public class DerivedClass extends SuperClass{&lt;br /&gt; //name and breed&lt;br /&gt; private String name;&lt;br /&gt; private String breed;&lt;br /&gt; &lt;br /&gt; public DerivedClass(String animalName){&lt;br /&gt;  super("Dog");&lt;br /&gt;  name = animalName;&lt;br /&gt;  breed = "Unknown";&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //animal constructor&lt;br /&gt; public DerivedClass(String animalName,String animalBreed){&lt;br /&gt;  super("Dog");&lt;br /&gt;  name = animalName;&lt;br /&gt;  breed = animalBreed;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //convert to string&lt;br /&gt; public String toString(){&lt;br /&gt;  return super.toString() +"\n"+name+"is a"+breed+"type of dog.\n";&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-2198624312195280456?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/2198624312195280456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=2198624312195280456' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2198624312195280456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2198624312195280456'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/05/derivedclass.html' title='DerivedClass'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4715966597773011816</id><published>2007-05-01T17:56:00.001-07:00</published><updated>2007-05-01T17:56:59.101-07:00</updated><title type='text'>SuperClass</title><content type='html'>public class SuperClass{&lt;br /&gt; //animal type&lt;br /&gt; private String type;&lt;br /&gt; &lt;br /&gt; public SuperClass(String animalType){&lt;br /&gt;  type = new String( animalType );&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //conversion to string&lt;br /&gt; public String toString(){&lt;br /&gt;  return "This is a type of" + type + ".";&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4715966597773011816?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4715966597773011816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4715966597773011816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4715966597773011816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4715966597773011816'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/05/superclass.html' title='SuperClass'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4765515197281079899</id><published>2007-05-01T17:42:00.000-07:00</published><updated>2007-05-01T17:43:51.965-07:00</updated><title type='text'>SysFontInfo</title><content type='html'>import java.awt.*;&lt;br /&gt;import java.awt.GraphicsEnvironment;&lt;br /&gt;import java.awt.Dimension;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;//import j2packs.BottomPanel;&lt;br /&gt;//import j2packs.TopPanel;&lt;br /&gt;&lt;br /&gt;public class SysFontInfo extends JFrame {&lt;br /&gt; &lt;br /&gt; //cdm&lt;br /&gt; String output ="", topTitle ="";&lt;br /&gt; int count, txtrow, txtcol;&lt;br /&gt; &lt;br /&gt; public static void main(String[] args){&lt;br /&gt;  SysFontInfo fontsavailable = new SysFontInfo();&lt;br /&gt;  fontsavailable.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);&lt;br /&gt;  fontsavailable.setSize(400,300);&lt;br /&gt;  fontsavailable.setVisible(true);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public SysFontInfo(){&lt;br /&gt;  &lt;br /&gt;  super("Fonts on this PlatForm");&lt;br /&gt;  displayFonts();&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; protected void displayFonts(){&lt;br /&gt;  &lt;br /&gt;  Container pane = getContentPane();&lt;br /&gt;  pane.setBackground(Color.blue);&lt;br /&gt;  pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;  &lt;br /&gt;  JTextArea outputArea = new JTextArea(txtrow,txtcol);&lt;br /&gt;  &lt;br /&gt;  Toolkit toolkit = Toolkit.getDefaultToolkit();&lt;br /&gt;  Dimension winSize = toolkit.getScreenSize();&lt;br /&gt;  &lt;br /&gt;  output += "This computer has the following specs:\n";&lt;br /&gt;  output += "Screen resolution: " + toolkit.getScreenResolution();&lt;br /&gt;  output += "dots per inch.\n";&lt;br /&gt;  output += "Screen size: " + winSize.width + " x ";&lt;br /&gt;  output += winSize.height + "pixels\n";&lt;br /&gt;  &lt;br /&gt;  GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();&lt;br /&gt;  String[] fontnames = e.getAvailableFontFamilyNames();&lt;br /&gt;  &lt;br /&gt;  output += "Font available on this platform:\n";&lt;br /&gt;  for(count = 0;count &lt; fontnames.length;count++){&lt;br /&gt;   output += "" + (count+1) + "" + fontnames[count] + "\n";&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  //display&lt;br /&gt;  outputArea.setText(output);&lt;br /&gt;  outputArea.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;  outputArea.setEditable(false);&lt;br /&gt;  pane.add(outputArea);&lt;br /&gt;  &lt;br /&gt;  JScrollPane scrollpane = new JScrollPane(outputArea);&lt;br /&gt;  pane.add(scrollpane);&lt;br /&gt;  &lt;br /&gt;  //add top and bottom panel&lt;br /&gt;  //topTitle = "SYSTEM INFORMATION";&lt;br /&gt; // pane.add(new TopPanel(topTitle), BorderLayout.NORTH);&lt;br /&gt; // pane.add(new BottomPanel(), BorderLayout.SOUTH);&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4765515197281079899?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4765515197281079899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4765515197281079899' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4765515197281079899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4765515197281079899'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/05/sysfontinfo.html' title='SysFontInfo'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-5811024192968381481</id><published>2007-04-16T18:13:00.001-07:00</published><updated>2007-04-16T18:13:30.803-07:00</updated><title type='text'>Prime Factors</title><content type='html'>import javax.swing.*; &lt;br /&gt;&lt;br /&gt;public class Prime_Factors{&lt;br /&gt; public static void main(String[] args){&lt;br /&gt; Prime_Factors factors=new Prime_Factors();&lt;br /&gt; }&lt;br /&gt; public Prime_Factors(){&lt;br /&gt; String output="",input;&lt;br /&gt; int num,count,h=0,get[]=new int[100],a=0;&lt;br /&gt; &lt;br /&gt; input= JOptionPane.showInputDialog("Enter a number:"); &lt;br /&gt; &lt;br /&gt; num=Integer.parseInt(input);&lt;br /&gt; do{&lt;br /&gt; for(int x=2;x&lt;=num;x++)&lt;br /&gt;     {&lt;br /&gt;  count=0;&lt;br /&gt;  for(int z=1;z&lt;=num;z++)&lt;br /&gt;  {&lt;br /&gt;   &lt;br /&gt;  if (x%z==0)&lt;br /&gt;    {&lt;br /&gt;     count=count+1;   &lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  if (count==2)&lt;br /&gt;   {&lt;br /&gt;  get[h]=x;  &lt;br /&gt;  h++;&lt;br /&gt;  } &lt;br /&gt; }&lt;br /&gt;   if(num%get[a]==0)&lt;br /&gt;     {&lt;br /&gt;      output+=get[a]+" ";&lt;br /&gt;      num=num/get[a];&lt;br /&gt;     }&lt;br /&gt;   if(num%get[a]!=0 &amp;&amp; num!=0)&lt;br /&gt;    a++;&lt;br /&gt;      {&lt;br /&gt;      if(num%get[a]==0)&lt;br /&gt;   {&lt;br /&gt;   output+=get[a]+" ";&lt;br /&gt;   num=num/get[a];&lt;br /&gt;   }&lt;br /&gt;      }&lt;br /&gt;  &lt;br /&gt; }while(num!=1);          &lt;br /&gt; &lt;br /&gt; JOptionPane.showMessageDialog(null,output,"Prime Numbers",JOptionPane.INFORMATION_MESSAGE);&lt;br /&gt; System.exit(0);&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-5811024192968381481?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/5811024192968381481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=5811024192968381481' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/5811024192968381481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/5811024192968381481'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/prime-factors.html' title='Prime Factors'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-2989759385087259658</id><published>2007-04-16T18:12:00.001-07:00</published><updated>2007-04-16T18:12:44.732-07:00</updated><title type='text'>Pascal Triangle</title><content type='html'>import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class Pascal{&lt;br /&gt; public static void main(String[] args){&lt;br /&gt;  Pascal pas=new Pascal();&lt;br /&gt; }&lt;br /&gt; public Pascal(){&lt;br /&gt; String output="",input;&lt;br /&gt; int num,a,b;&lt;br /&gt; &lt;br /&gt; input=JOptionPane.showInputDialog("Enter a number:");&lt;br /&gt; num=Integer.parseInt(input);&lt;br /&gt;&lt;br /&gt; for (int x=1;x&lt;=num;x++)&lt;br /&gt;  {&lt;br /&gt;  for (int z=num;z&gt;=x;z--)&lt;br /&gt;  {&lt;br /&gt;  output+=" ";&lt;br /&gt;  }&lt;br /&gt;  output+="1"+" ";&lt;br /&gt;  b=1;a=0;   &lt;br /&gt;   for(int y=x;y&gt;1;y--)&lt;br /&gt;  {&lt;br /&gt;  b=(y*b)/(a+1);&lt;br /&gt;  output+=b+" ";&lt;br /&gt;  a++;&lt;br /&gt;  }&lt;br /&gt;  output+="1";&lt;br /&gt;  output+="\n";&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;   &lt;br /&gt;   &lt;br /&gt; &lt;br /&gt;JOptionPane.showMessageDialog(null,output,"PASCAL TRIANGLE",JOptionPane.INFORMATION_MESSAGE);&lt;br /&gt; System.exit(0);&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-2989759385087259658?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/2989759385087259658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=2989759385087259658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2989759385087259658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2989759385087259658'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/pascal-triangle.html' title='Pascal Triangle'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4639254210937378228</id><published>2007-04-16T18:09:00.000-07:00</published><updated>2007-04-16T18:10:25.570-07:00</updated><title type='text'>FlowLayout</title><content type='html'>import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;public class FlowLayoutTest extends JFrame{&lt;br /&gt; public static void main(String[] args){&lt;br /&gt;  FlowLayoutTest flowlayout = new FlowLayoutTest();&lt;br /&gt;  flowlayout.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;  flowlayout.setSize(400,300);&lt;br /&gt;  flowlayout.setVisible(true);&lt;br /&gt; }&lt;br /&gt; public FlowLayoutTest(){&lt;br /&gt;  super("FlowLayout Manager");&lt;br /&gt;  Container pane = getContentPane();&lt;br /&gt;  pane.setLayout(new FlowLayout(FlowLayout.LEFT));&lt;br /&gt;  pane.add(new JLabel("This is a flowlayout test"));&lt;br /&gt;  JButton button = new JButton("FlowLayout");&lt;br /&gt;  button.setBorder(BorderFactory.createRaisedBevelBorder());&lt;br /&gt;  pane.add(button);&lt;br /&gt;  pane.add(new JTextField(30));&lt;br /&gt;  pane.add(new JTextArea("This is the textarea of this FlowLayout", 5,10));&lt;br /&gt;  pane.add(new JLabel("This is the label created by flowlayout"));&lt;br /&gt;  pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4639254210937378228?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4639254210937378228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4639254210937378228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4639254210937378228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4639254210937378228'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/flowlayout.html' title='FlowLayout'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4968707882564734836</id><published>2007-04-16T18:08:00.000-07:00</published><updated>2007-04-16T18:09:12.647-07:00</updated><title type='text'>FIBONACCI</title><content type='html'>import javax.swing.*; &lt;br /&gt;&lt;br /&gt;public class Fib{&lt;br /&gt; public static void main(String[] args){&lt;br /&gt; Fib fb=new Fib();&lt;br /&gt; }&lt;br /&gt; public Fib(){&lt;br /&gt; String output="",input;&lt;br /&gt; int num,a,b,sum=0;&lt;br /&gt; &lt;br /&gt; input= JOptionPane.showInputDialog("Enter a number:"); &lt;br /&gt; &lt;br /&gt; num=Integer.parseInt(input);&lt;br /&gt; &lt;br /&gt;  &lt;br /&gt; a=0;&lt;br /&gt; b=1; &lt;br /&gt; for(int x=1;x&lt;=num;x++)&lt;br /&gt; {    &lt;br /&gt; sum=a+b;&lt;br /&gt; a=b;&lt;br /&gt; b=sum; &lt;br /&gt; output+=sum+" ";&lt;br /&gt; output+="\n";&lt;br /&gt; }&lt;br /&gt; JOptionPane.showMessageDialog(null,output,"Jo!!,THIS IS A FIBONACCI...BABY",JOptionPane.INFORMATION_MESSAGE);&lt;br /&gt; System.exit(0);&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4968707882564734836?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4968707882564734836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4968707882564734836' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4968707882564734836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4968707882564734836'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/fibonacci.html' title='FIBONACCI'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-912927383974760276</id><published>2007-04-16T18:07:00.000-07:00</published><updated>2007-04-16T18:08:07.392-07:00</updated><title type='text'>BookSale</title><content type='html'>import java.text.*;&lt;br /&gt;import javax.swing.text.MaskFormatter;&lt;br /&gt;import java.text.Format.*;&lt;br /&gt;import java.text.ParseException;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import javax.swing.border.BevelBorder;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;import java.util.Calendar;&lt;br /&gt;import java.text.DateFormatSymbols;&lt;br /&gt;import java.sql.*;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//CLASS OF frame 2 FOR STUDENT FILE&lt;br /&gt;&lt;br /&gt; class BookSale extends JFrame{&lt;br /&gt; //ds&lt;br /&gt; String output="";&lt;br /&gt; private Container pane = getContentPane();&lt;br /&gt; private JTable table;&lt;br /&gt; private Connection con;&lt;br /&gt; int row=300,col=3;&lt;br /&gt; private JLabel pic2, label, label1, label2, label3, label4,label5,label6,label7,label8,label9;&lt;br /&gt; private JTextField field1, field2, field3, field4, field5, field6, field7,field8;&lt;br /&gt; //JComboBox combo1, combo2, combo3;&lt;br /&gt; //private String gender[] = {"Male","Female"};&lt;br /&gt; //private String semester[] = {"First", "Second", "Summer"};&lt;br /&gt; //private String status[] = {"New", "Old/Active", "Returnee", "Transferee"};&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;public BookSale()&lt;br /&gt; {&lt;br /&gt; setTitle("BOOK SALES FORM");&lt;br /&gt; &lt;br /&gt; JTextArea textarea;&lt;br /&gt; &lt;br /&gt; pane.setBackground(Color.black);&lt;br /&gt; pane.setLayout(null);&lt;br /&gt; Font font = new Font("Teletype",Font.PLAIN,18);&lt;br /&gt;&lt;br /&gt; &lt;br /&gt; JLabel label = new JLabel("COR JESU COLLEGE\n Digos City",JLabel.CENTER);&lt;br /&gt; label.setFont(font);&lt;br /&gt; label.setBounds(50,10,400,40);&lt;br /&gt; label.setForeground(Color.pink);&lt;br /&gt; label.setBackground(Color.yellow);&lt;br /&gt; label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));   &lt;br /&gt; pane.add(label,BorderLayout.CENTER);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//for pictures or logo&lt;br /&gt;    Icon logo = new ImageIcon("logo3.gif"); &lt;br /&gt;    pic2 = new JLabel(logo);&lt;br /&gt;    pic2.setBounds(50,0,60,60);&lt;br /&gt;    pane.add(pic2);   &lt;br /&gt;&lt;br /&gt;//SET DATE HERE&lt;br /&gt;  textarea = new JTextArea();&lt;br /&gt;  GregorianCalendar today = new GregorianCalendar();&lt;br /&gt;&lt;br /&gt;  String[]weekdays = new            DateFormatSymbols().getWeekdays();&lt;br /&gt;  String[]months = new DateFormatSymbols().getMonths();&lt;br /&gt;&lt;br /&gt;  output+=""+weekdays[today.get(today.DAY_OF_WEEK)];&lt;br /&gt;  output+=", "+(today.get(today.DATE))+" ";&lt;br /&gt;  output+=months[today.get(today.MONTH)]+"";&lt;br /&gt;  output+=today.get(today.YEAR)+"\n";&lt;br /&gt;&lt;br /&gt;//LABELS HERE&lt;br /&gt;label = new JLabel("B O O K  S A L E  F O R M");&lt;br /&gt; label.setBounds(100,60,350,50);&lt;br /&gt; label.setFont(new Font("Broadway BT",Font.BOLD,18));&lt;br /&gt; label.setForeground(Color.yellow);&lt;br /&gt; label.setBackground(Color.blue);&lt;br /&gt; pane.add(label);        &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;label1 = new JLabel("Date:");&lt;br /&gt; label1.setBounds(280,120,200,20);&lt;br /&gt; label1.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label1.setForeground(Color.white);&lt;br /&gt; pane.add(label1);       &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;textarea.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; textarea.setEditable(false);&lt;br /&gt; textarea.setText(output);&lt;br /&gt; textarea.setBounds(320,120,180,20);&lt;br /&gt; textarea.setForeground(Color.pink);&lt;br /&gt; textarea.setBackground(Color.black);&lt;br /&gt; pane.add(textarea);&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;label3 = new JLabel("Name:");&lt;br /&gt; label3.setBounds(10,120,250,20);&lt;br /&gt; label3.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label3.setForeground(Color.white);&lt;br /&gt; pane.add(label3);       &lt;br /&gt; field3 = new JTextField();&lt;br /&gt; field3.setBounds(50,120,200,20);&lt;br /&gt; field3.setText("");&lt;br /&gt; field3.setFont(new Font("Tahoma",Font.PLAIN,16));&lt;br /&gt; field3.setForeground(Color.blue);&lt;br /&gt; pane.add(field3);&lt;br /&gt;//pane.add(table);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//FOR TABLE&lt;br /&gt;//JTable inventTable = new JTable(row,col);&lt;br /&gt;  //  inventTable.setGridColor(Color.gray);&lt;br /&gt;     &lt;br /&gt;    //JScrollPane inventScroll = new JScrollPane(inventTable);&lt;br /&gt;    //inventScroll.setBounds(20,150,450,100);&lt;br /&gt;    //pane.add(inventScroll);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;label4 = new JLabel("TOTAL P:");&lt;br /&gt; label4.setBounds(300,270,150,20);&lt;br /&gt; label4.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label4.setForeground(Color.white);&lt;br /&gt; pane.add(label4);     &lt;br /&gt; field4 = new JTextField();&lt;br /&gt; field4.setBounds(360,270,120,20);&lt;br /&gt; field4.setText("");&lt;br /&gt; field4.setFont(new Font("Tahoma",Font.PLAIN,16));&lt;br /&gt; field4.setForeground(Color.blue);&lt;br /&gt; pane.add(field4);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;label5 = new JLabel("Receive Payment By:");&lt;br /&gt; label5.setBounds(150,310,150,20);&lt;br /&gt; label5.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label5.setForeground(Color.white);&lt;br /&gt; pane.add(label5);     &lt;br /&gt; field5 = new JTextField();&lt;br /&gt; field5.setBounds(290,310,190,20);&lt;br /&gt; field5.setText("");&lt;br /&gt; field5.setFont(new Font("Tahoma",Font.PLAIN,16));&lt;br /&gt; field5.setForeground(Color.blue);&lt;br /&gt; pane.add(field5);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;label6 = new JLabel("Cashier");&lt;br /&gt; label6.setBounds(360,330,250,20);&lt;br /&gt; label6.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label6.setForeground(Color.white);&lt;br /&gt; pane.add(label6);     &lt;br /&gt;&lt;br /&gt;label7 = new JLabel("O.R. Number:");&lt;br /&gt; label7.setBounds(290,360,150,20);&lt;br /&gt; label7.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label7.setForeground(Color.white);&lt;br /&gt; pane.add(label7);     &lt;br /&gt; field7 = new JTextField();&lt;br /&gt; field7.setBounds(375,360,105,20);&lt;br /&gt; field7.setText("");&lt;br /&gt; field7.setFont(new Font("Tahoma",Font.PLAIN,16));&lt;br /&gt; field7.setForeground(Color.blue);&lt;br /&gt; pane.add(field7);&lt;br /&gt;&lt;br /&gt;label8 = new JLabel("Recieved in Good Condition By:");&lt;br /&gt; label8.setBounds(120,390,250,20);&lt;br /&gt; label8.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label8.setForeground(Color.white);&lt;br /&gt; pane.add(label8);     &lt;br /&gt; field8 = new JTextField();&lt;br /&gt; field8.setBounds(290,390,190,20);&lt;br /&gt; field8.setText("");&lt;br /&gt; field8.setFont(new Font("Tahoma",Font.PLAIN,16));&lt;br /&gt; field8.setForeground(Color.blue);&lt;br /&gt; pane.add(field8);&lt;br /&gt;&lt;br /&gt;label9 = new JLabel("Parent/Guardian/Student");&lt;br /&gt; label9.setBounds(300,410,250,20);&lt;br /&gt; label9.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt; label9.setForeground(Color.white);&lt;br /&gt; pane.add(label9);     &lt;br /&gt;&lt;br /&gt;JPanel bottompanel=new JPanel();&lt;br /&gt;   bottompanel.setBackground(Color.white);&lt;br /&gt; &lt;br /&gt; JButton buttonnew;&lt;br /&gt; JButton buttonsave;&lt;br /&gt; JButton buttonsearch;&lt;br /&gt; JButton buttonprint;&lt;br /&gt; JButton buttonclose;&lt;br /&gt; JButton buttondelete;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//dimension size of button&lt;br /&gt; Dimension size=new Dimension(50,30);&lt;br /&gt;//bevel JLabel label1 = newbutton&lt;br /&gt; Border edge=BorderFactory.createRaisedBevelBorder();&lt;br /&gt;&lt;br /&gt;//declare bottons&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;     buttonnew = new JButton("NEW");&lt;br /&gt;     buttonnew.setBounds(10,460,60,30);&lt;br /&gt;     buttonnew.setPreferredSize(size);&lt;br /&gt;     buttonnew.setBorder(edge);&lt;br /&gt;     buttonnew.setToolTipText("click this button to add file.");&lt;br /&gt;     buttonnew.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;     buttonnew.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;     buttonnew.setBackground(new Color(10,250,210));&lt;br /&gt;     buttonnew.setForeground(new Color(0,5,255));&lt;br /&gt;     buttonnew.setMnemonic('N');&lt;br /&gt;     bottompanel.add(buttonnew);&lt;br /&gt;&lt;br /&gt;     buttonsave = new JButton("SAVE");&lt;br /&gt;     buttonsave.setPreferredSize(size);&lt;br /&gt;     buttonsave.setBorder(edge);&lt;br /&gt;     buttonsave.setToolTipText("it saves the files");&lt;br /&gt;     buttonsave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;     buttonsave.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;     buttonsave.setForeground(new Color(0,5,255));&lt;br /&gt;     buttonsave.setBackground(new Color(10,250,210));&lt;br /&gt;     buttonsave.setBounds(100,460,60,30);&lt;br /&gt;     buttonsave.setMnemonic('S');     &lt;br /&gt;     bottompanel.add(buttonsave);&lt;br /&gt; &lt;br /&gt;     buttonprint = new JButton("PRINT");&lt;br /&gt;     buttonprint.setBounds(190,460,60,30);&lt;br /&gt;     buttonprint.setPreferredSize(size);&lt;br /&gt;     buttonprint.setBorder(edge);&lt;br /&gt;     buttonprint.setToolTipText("it gives you a hard copy");&lt;br /&gt;     buttonprint.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;     buttonprint.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;     buttonprint.setForeground(new Color(0,5,255));&lt;br /&gt;     buttonprint.setBackground(new Color(10,250,210));&lt;br /&gt;     buttonprint.setMnemonic('P');&lt;br /&gt;     bottompanel.add(buttonprint);&lt;br /&gt;&lt;br /&gt; buttonsearch = new JButton("SEARCH");&lt;br /&gt; buttonsearch.setBounds(280,460,60,30);&lt;br /&gt; buttonsearch.setPreferredSize(size);&lt;br /&gt; buttonsearch.setBorder(edge);&lt;br /&gt; buttonsearch.setToolTipText("click this button to find");&lt;br /&gt; buttonsearch.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt; buttonsearch.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt; buttonsearch.setForeground(new Color(0,5,255));&lt;br /&gt; buttonsearch.setBackground(new Color(10,250,210));&lt;br /&gt; buttonsearch.setMnemonic('R');&lt;br /&gt; bottompanel.add(buttonsearch);&lt;br /&gt;&lt;br /&gt; buttondelete = new JButton("DELETE");&lt;br /&gt; buttondelete.setBounds(370,460,60,30);&lt;br /&gt; buttondelete.setPreferredSize(size);&lt;br /&gt; buttondelete.setBorder(edge);&lt;br /&gt; buttondelete.setToolTipText("Click this button to erase the file"); buttondelete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt; buttondelete.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt; buttondelete.setForeground(new Color(0,5,255));&lt;br /&gt; buttondelete.setBackground(new Color(10,250,210));&lt;br /&gt; buttondelete.setMnemonic('D');&lt;br /&gt; bottompanel.add(buttondelete);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; buttonclose = new JButton("CLOSE");&lt;br /&gt; buttonclose.setBounds(460,460,60,30);&lt;br /&gt; buttonclose.setPreferredSize(size);&lt;br /&gt; buttonclose.setBorder(edge);&lt;br /&gt; buttonclose.setToolTipText("Click this button to terminate the frame");  buttonclose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt; buttonclose.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt; buttonclose.setForeground(new Color(0,5,255));&lt;br /&gt; buttonclose.setBackground(new Color(10,250,210));&lt;br /&gt; buttonclose.setMnemonic('C');&lt;br /&gt; bottompanel.add(buttonclose);&lt;br /&gt;&lt;br /&gt; //pane.add(bottompanel);&lt;br /&gt;     pane.add(buttonsearch);    &lt;br /&gt;     pane.add(buttonnew);&lt;br /&gt;     pane.add(buttonprint);&lt;br /&gt;     pane.add(buttonsave);&lt;br /&gt;     pane.add(buttonclose);&lt;br /&gt;     pane.add(buttondelete);    &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;buttonclose.addActionListener(new ActionListener(){&lt;br /&gt;  public void actionPerformed(ActionEvent e){&lt;br /&gt;setVisible(false);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//display table&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; String url = "jdbc:odbc:cim";  &lt;br /&gt;       // pane.setLayout(null);     &lt;br /&gt;&lt;br /&gt;      // Load the driver to allow connection to the database&lt;br /&gt;      try {&lt;br /&gt;  Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );&lt;br /&gt;&lt;br /&gt;  con = DriverManager.getConnection( &lt;br /&gt;     url );&lt;br /&gt;      } &lt;br /&gt;      catch ( ClassNotFoundException cnfex ) {&lt;br /&gt;  System.err.println( &lt;br /&gt;     "Failed to load JDBC/ODBC driver." );&lt;br /&gt;  cnfex.printStackTrace();&lt;br /&gt;  System.exit( 1 );  // terminate program&lt;br /&gt;      }&lt;br /&gt;      catch ( SQLException sqlex ) {&lt;br /&gt;  System.err.println( "Unable to connect" );&lt;br /&gt;  sqlex.printStackTrace();&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      getTable();&lt;br /&gt;&lt;br /&gt;      setSize( 450, 150 );&lt;br /&gt;      show();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   private void getTable()&lt;br /&gt;   {&lt;br /&gt;      Statement statement;&lt;br /&gt;      ResultSet resultSet;&lt;br /&gt;      &lt;br /&gt;      try {&lt;br /&gt;  String query = "SELECT * FROM Table1";&lt;br /&gt;&lt;br /&gt;  statement = con.createStatement();&lt;br /&gt;  resultSet = statement.executeQuery( query );&lt;br /&gt;  displayResultSet( resultSet );&lt;br /&gt;  statement.close();&lt;br /&gt;      }&lt;br /&gt;      catch ( SQLException sqlex ) {&lt;br /&gt;  sqlex.printStackTrace();&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   private void displayResultSet( ResultSet rs )&lt;br /&gt;      throws SQLException&lt;br /&gt;   {&lt;br /&gt;      // position to first record&lt;br /&gt;      boolean moreRecords = rs.next();  &lt;br /&gt;&lt;br /&gt;      // If there are no records, display a message&lt;br /&gt;      if ( ! moreRecords ) {&lt;br /&gt;  JOptionPane.showMessageDialog( this, &lt;br /&gt;     "ResultSet contained no records" );&lt;br /&gt;  setTitle( "No records to display" );&lt;br /&gt;  return;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      setTitle( "Authors table from Books" );&lt;br /&gt;&lt;br /&gt;      Vector columnHeads = new Vector();&lt;br /&gt;      Vector rows = new Vector();&lt;br /&gt;&lt;br /&gt;      try {&lt;br /&gt;  // get column heads&lt;br /&gt;  ResultSetMetaData rsmd = rs.getMetaData();&lt;br /&gt;      &lt;br /&gt;  for ( int i = 1; i &lt;= rsmd.getColumnCount(); ++i ) &lt;br /&gt;     columnHeads.addElement( rsmd.getColumnName( i ) );&lt;br /&gt;&lt;br /&gt;  // get row data&lt;br /&gt;  do {&lt;br /&gt;     rows.addElement( getNextRow( rs, rsmd ) ); &lt;br /&gt;  } while ( rs.next() );&lt;br /&gt;&lt;br /&gt;  // display table with ResultSet contents&lt;br /&gt;  table = new JTable(rows, columnHeads);&lt;br /&gt;  JScrollPane scroller = new JScrollPane( table );&lt;br /&gt; scroller.setBounds(50,150,430,100);&lt;br /&gt; pane.add(scroller);&lt;br /&gt; //getContentPane().add(scroller, BorderLayout.CENTER );&lt;br /&gt;  validate();&lt;br /&gt;      }&lt;br /&gt;      catch ( SQLException sqlex ) {&lt;br /&gt;  sqlex.printStackTrace();&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   private Vector getNextRow( ResultSet rs, &lt;br /&gt;         ResultSetMetaData rsmd )&lt;br /&gt;       throws SQLException&lt;br /&gt;   {&lt;br /&gt;      Vector currentRow = new Vector();&lt;br /&gt;      &lt;br /&gt;      for ( int i = 1; i &lt;= rsmd.getColumnCount(); ++i )&lt;br /&gt;  switch( rsmd.getColumnType( i ) ) {&lt;br /&gt;     case Types.VARCHAR:&lt;br /&gt;    currentRow.addElement( rs.getString( i ) );&lt;br /&gt;        break;&lt;br /&gt;     case Types.INTEGER:&lt;br /&gt;    currentRow.addElement( &lt;br /&gt;       new Long( rs.getLong( i ) ) );&lt;br /&gt;        break;&lt;br /&gt;     default: &lt;br /&gt;        System.out.println( "Type was: " + &lt;br /&gt;    rsmd.getColumnTypeName( i ) );&lt;br /&gt;  }&lt;br /&gt;      &lt;br /&gt;      return currentRow;&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-912927383974760276?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/912927383974760276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=912927383974760276' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/912927383974760276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/912927383974760276'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/booksale.html' title='BookSale'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-1828505236657181353</id><published>2007-04-16T18:06:00.000-07:00</published><updated>2007-04-16T18:07:11.158-07:00</updated><title type='text'>BirthDay</title><content type='html'>import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;import java.text.*;&lt;br /&gt;import java.text.DateFormatSymbols;&lt;br /&gt;import java.util.Calendar;&lt;br /&gt;&lt;br /&gt; public class BDay extends JFrame{&lt;br /&gt;  int row,col;&lt;br /&gt;  Container pane;&lt;br /&gt;  JTextArea textArea;&lt;br /&gt;  String output=" ",inputbd,Name;&lt;br /&gt;  String fdt="MM/dd/yyyy";&lt;br /&gt;  public static void main(String[] args){&lt;br /&gt;    BDay brtdy=new BDay();&lt;br /&gt;    brtdy.setBounds(100,100,350,250);&lt;br /&gt;    brtdy.setVisible(true);&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt; public BDay(){&lt;br /&gt;   super("HAPPY BIRTHDAY");&lt;br /&gt;   pane=getContentPane();&lt;br /&gt;   pane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));&lt;br /&gt;&lt;br /&gt;   textArea=new JTextArea(row,col);&lt;br /&gt;   addWindowListener(new WindowHandler());&lt;br /&gt; input();&lt;br /&gt;        textArea.setText(output);&lt;br /&gt;        pane.add(textArea);&lt;br /&gt;   pane.add(new TopPanel(),BorderLayout.NORTH);&lt;br /&gt;   pane.add(new BottomPanel(),BorderLayout.SOUTH);&lt;br /&gt;  }&lt;br /&gt;  void input(){&lt;br /&gt;    String dformat,dform;&lt;br /&gt;    int age;&lt;br /&gt;      Name=JOptionPane.showInputDialog("Enter Name:");&lt;br /&gt;      inputbd = JOptionPane.showInputDialog("Enter Date Of Birth in this form &lt;MM/DD/YYYY&gt;"+"\n"+"Example:\n 01/25/1940");&lt;br /&gt; try{&lt;br /&gt; SimpleDateFormat df= new SimpleDateFormat(fdt);&lt;br /&gt;  df.setLenient(false);&lt;br /&gt; java.util.Date d = df.parse(inputbd);&lt;br /&gt; Calendar dateofbirth = Calendar.getInstance();&lt;br /&gt;  dateofbirth.setTime(d);&lt;br /&gt; Calendar today = Calendar.getInstance();&lt;br /&gt; age = today.get(Calendar.YEAR) - dateofbirth.get(Calendar.YEAR);&lt;br /&gt;  dformat = " MMMM, dd,EEEE--yyyy";&lt;br /&gt;         dform="MM,dd,yyyy";&lt;br /&gt; SimpleDateFormat sdf = new SimpleDateFormat(dformat);&lt;br /&gt; SimpleDateFormat sdf2 = new SimpleDateFormat(dform);&lt;br /&gt;        output +="Name:"+ Name + "\n\n"; &lt;br /&gt;        output +="Date of Birth:"+sdf2.format(dateofbirth.getTime())+"\n";&lt;br /&gt;        output+="You were born:" + " " + sdf.format(dateofbirth.getTime())+ "\n\n";&lt;br /&gt; dateofbirth.set(Calendar.YEAR,2002);&lt;br /&gt;      output +="You are"+" "+age+" "+"years old this year:"+" "+sdf.format(dateofbirth.getTime());&lt;br /&gt; }&lt;br /&gt;   catch(ParseException e){&lt;br /&gt;&lt;br /&gt; JOptionPane.showMessageDialog(null,"Date is invalid ","Try another",JOptionPane.ERROR_MESSAGE);&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;    }&lt;br /&gt;  &lt;br /&gt;  class WindowHandler extends WindowAdapter{&lt;br /&gt;   public void windowClosing(WindowEvent e){&lt;br /&gt;     System.exit(0);&lt;br /&gt;              }&lt;br /&gt;         }&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-1828505236657181353?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/1828505236657181353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=1828505236657181353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1828505236657181353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1828505236657181353'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/birthday.html' title='BirthDay'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-6510825362599143097</id><published>2007-04-16T18:05:00.000-07:00</published><updated>2007-04-16T18:06:17.522-07:00</updated><title type='text'>BankServer</title><content type='html'>import java.sql.*;&lt;br /&gt;import java.sql.Date.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.print.*; &lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.util.Calendar.*;&lt;br /&gt;import java.util.Date.*;&lt;br /&gt;import java.text.*; &lt;br /&gt;import java.net.*;  &lt;br /&gt;&lt;br /&gt;class BankServer extends JFrame {&lt;br /&gt; private  JTabbedPane tabbedPane;&lt;br /&gt; private  JPanel  panel1;&lt;br /&gt; private  JPanel  panel2;&lt;br /&gt; private  JPanel  panel3;&lt;br /&gt; private JButton addbutton;&lt;br /&gt;    private JTextField field,field2,fie1,fie2,fie3,fiee1,fiee2,fiee3;&lt;br /&gt; private String amm="";&lt;br /&gt;                 ObjectOutputStream output;&lt;br /&gt;   ObjectInputStream input;&lt;br /&gt;   private JTextArea display;&lt;br /&gt;        private int amountt;&lt;br /&gt;&lt;br /&gt; public BankServer()&lt;br /&gt; {&lt;br /&gt;  setTitle( "Banking Program" );&lt;br /&gt;  setSize( 400, 300 );&lt;br /&gt;  setBackground( Color.gray );&lt;br /&gt;&lt;br /&gt;  JPanel topPanel = new JPanel();&lt;br /&gt;  display = new JTextArea();&lt;br /&gt;       field = new JTextField();&lt;br /&gt;  field2 = new JTextField();&lt;br /&gt;  fie1 = new JTextField();&lt;br /&gt;  fie2 = new JTextField();&lt;br /&gt;  topPanel.setLayout( new BorderLayout() );&lt;br /&gt;  getContentPane().add( topPanel );&lt;br /&gt;  createPage1();&lt;br /&gt;  createPage2();&lt;br /&gt;  createPage3();&lt;br /&gt;&lt;br /&gt;  // Create a tabbed pane&lt;br /&gt;  tabbedPane = new JTabbedPane();&lt;br /&gt;  tabbedPane.addTab( "Add Client", panel1 );&lt;br /&gt;  tabbedPane.addTab( "With Draw", panel2 );&lt;br /&gt;  tabbedPane.addTab( "Deposit", panel3 );&lt;br /&gt;  topPanel.add( tabbedPane, BorderLayout.CENTER );&lt;br /&gt;   &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;public void runServer(){&lt;br /&gt; ServerSocket server;&lt;br /&gt;  Socket connection;&lt;br /&gt;  int counter = 1;&lt;br /&gt;    try{ server = new ServerSocket(5000,100);&lt;br /&gt;    while(true){&lt;br /&gt;    display.setText("Waiting for connection\n");&lt;br /&gt;    connection = server.accept();&lt;br /&gt;    display.append("Connection"+ counter + " recieved from: " + connection.getInetAddress().getHostName());&lt;br /&gt;    output = new ObjectOutputStream(connection.getOutputStream());&lt;br /&gt;    output.flush();&lt;br /&gt;   input = new ObjectInputStream(connection.getInputStream());&lt;br /&gt;   display.append("\n Got I/O stream\n");&lt;br /&gt;   String message ="";// "SERVER&gt;&gt; Connection Succesfull";&lt;br /&gt;     do{&lt;br /&gt;      try {&lt;br /&gt;&lt;br /&gt;     String getrequest=(String) input.readObject();&lt;br /&gt; if(getrequest.equals("add")){&lt;br /&gt;    String oktoadd= "oktoadd";&lt;br /&gt;  output.writeObject(oktoadd);&lt;br /&gt;  //field.setText((String) input.readObject());&lt;br /&gt;                //field2.setText((String)input.readObject());&lt;br /&gt;   &lt;br /&gt;         field.setText((String) input.readObject());&lt;br /&gt;         field2.setText((String)input.readObject());&lt;br /&gt;         String okk=(String)input.readObject();&lt;br /&gt;         if(okk.equals("ok")){  &lt;br /&gt;  try {&lt;br /&gt;             Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");&lt;br /&gt;              String url = "jdbc:odbc:Bank";&lt;br /&gt;              Connection con = DriverManager.getConnection(url,"awing","awing");&lt;br /&gt;              Statement st = con.createStatement();&lt;br /&gt; &lt;br /&gt;     st.executeUpdate("INSERT INTO ClientTable( Client_ID , Name) "+ &lt;br /&gt;        " VALUES ( '" + field.getText()+"','" + field2.getText() + "') "); &lt;br /&gt;                    con.close();&lt;br /&gt;               JOptionPane.showMessageDialog(null,"Enroll is Succesfull");     &lt;br /&gt;        field.setText("");    &lt;br /&gt;        field2.setText("");    &lt;br /&gt;      } catch (java.lang.Exception ex){&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"Add is not Succesfull"); &lt;br /&gt;                     field.setText("");    &lt;br /&gt;       field2.setText(""); &lt;br /&gt;   String eror="error";&lt;br /&gt;   //output.writeObject(eror);&lt;br /&gt;   senderror(eror);&lt;br /&gt;                 }      &lt;br /&gt;                   }//end if&lt;br /&gt;     } //end if&lt;br /&gt;&lt;br /&gt; if(getrequest.equals("withdraw")){&lt;br /&gt;  String oktowithdraw= "oktowithdraw";&lt;br /&gt; output.writeObject(oktowithdraw);&lt;br /&gt;       fie1.setText((String) input.readObject());&lt;br /&gt;       String mewith = fie1.getText(),oo="ok";&lt;br /&gt; if(oo.equals("ok")){&lt;br /&gt; try {&lt;br /&gt;            Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");&lt;br /&gt;            String url = "jdbc:odbc:Bank";&lt;br /&gt;            Connection con = DriverManager.getConnection(url,"awing","awing");&lt;br /&gt;            Statement st = con.createStatement();&lt;br /&gt;    String query1= "SELECT * FROM ClientTable WHERE Client_ID='"+fie1.getText()+"' ";&lt;br /&gt;                 ResultSet rs1 = st.executeQuery(query1);&lt;br /&gt;                     rs1.next();&lt;br /&gt;&lt;br /&gt;                       fie2.setText(rs1.getString(2));&lt;br /&gt;   String name = fie2.getText();&lt;br /&gt;          //output.writeObject(name);&lt;br /&gt;   sendData(name);&lt;br /&gt; } catch (java.lang.Exception ex)&lt;br /&gt;                {&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"invalid Client ID or None in database");  &lt;br /&gt;                }   &lt;br /&gt; }//end if sa withdraw....&lt;br /&gt;        &lt;br /&gt;       //fie2.setText(&lt;br /&gt;  //String okk=(String)input.readObject();&lt;br /&gt;       &lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;        }&lt;br /&gt;      catch(ClassNotFoundException cnfex){&lt;br /&gt;      display.append("\nUnknown object type received");&lt;br /&gt; }&lt;br /&gt;         }while(!message.equals("CLIENT&gt;&gt;&gt; TERMINATE"));&lt;br /&gt;        display.append("\n User terminated connection");&lt;br /&gt; //enter.setEnabled(false);&lt;br /&gt; output.close();&lt;br /&gt; input.close();&lt;br /&gt;              connection.close();&lt;br /&gt;        ++counter; &lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;   catch(IOException io){&lt;br /&gt;      io.printStackTrace();&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt; public void createPage1() {&lt;br /&gt;  panel1 = new JPanel();&lt;br /&gt;  panel1.setLayout( null );&lt;br /&gt;&lt;br /&gt;  JLabel label1 = new JLabel( "Client ID:" );&lt;br /&gt;  label1.setBounds( 10, 15, 150, 20 );&lt;br /&gt;  panel1.add( label1 );&lt;br /&gt;&lt;br /&gt;  //field = new JTextField();&lt;br /&gt;  field.setBounds( 60, 15, 80, 20 );&lt;br /&gt;  panel1.add( field );&lt;br /&gt;&lt;br /&gt;  JLabel label2 = new JLabel( "Name:" );&lt;br /&gt;  label2.setBounds( 10, 45, 150, 20 );&lt;br /&gt;  panel1.add( label2 );&lt;br /&gt;&lt;br /&gt;  //field2 = new JTextField();&lt;br /&gt;  field2.setBounds( 60, 45, 150, 20 );&lt;br /&gt;  panel1.add( field2 );&lt;br /&gt;  addbutton = new JButton("Add");&lt;br /&gt;  display.setBounds(50, 150, 230, 75 );&lt;br /&gt;  display.setEditable(false);&lt;br /&gt;     panel1.add(display);&lt;br /&gt;                addbutton.setBounds(100, 100, 90, 20 );&lt;br /&gt;    addbutton.addActionListener( new ActionListener() {&lt;br /&gt;      public void actionPerformed(ActionEvent e) {&lt;br /&gt;    try {&lt;br /&gt;             Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");&lt;br /&gt;              String url = "jdbc:odbc:Bank";&lt;br /&gt;              Connection con = DriverManager.getConnection(url,"awing","awing");&lt;br /&gt;              Statement st = con.createStatement();&lt;br /&gt; &lt;br /&gt;     st.executeUpdate("INSERT INTO ClientTable( Client_ID , Name) "+ &lt;br /&gt;        " VALUES ( '" + field.getText()+"','" + field2.getText() + "') "); &lt;br /&gt;                    con.close();&lt;br /&gt;               //JOptionPane.showMessageDialog(null,"Enroll is Succesfull");     &lt;br /&gt;        field.setText("");    &lt;br /&gt;        field2.setText("");    &lt;br /&gt;      } catch (java.lang.Exception ex){&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"Add is not Succesfull");&lt;br /&gt;    &lt;br /&gt;                     field.setText("");    &lt;br /&gt;       field2.setText(""); &lt;br /&gt;                 }      &lt;br /&gt;               }&lt;br /&gt;         });&lt;br /&gt;  panel1.add( addbutton);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt; public void createPage2() {&lt;br /&gt;  panel2 = new JPanel();&lt;br /&gt;  panel2.setLayout( null);&lt;br /&gt;  panel2.setBackground( Color.blue );&lt;br /&gt;  JLabel lab1 = new JLabel( "Client ID:" );&lt;br /&gt;  lab1.setBounds( 10, 15, 150, 20 );&lt;br /&gt;  panel2.add( lab1 );&lt;br /&gt;&lt;br /&gt;  //fie1 = new JTextField();&lt;br /&gt;  fie1.setBounds( 60, 15, 80, 20 );&lt;br /&gt;  panel2.add( fie1 );&lt;br /&gt;&lt;br /&gt;  JLabel lab2 = new JLabel( "Name:" );&lt;br /&gt;  lab2.setBounds( 10, 45, 150, 20 );&lt;br /&gt;  panel2.add( lab2 );&lt;br /&gt;&lt;br /&gt;  //fie2 = new JTextField();&lt;br /&gt;  fie2.setBounds( 60, 45, 150, 20 );&lt;br /&gt;  fie2.setEditable(false);&lt;br /&gt;  panel2.add( fie2 );&lt;br /&gt;                JLabel amount = new JLabel("Amount:");&lt;br /&gt;          amount.setBounds( 10, 70, 150, 20 );&lt;br /&gt;                panel2.add(amount);&lt;br /&gt;                fie3 = new JTextField();&lt;br /&gt;  fie3.setBounds( 60, 70, 150, 20 );&lt;br /&gt;                &lt;br /&gt;                panel2.add(fie3);&lt;br /&gt;             fie1.addActionListener( new ActionListener() {&lt;br /&gt;      public void actionPerformed(ActionEvent e) {&lt;br /&gt;    try {&lt;br /&gt;            Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");&lt;br /&gt;            String url = "jdbc:odbc:Bank";&lt;br /&gt;            Connection con = DriverManager.getConnection(url,"awing","awing");&lt;br /&gt;            Statement st = con.createStatement();&lt;br /&gt;    String query1= "SELECT * FROM ClientTable WHERE Client_ID='"+fie1.getText()+"' ";&lt;br /&gt;                 ResultSet rs1 = st.executeQuery(query1);&lt;br /&gt;                     rs1.next();&lt;br /&gt;&lt;br /&gt;                       fie2.setText(rs1.getString(2));&lt;br /&gt;       &lt;br /&gt; } catch (java.lang.Exception ex)&lt;br /&gt;                {&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"invalid Client ID or None in database");  &lt;br /&gt;                }   &lt;br /&gt;           }&lt;br /&gt;       });&lt;br /&gt;  JButton okbutton = new JButton("with draw");&lt;br /&gt;                okbutton.setBounds(100, 100, 90, 20 );&lt;br /&gt; &lt;br /&gt;   okbutton.addActionListener( new ActionListener() {&lt;br /&gt;      public void actionPerformed(ActionEvent e) {&lt;br /&gt;                amm = fie3.getText();&lt;br /&gt;                amountt = Integer.parseInt(amm);&lt;br /&gt;    try {&lt;br /&gt;            Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");&lt;br /&gt;            String url = "jdbc:odbc:Bank";&lt;br /&gt;            Connection con = DriverManager.getConnection(url,"awing","awing");&lt;br /&gt;            Statement st = con.createStatement();&lt;br /&gt;          st.executeUpdate("INSERT INTO ClientWithdraw( Client_ID , Amount) "+ &lt;br /&gt;        " VALUES ( '" + fie1.getText()+"','" + amountt + "') "); &lt;br /&gt;         con.close();&lt;br /&gt; JOptionPane.showMessageDialog(null,"WithDraw is Succesfull");  &lt;br /&gt;&lt;br /&gt;    } catch (java.lang.Exception ex)&lt;br /&gt;                {&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"Add is not Succesfull");  &lt;br /&gt;                }      &lt;br /&gt;           }&lt;br /&gt;       });&lt;br /&gt;  panel2.add( okbutton);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;private void senderror( String s ) {&lt;br /&gt;  try {&lt;br /&gt;   //message = s;&lt;br /&gt;   output.writeObject ( s );&lt;br /&gt;   output.flush();&lt;br /&gt;   //display.append ( "\nCLIENT&gt;&gt;&gt; " + s ); &lt;br /&gt;  }&lt;br /&gt;  catch ( IOException cnfe ) {&lt;br /&gt;   display.append ( "\nError writing object" );&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;private void sendData( String s ) {&lt;br /&gt;  try {&lt;br /&gt;   //message = s;&lt;br /&gt;   output.writeObject ( s );&lt;br /&gt;   output.flush();&lt;br /&gt;   //display.append ( "\nCLIENT&gt;&gt;&gt; " + s ); &lt;br /&gt;  }&lt;br /&gt;  catch ( IOException cnfe ) {&lt;br /&gt;   display.append ( "\nError writing object" );&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void createPage3()&lt;br /&gt; {&lt;br /&gt;  panel3 = new JPanel();&lt;br /&gt;  panel3.setLayout( null );&lt;br /&gt;                panel3.setBackground( Color.orange );&lt;br /&gt;&lt;br /&gt;  JLabel labb1 = new JLabel( "Client ID:" );&lt;br /&gt;  labb1.setBounds( 10, 15, 150, 20 );&lt;br /&gt;  panel3.add( labb1 );&lt;br /&gt;&lt;br /&gt;  JTextField fiee1 = new JTextField();&lt;br /&gt;  fiee1.setBounds( 60, 15, 80, 20 );&lt;br /&gt;  panel3.add( fiee1 );&lt;br /&gt;&lt;br /&gt;  JLabel labb2 = new JLabel( "Name:" );&lt;br /&gt;  labb2.setBounds( 10, 45, 150, 20 );&lt;br /&gt;  panel3.add( labb2 );&lt;br /&gt;&lt;br /&gt;  JTextField fiee2 = new JTextField();&lt;br /&gt;  fiee2.setBounds( 60, 45, 150, 20 );&lt;br /&gt;  fiee2.setEditable(false);&lt;br /&gt;  panel3.add( fiee2 );&lt;br /&gt;  JLabel amoun = new JLabel("Amount:");&lt;br /&gt;          amoun.setBounds( 10, 70, 150, 20 );&lt;br /&gt;                panel3.add(amoun);&lt;br /&gt;                fiee3 = new JTextField();&lt;br /&gt;  fiee3.setBounds( 60, 70, 150, 20 );&lt;br /&gt;                panel3.add(fiee3);&lt;br /&gt;  JButton okkbutton = new JButton("deposit");&lt;br /&gt;                okkbutton.setBounds(100, 100, 90, 20 );&lt;br /&gt;&lt;br /&gt;  panel3.add( okkbutton);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;   public static void main( String args[] )&lt;br /&gt; {&lt;br /&gt;  // Create an instance of the test application&lt;br /&gt;  BankServer mainFrame = new BankServer();&lt;br /&gt;  mainFrame.setVisible( true );&lt;br /&gt;  mainFrame.runServer();&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-6510825362599143097?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/6510825362599143097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=6510825362599143097' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/6510825362599143097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/6510825362599143097'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/bankserver.html' title='BankServer'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8650962088748000179</id><published>2007-04-16T18:02:00.000-07:00</published><updated>2007-04-16T18:05:46.075-07:00</updated><title type='text'>Bank</title><content type='html'>import java.sql.Date.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.print.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.util.Calendar.*;&lt;br /&gt;import java.util.Date.*;&lt;br /&gt;import java.text.*;&lt;br /&gt;import java.net.*;&lt;br /&gt;&lt;br /&gt;class Bank extends    JFrame {&lt;br /&gt;    private        JTabbedPane tabbedPane;&lt;br /&gt;    private        JPanel        panel1;&lt;br /&gt;    private        JPanel        panel2;&lt;br /&gt;    private        JPanel        panel3;&lt;br /&gt;    private JButton addbutton;&lt;br /&gt;       private JTextField field,field2,fie1,fie2,fie3,fiee1,fiee2,fiee3;&lt;br /&gt;    private String amm="";&lt;br /&gt;        private int amountt;&lt;br /&gt;    JTextArea display;&lt;br /&gt;    ObjectOutputStream output;&lt;br /&gt;    ObjectInputStream input;&lt;br /&gt;    Socket client;&lt;br /&gt;&lt;br /&gt;    public Bank()&lt;br /&gt;    {&lt;br /&gt;        setTitle( "Banking Program" );&lt;br /&gt;        setSize( 400, 300 );&lt;br /&gt;        setBackground( Color.gray );&lt;br /&gt;       &lt;br /&gt;&lt;br /&gt;        JPanel topPanel = new JPanel();&lt;br /&gt;        topPanel.setLayout( new BorderLayout() );&lt;br /&gt;        getContentPane().add( topPanel );&lt;br /&gt;        createPage1();&lt;br /&gt;        createPage2();&lt;br /&gt;        createPage3();&lt;br /&gt;&lt;br /&gt;        // Create a tabbed pane&lt;br /&gt;        tabbedPane = new JTabbedPane();&lt;br /&gt;        tabbedPane.addTab( "Add Client", panel1 );&lt;br /&gt;        tabbedPane.addTab( "With Draw", panel2 );&lt;br /&gt;        tabbedPane.addTab( "Deposit", panel3 );&lt;br /&gt;        topPanel.add( tabbedPane, BorderLayout.CENTER );&lt;br /&gt;                               &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void createPage1() {&lt;br /&gt;        panel1 = new JPanel();&lt;br /&gt;        panel1.setLayout( null );&lt;br /&gt;&lt;br /&gt;        JLabel label1 = new JLabel( "Client ID:" );&lt;br /&gt;        label1.setBounds( 10, 15, 150, 20 );&lt;br /&gt;        panel1.add( label1 );&lt;br /&gt;&lt;br /&gt;        field = new JTextField();&lt;br /&gt;        field.setBounds( 60, 15, 80, 20 );&lt;br /&gt;        panel1.add( field );&lt;br /&gt;&lt;br /&gt;        JLabel label2 = new JLabel( "Name:" );&lt;br /&gt;        label2.setBounds( 10, 45, 150, 20 );&lt;br /&gt;        panel1.add( label2 );&lt;br /&gt;&lt;br /&gt;        field2 = new JTextField();&lt;br /&gt;        field2.setBounds( 60, 45, 150, 20 );&lt;br /&gt;        panel1.add( field2 );&lt;br /&gt;        addbutton = new JButton("Add");&lt;br /&gt;                addbutton.setBounds(100, 100, 90, 20 );&lt;br /&gt;       addbutton.addActionListener( new ActionListener() {&lt;br /&gt;            public void actionPerformed(ActionEvent e) {&lt;br /&gt;                     &lt;br /&gt;    try {&lt;br /&gt; client = new Socket ( InetAddress.getByName ( "202.134.238.3" ), 10000 );&lt;br /&gt;        output = new ObjectOutputStream ( client.getOutputStream() );&lt;br /&gt;            output.flush();&lt;br /&gt;                               String mess =field.getText();&lt;br /&gt;    String mess1 =field2.getText();//kini sad....&lt;br /&gt;    field.setCaretPosition ( field.getText().length() );&lt;br /&gt;                          output.writeObject(mess);&lt;br /&gt;          output.writeObject(mess1);//kini&lt;br /&gt;    field2.setCaretPosition ( field2.getText().length() );&lt;br /&gt;        output.flush();&lt;br /&gt;                       // field.getText()+"','" + field2.getText()&lt;br /&gt;             &lt;br /&gt;                 field.setText("");   &lt;br /&gt;                 field2.setText("");&lt;br /&gt;   &lt;br /&gt;            } catch (java.lang.Exception ex){&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"Add is not Succesfull");&lt;br /&gt;                     field.setText("");   &lt;br /&gt;             field2.setText("");&lt;br /&gt;                    }     &lt;br /&gt;                  }&lt;br /&gt;               });&lt;br /&gt;        panel1.add( addbutton);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    public void createPage2() {&lt;br /&gt;        panel2 = new JPanel();&lt;br /&gt;        panel2.setLayout( null);&lt;br /&gt;        panel2.setBackground( Color.blue );&lt;br /&gt;        JLabel lab1 = new JLabel( "Client ID:" );&lt;br /&gt;        lab1.setBounds( 10, 15, 150, 20 );&lt;br /&gt;        panel2.add( lab1 );&lt;br /&gt;&lt;br /&gt;        fie1 = new JTextField();&lt;br /&gt;        fie1.setBounds( 60, 15, 80, 20 );&lt;br /&gt;        panel2.add( fie1 );&lt;br /&gt;&lt;br /&gt;        JLabel lab2 = new JLabel( "Name:" );&lt;br /&gt;        lab2.setBounds( 10, 45, 150, 20 );&lt;br /&gt;        panel2.add( lab2 );&lt;br /&gt;&lt;br /&gt;        fie2 = new JTextField();&lt;br /&gt;        fie2.setBounds( 60, 45, 150, 20 );&lt;br /&gt;        fie2.setEditable(false);&lt;br /&gt;        panel2.add( fie2 );&lt;br /&gt;                JLabel amount = new JLabel("Amount:");&lt;br /&gt;             amount.setBounds( 10, 70, 150, 20 );&lt;br /&gt;                panel2.add(amount);&lt;br /&gt;                fie3 = new JTextField();&lt;br /&gt;        fie3.setBounds( 60, 70, 150, 20 );&lt;br /&gt;               &lt;br /&gt;                panel2.add(fie3);&lt;br /&gt;             fie1.addActionListener( new ActionListener() {&lt;br /&gt;            public void actionPerformed(ActionEvent e) {&lt;br /&gt;          try {&lt;br /&gt;            Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");&lt;br /&gt;            String url = "jdbc:odbc:Bank";&lt;br /&gt;            Connection con = DriverManager.getConnection(url,"awing","awing");&lt;br /&gt;            Statement st = con.createStatement();&lt;br /&gt;          String query1= "SELECT * FROM ClientTable WHERE Client_ID='"+fie1.getText()+"' ";&lt;br /&gt;                 ResultSet rs1 = st.executeQuery(query1);&lt;br /&gt;                     rs1.next();&lt;br /&gt;&lt;br /&gt;                       fie2.setText(rs1.getString(2));&lt;br /&gt;      &lt;br /&gt;    } catch (java.lang.Exception ex)&lt;br /&gt;                {&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"invalid Client ID or None in database"); &lt;br /&gt;                }  &lt;br /&gt;           }&lt;br /&gt;       });&lt;br /&gt;        JButton okbutton = new JButton("with draw");&lt;br /&gt;                okbutton.setBounds(100, 100, 90, 20 );&lt;br /&gt;   &lt;br /&gt;        &lt;br /&gt;      okbutton.addActionListener( new ActionListener() {&lt;br /&gt;            public void actionPerformed(ActionEvent e) {&lt;br /&gt;                                  &lt;br /&gt;                amm = fie3.getText();&lt;br /&gt;                amountt = Integer.parseInt(amm);&lt;br /&gt;          try {&lt;br /&gt;            &lt;br /&gt;&lt;br /&gt;    } catch (java.lang.Exception ex)&lt;br /&gt;                {&lt;br /&gt;                //ex.printStackTrace();&lt;br /&gt;                JOptionPane.showMessageDialog(null,"Add is not Succesfull"); &lt;br /&gt;                }     &lt;br /&gt;           }&lt;br /&gt;       });&lt;br /&gt;        panel2.add( okbutton);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void createPage3()&lt;br /&gt;    {&lt;br /&gt;        panel3 = new JPanel();&lt;br /&gt;        panel3.setLayout( null );&lt;br /&gt;                panel3.setBackground( Color.orange );&lt;br /&gt;&lt;br /&gt;        JLabel labb1 = new JLabel( "Client ID:" );&lt;br /&gt;        labb1.setBounds( 10, 15, 150, 20 );&lt;br /&gt;        panel3.add( labb1 );&lt;br /&gt;&lt;br /&gt;        JTextField fiee1 = new JTextField();&lt;br /&gt;        fiee1.setBounds( 60, 15, 80, 20 );&lt;br /&gt;        panel3.add( fiee1 );&lt;br /&gt;&lt;br /&gt;        JLabel labb2 = new JLabel( "Name:" );&lt;br /&gt;        labb2.setBounds( 10, 45, 150, 20 );&lt;br /&gt;        panel3.add( labb2 );&lt;br /&gt;&lt;br /&gt;        JTextField fiee2 = new JTextField();&lt;br /&gt;        fiee2.setBounds( 60, 45, 150, 20 );&lt;br /&gt;        fiee2.setEditable(false);&lt;br /&gt;        panel3.add( fiee2 );&lt;br /&gt;        JLabel amoun = new JLabel("Amount:");&lt;br /&gt;             amoun.setBounds( 10, 70, 150, 20 );&lt;br /&gt;                panel3.add(amoun);&lt;br /&gt;                fiee3 = new JTextField();&lt;br /&gt;        fiee3.setBounds( 60, 70, 150, 20 );&lt;br /&gt;                panel3.add(fiee3);&lt;br /&gt;        JButton okkbutton = new JButton("deposit");&lt;br /&gt;                okkbutton.setBounds(100, 100, 90, 20 );&lt;br /&gt;&lt;br /&gt;        panel3.add( okkbutton);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Main method to get things started&lt;br /&gt;    public static void main( String args[] )&lt;br /&gt;    {&lt;br /&gt;        // Create an instance of the test application&lt;br /&gt;        Bank mainFrame    = new Bank();&lt;br /&gt;        mainFrame.setVisible( true );&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/elements.length;i++){&gt;&lt;/elements.length;i++){&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8650962088748000179?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8650962088748000179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8650962088748000179' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8650962088748000179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8650962088748000179'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/bank.html' title='Bank'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8438850092390032739</id><published>2007-04-16T18:01:00.000-07:00</published><updated>2007-04-16T18:02:41.687-07:00</updated><title type='text'>Arc</title><content type='html'>/*&lt;br /&gt; * @(#)Arcs.java    1.19 01/12/03&lt;br /&gt; *&lt;br /&gt; * Copyright 2002 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt; * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;package java2d.demos.Arcs_Curves;&lt;br /&gt;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.geom.Ellipse2D;&lt;br /&gt;import java.awt.geom.Arc2D;&lt;br /&gt;import java.awt.geom.AffineTransform;&lt;br /&gt;import java2d.AnimatingSurface;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Arc2D Open, Chord &amp; Pie arcs; Animated Pie Arc.&lt;br /&gt; */&lt;br /&gt;public class Arcs extends AnimatingSurface {&lt;br /&gt;&lt;br /&gt;    private static String types[] = {"Arc2D.OPEN","Arc2D.CHORD","Arc2D.PIE"};&lt;br /&gt;    private static final int CLOSE = 0;&lt;br /&gt;    private static final int OPEN = 1;&lt;br /&gt;    private static final int FORWARD = 0;&lt;br /&gt;    private static final int BACKWARD = 1;&lt;br /&gt;    private static final int DOWN = 2;&lt;br /&gt;    private static final int UP = 3;&lt;br /&gt;&lt;br /&gt;    private int aw, ah; // animated arc width &amp; height&lt;br /&gt;    private int x, y;&lt;br /&gt;    private int angleStart = 45;&lt;br /&gt;    private int angleExtent = 270;&lt;br /&gt;    private int mouth = CLOSE;&lt;br /&gt;    private int direction = FORWARD;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public Arcs() {&lt;br /&gt;        setBackground(Color.white);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public void reset(int w, int h) {&lt;br /&gt;        x = 0; y = 0;&lt;br /&gt;        aw = w/12; ah = h/12;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public void step(int w, int h) {&lt;br /&gt;      // Compute direction&lt;br /&gt;        if (x+aw &gt;= w-5 &amp;&amp;amp; direction == FORWARD)&lt;br /&gt;            direction = DOWN;&lt;br /&gt;        if (y+ah &gt;= h-5 &amp;&amp;amp; direction == DOWN)&lt;br /&gt;            direction = BACKWARD;&lt;br /&gt;        if (x-aw &lt;= 5 &amp;&amp;amp; direction == BACKWARD)&lt;br /&gt;            direction = UP;&lt;br /&gt;        if (y-ah &lt;= 5 &amp;&amp;amp; direction == UP)&lt;br /&gt;            direction = FORWARD;&lt;br /&gt;&lt;br /&gt;      // compute angle start &amp; extent&lt;br /&gt;        if (mouth == CLOSE) {&lt;br /&gt;            angleStart -= 5;&lt;br /&gt;            angleExtent += 10;&lt;br /&gt;        }&lt;br /&gt;        if (mouth == OPEN) {&lt;br /&gt;            angleStart += 5;&lt;br /&gt;            angleExtent -= 10;&lt;br /&gt;        }&lt;br /&gt;        if (direction == FORWARD) {&lt;br /&gt;            x += 5; y = 0;&lt;br /&gt;        }&lt;br /&gt;        if (direction == DOWN) {&lt;br /&gt;            x = w; y += 5;&lt;br /&gt;        }&lt;br /&gt;        if (direction == BACKWARD) {&lt;br /&gt;            x -= 5; y = h;&lt;br /&gt;        }&lt;br /&gt;        if (direction == UP) {&lt;br /&gt;            x = 0; y -= 5;&lt;br /&gt;        }&lt;br /&gt;        if (angleStart == 0)&lt;br /&gt;            mouth = OPEN;&lt;br /&gt;        if (angleStart &gt; 45)&lt;br /&gt;            mouth = CLOSE;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public void render(int w, int h, Graphics2D g2) {&lt;br /&gt;&lt;br /&gt;        g2.setStroke(new BasicStroke(5.0f));&lt;br /&gt;      // Draw Arcs&lt;br /&gt;        for (int i = 0; i &lt; types.length; i++) {&lt;br /&gt;            Arc2D arc = new Arc2D.Float(i);&lt;br /&gt;            arc.setFrame((i+1)*w*.2, (i+1)*h*.2, w*.17, h*.17);&lt;br /&gt;            arc.setAngleStart(45);&lt;br /&gt;            arc.setAngleExtent(270);&lt;br /&gt;            g2.setColor(Color.blue);&lt;br /&gt;            g2.draw(arc);&lt;br /&gt;            g2.setColor(Color.gray);&lt;br /&gt;            g2.fill(arc);&lt;br /&gt;            g2.setColor(Color.black);&lt;br /&gt;            g2.drawString(types[i], (int)((i+1)*w*.2), (int)((i+1)*h*.2-3));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;      // Draw Animated Pie Arc&lt;br /&gt;        Arc2D pieArc = new Arc2D.Float(Arc2D.PIE);&lt;br /&gt;        pieArc.setFrame(0, 0, aw, ah);&lt;br /&gt;        pieArc.setAngleStart(angleStart);&lt;br /&gt;        pieArc.setAngleExtent(angleExtent);&lt;br /&gt;        AffineTransform at = AffineTransform.getTranslateInstance(x, y);&lt;br /&gt;        switch (direction) {&lt;br /&gt;            case DOWN : at.rotate(Math.toRadians(90)); break;&lt;br /&gt;            case BACKWARD : at.rotate(Math.toRadians(180)); break;&lt;br /&gt;            case UP : at.rotate(Math.toRadians(270));&lt;br /&gt;        }&lt;br /&gt;        g2.setColor(Color.blue);&lt;br /&gt;        g2.fill(at.createTransformedShape(pieArc));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public static void main(String argv[]) {&lt;br /&gt;        createDemoFrame(new Arcs());&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8438850092390032739?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8438850092390032739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8438850092390032739' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8438850092390032739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8438850092390032739'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/arc.html' title='Arc'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-3851940904175016884</id><published>2007-04-13T22:35:00.001-07:00</published><updated>2007-04-13T22:35:36.570-07:00</updated><title type='text'>AquaMetalTheme</title><content type='html'>/*&lt;br /&gt; * @(#)AquaMetalTheme.java    1.6 01/12/03&lt;br /&gt; *&lt;br /&gt; * Copyright 2002 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt; * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import javax.swing.plaf.*;&lt;br /&gt;import javax.swing.plaf.metal.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * This class describes a theme using "blue-green" colors.&lt;br /&gt; *&lt;br /&gt; * @version 1.6 12/03/01&lt;br /&gt; * @author Steve Wilson&lt;br /&gt; */&lt;br /&gt;public class AquaMetalTheme extends DefaultMetalTheme {&lt;br /&gt;&lt;br /&gt;    public String getName() { return "Oxide"; }&lt;br /&gt;&lt;br /&gt;    private final ColorUIResource primary1 = new ColorUIResource(102, 153, 153);&lt;br /&gt;    private final ColorUIResource primary2 = new ColorUIResource(128, 192, 192);&lt;br /&gt;    private final ColorUIResource primary3 = new ColorUIResource(159, 235, 235);&lt;br /&gt;&lt;br /&gt;    protected ColorUIResource getPrimary1() { return primary1; }&lt;br /&gt;    protected ColorUIResource getPrimary2() { return primary2; }&lt;br /&gt;    protected ColorUIResource getPrimary3() { return primary3; }&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-3851940904175016884?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/3851940904175016884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=3851940904175016884' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3851940904175016884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3851940904175016884'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/aquametaltheme.html' title='AquaMetalTheme'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-2069719261098817723</id><published>2007-04-13T22:32:00.001-07:00</published><updated>2007-04-13T22:32:22.206-07:00</updated><title type='text'>AppletFrame</title><content type='html'>/*&lt;br /&gt; * @(#)AppletFrame.java    1.10 01/12/03&lt;br /&gt; *&lt;br /&gt; * Copyright 2002 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt; * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;import java.awt.Frame;&lt;br /&gt;import java.awt.Event;&lt;br /&gt;import java.awt.Dimension;&lt;br /&gt;import java.applet.Applet;&lt;br /&gt;import java.awt.AWTEvent;&lt;br /&gt;&lt;br /&gt;// Applet to Application Frame window&lt;br /&gt;class AppletFrame extends Frame&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    public static void startApplet(String className,&lt;br /&gt;                                   String title,&lt;br /&gt;                                   String args[])&lt;br /&gt;    {&lt;br /&gt;       // local variables&lt;br /&gt;       Applet a;&lt;br /&gt;       Dimension appletSize;&lt;br /&gt;&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;          // create an instance of your applet class&lt;br /&gt;          a = (Applet) Class.forName(className).newInstance();&lt;br /&gt;       }&lt;br /&gt;       catch (ClassNotFoundException e) { return; }&lt;br /&gt;       catch (InstantiationException e) { return; }&lt;br /&gt;       catch (IllegalAccessException e) { return; }&lt;br /&gt;&lt;br /&gt;       // initialize the applet&lt;br /&gt;       a.init();&lt;br /&gt;       a.start();&lt;br /&gt; &lt;br /&gt;       // create new application frame window&lt;br /&gt;       AppletFrame f = new AppletFrame(title);&lt;br /&gt; &lt;br /&gt;       // add applet to frame window&lt;br /&gt;       f.add("Center", a);&lt;br /&gt; &lt;br /&gt;       // resize frame window to fit applet&lt;br /&gt;       // assumes that the applet sets its own size&lt;br /&gt;       // otherwise, you should set a specific size here.&lt;br /&gt;       appletSize =  a.getSize();&lt;br /&gt;       f.pack();&lt;br /&gt;       f.setSize(appletSize); &lt;br /&gt;&lt;br /&gt;       // show the window&lt;br /&gt;       f.show();&lt;br /&gt; &lt;br /&gt;    }  // end startApplet()&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    // constructor needed to pass window title to class Frame&lt;br /&gt;    public AppletFrame(String name)&lt;br /&gt;    {&lt;br /&gt;       // call java.awt.Frame(String) constructor&lt;br /&gt;       super(name);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // needed to allow window close&lt;br /&gt;    public void processEvent(AWTEvent e)&lt;br /&gt;    {&lt;br /&gt;       // Window Destroy event&lt;br /&gt;       if (e.getID() == Event.WINDOW_DESTROY)&lt;br /&gt;       {&lt;br /&gt;          // exit the program&lt;br /&gt;          System.exit(0);&lt;br /&gt;       }   &lt;br /&gt;   }  // end handleEvent()&lt;br /&gt;&lt;br /&gt;}   // end class AppletFrame&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-2069719261098817723?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/2069719261098817723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=2069719261098817723' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2069719261098817723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2069719261098817723'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/appletframe.html' title='AppletFrame'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8506860673435567486</id><published>2007-04-13T22:31:00.001-07:00</published><updated>2007-04-13T22:31:27.659-07:00</updated><title type='text'>AddNumbers</title><content type='html'>import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class Add2numbers{&lt;br /&gt;&lt;br /&gt; public static void main(String[] args){&lt;br /&gt;   Add2numbers add=new Add2numbers();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt; public Add2numbers(){&lt;br /&gt;   String num1,num2,output="";&lt;br /&gt;   int no1,no2,sum=0;&lt;br /&gt;&lt;br /&gt;   num1=JOptionPane.showInputDialog(null,"Enter 1st to add","INPUT NO1",JOptionPane.QUESTION_MESSAGE);&lt;br /&gt;   num2=JOptionPane.showInputDialog(null,"Enter 2nd to add","INPUT NO2",JOptionPane.QUESTION_MESSAGE);&lt;br /&gt;&lt;br /&gt;  no1=Integer.parseInt(num1);&lt;br /&gt;  no2=Integer.parseInt(num2);&lt;br /&gt;&lt;br /&gt;  sum=no1+no2;&lt;br /&gt;&lt;br /&gt;  output+="first number entered is" + no1 +"\n";&lt;br /&gt;  output+="Second number entered is" + no2 +"\n";&lt;br /&gt;&lt;br /&gt; JOptionPane.showMessageDialog(null,output+no1+"+"+no2+"="+sum,"sum",JOptionPane.INFORMATION_MESSAGE);&lt;br /&gt;&lt;br /&gt; System.exit(0);&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8506860673435567486?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8506860673435567486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8506860673435567486' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8506860673435567486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8506860673435567486'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/addnumbers.html' title='AddNumbers'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-2384171207868753580</id><published>2007-04-13T22:28:00.001-07:00</published><updated>2007-04-13T22:28:34.258-07:00</updated><title type='text'>Action Button</title><content type='html'>public boolean action(Event evt, Object obj)&lt;br /&gt;{&lt;br /&gt;    boolean retval = false;            // assume not processed&lt;br /&gt;    if ("New".equals(obj))&lt;br /&gt;    {&lt;br /&gt;        if (validateFields())&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                CurrentOperator.insert(db);&lt;br /&gt;                readOperators();&lt;br /&gt;            }&lt;br /&gt;            catch(ComException e)&lt;br /&gt;            {&lt;br /&gt;                setStatus(e);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        retval = true;&lt;br /&gt;    }&lt;br /&gt;    else if ("Update".equals(obj))&lt;br /&gt;    {&lt;br /&gt;        if (validateFields())&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                CurrentOperator.update(db);&lt;br /&gt;                readOperators();&lt;br /&gt;            }&lt;br /&gt;            catch(Exception e)&lt;br /&gt;            {&lt;br /&gt;                setStatus("DB Error: " + e.getMessage());&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        retval = true;&lt;br /&gt;    }&lt;br /&gt;    return retval;&lt;br /&gt;}&lt;br /&gt;If the New button is pressed, the fields are validated and&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-2384171207868753580?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/2384171207868753580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=2384171207868753580' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2384171207868753580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2384171207868753580'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/action-button.html' title='Action Button'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4833568462380486704</id><published>2007-04-13T22:27:00.001-07:00</published><updated>2007-04-13T22:27:53.984-07:00</updated><title type='text'>Accounts Entry</title><content type='html'>import java.text.*;&lt;br /&gt;import javax.swing.text.MaskFormatter;&lt;br /&gt;import java.text.Format.*;&lt;br /&gt;import java.text.ParseException;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import javax.swing.border.BevelBorder;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;import java.util.Calendar;&lt;br /&gt;import java.text.DateFormatSymbols;&lt;br /&gt;import javax.swing.DefaultCellEditor;&lt;br /&gt;import javax.swing.JScrollPane;&lt;br /&gt;import javax.swing.JFrame;&lt;br /&gt;import javax.swing.SwingUtilities;&lt;br /&gt;import java.text.*;&lt;br /&gt;import javax.swing.text.MaskFormatter;&lt;br /&gt;import java.text.Format.*;&lt;br /&gt;import javax.swing.table.AbstractTableModel;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//CLASS OF frame 2 FOR STUDENT FILE&lt;br /&gt;&lt;br /&gt;    class AccountsEntry extends JFrame{&lt;br /&gt;    //ds&lt;br /&gt;    String output="";&lt;br /&gt;    int row=200, col=5;&lt;br /&gt;    private JLabel pic2, label, label1, label2, label3, label4,label5,label6,label7;&lt;br /&gt;    private JTextField field1, field2, field3, field4, field5, field6, field7;&lt;br /&gt;    private JTable inventTable;   &lt;br /&gt;    private JScrollPane inventScroll1;&lt;br /&gt;    JComboBox combo1, combo2, combo3;&lt;br /&gt;    private String gender[] = {"Male","Female"};&lt;br /&gt;    private String semester[] = {"First", "Second", "Summer"};&lt;br /&gt;    private String status[] = {"New", "Old/Active", "Returnee", "Transferee"};&lt;br /&gt;    private JRadioButton student,staff;&lt;br /&gt;    private ButtonGroup radioGroup;&lt;br /&gt;&lt;br /&gt;    JButton buttonadd;&lt;br /&gt;    JButton buttonsave;&lt;br /&gt;    JButton buttonsearch;&lt;br /&gt;    JButton buttonprint;&lt;br /&gt;    JButton buttonclose;&lt;br /&gt;    JButton buttondelete;&lt;br /&gt;    JRadioButton buttonstudent;&lt;br /&gt;    JRadioButton buttonstaff;&lt;br /&gt;     ButtonGroup radiogroup;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;    public AccountsEntry()&lt;br /&gt;        {&lt;br /&gt;    setTitle("ACCOUNTS FORM");&lt;br /&gt;    Container pane = getContentPane();&lt;br /&gt;    JTextArea textarea;&lt;br /&gt;   &lt;br /&gt;    pane.setBackground(Color.black);&lt;br /&gt;    pane.setLayout(null);&lt;br /&gt;    Font font = new Font("Teletype",Font.PLAIN,18);&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;    JLabel label = new JLabel("CJC Center for Instructional and Mimeographing Services"+"\n"+" INVENTORY SYSTEM",JLabel.CENTER);&lt;br /&gt;    label.setFont(font);&lt;br /&gt;    label.setBounds(0,0,790,60);&lt;br /&gt;    label.setForeground(Color.yellow);&lt;br /&gt;    label.setBackground(Color.blue);&lt;br /&gt;    label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));   &lt;br /&gt;    pane.add(label,BorderLayout.CENTER);&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;//for pictures or logo&lt;br /&gt;    Icon logo = new ImageIcon("logo2.gif");&lt;br /&gt;    pic2 = new JLabel(logo);&lt;br /&gt;    pic2.setBounds(0,0,60,60);&lt;br /&gt;    pane.add(pic2);  &lt;br /&gt;&lt;br /&gt;//SET DATE HERE&lt;br /&gt;        //textarea = new JTextArea();&lt;br /&gt;        GregorianCalendar today = new GregorianCalendar();&lt;br /&gt;&lt;br /&gt;        String[]weekdays = new DateFormatSymbols().getWeekdays();&lt;br /&gt;        String[]months = new DateFormatSymbols().getMonths();&lt;br /&gt;&lt;br /&gt;        output+=""+weekdays[today.get(today.DAY_OF_WEEK)];&lt;br /&gt;        output+=", "+(today.get(today.DATE))+" ";&lt;br /&gt;        output+=months[today.get(today.MONTH)]+"";&lt;br /&gt;        output+=today.get(today.YEAR)+"\n";&lt;br /&gt;   &lt;br /&gt;//TABLE HERE&lt;br /&gt;/*******JTable inventTable = new JTable(row,col);&lt;br /&gt;    inventTable.setGridColor(Color.gray);&lt;br /&gt;       &lt;br /&gt;    JScrollPane inventScroll = new JScrollPane(inventTable);&lt;br /&gt;    inventScroll.setBounds(30,280,650,150);&lt;br /&gt;    pane.add(inventScroll);&lt;br /&gt;&lt;br /&gt;****************/&lt;br /&gt;       &lt;br /&gt;//LABELS HERE&lt;br /&gt;label = new JLabel("A C C O U N T S   E N T R Y");&lt;br /&gt;    label.setBounds(250,80,450,50);&lt;br /&gt;    label.setFont(new Font("Broadway BT",Font.BOLD,20));&lt;br /&gt;    label.setForeground(Color.red);&lt;br /&gt;    label.setBackground(Color.blue);&lt;br /&gt;    pane.add(label);   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;label1 = new JLabel("Date:");&lt;br /&gt;    label1.setBounds(555,150,200,20);&lt;br /&gt;    label1.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;    label1.setForeground(Color.white);&lt;br /&gt;    pane.add(label1);   &lt;br /&gt;    field1 = new JTextField();&lt;br /&gt;    field1.setBounds(592,150,160,20);&lt;br /&gt;    field1.setText(output);&lt;br /&gt;    field1.setForeground(Color.blue);&lt;br /&gt;    pane.add(field1);&lt;br /&gt;   &lt;br /&gt;label2 = new JLabel("ID Number:");&lt;br /&gt;    label2.setBounds(10,150,100,20);&lt;br /&gt;    label2.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;    label2.setForeground(Color.white);&lt;br /&gt;    pane.add(label2);   &lt;br /&gt;   &lt;br /&gt;    try{&lt;br /&gt;    MaskFormatter mf1 = new MaskFormatter("####-####-#");&lt;br /&gt;    JFormattedTextField field2 = new JFormattedTextField(mf1);&lt;br /&gt;    field2.setBounds(85,150,80,20);&lt;br /&gt;    //field2.setText("");&lt;br /&gt;    field2.setForeground(Color.blue);&lt;br /&gt;    pane.add(field2);&lt;br /&gt;    }&lt;br /&gt;    catch(ParseException pe){&lt;br /&gt;    }&lt;br /&gt;label3 = new JLabel("Name:");&lt;br /&gt;    label3.setBounds(10,200,250,20);&lt;br /&gt;    label3.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;    label3.setForeground(Color.white);&lt;br /&gt;    pane.add(label3);   &lt;br /&gt;    field3 = new JTextField();&lt;br /&gt;    field3.setBounds(85,200,250,20);&lt;br /&gt;    field3.setText("");&lt;br /&gt;    field3.setFont(new Font("Tahoma",Font.BOLD,14));&lt;br /&gt;    field3.setForeground(Color.blue);&lt;br /&gt;    pane.add(field3);&lt;br /&gt;&lt;br /&gt;label4 = new JLabel("Status:");&lt;br /&gt;    label4.setBounds(190,150,105,20);&lt;br /&gt;    label4.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;    label4.setForeground(Color.white);&lt;br /&gt;    pane.add(label4);   &lt;br /&gt;   &lt;br /&gt;    combo3 = new JComboBox(status);&lt;br /&gt;    combo3.setBounds(235,150,100,20);&lt;br /&gt;    combo3.setForeground(Color.blue);&lt;br /&gt;    pane.add(combo3);&lt;br /&gt;&lt;br /&gt;label5 = new JLabel("Course/Year:");&lt;br /&gt;    label5.setBounds(585,200,100,20);&lt;br /&gt;    label5.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;    label5.setForeground(Color.white);&lt;br /&gt;    pane.add(label5);   &lt;br /&gt;   &lt;br /&gt;    try{&lt;br /&gt;    MaskFormatter mf2 = new MaskFormatter("****-#");&lt;br /&gt;    JFormattedTextField field5 = new JFormattedTextField(mf2);&lt;br /&gt;    field5.setBounds(670,200,80,20);&lt;br /&gt;    //field5.setText("");&lt;br /&gt;    field5.setForeground(Color.blue);&lt;br /&gt;    pane.add(field5);&lt;br /&gt;    }&lt;br /&gt;    catch(ParseException pe){&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;label6 = new JLabel("Semester:");&lt;br /&gt;    label6.setBounds(360,150,100,20);&lt;br /&gt;    label6.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;    label6.setForeground(Color.white);&lt;br /&gt;    pane.add(label6);   &lt;br /&gt;&lt;br /&gt;    combo1 = new JComboBox(semester);&lt;br /&gt;    combo1.setBounds(425,150,100,20);&lt;br /&gt;    combo1.setForeground(Color.blue);&lt;br /&gt;    pane.add(combo1);&lt;br /&gt;&lt;br /&gt;label7 = new JLabel("Gender:");&lt;br /&gt;    label7.setBounds(375,200,100,20);&lt;br /&gt;    label7.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;    label7.setForeground(Color.white);&lt;br /&gt;    pane.add(label7);   &lt;br /&gt;&lt;br /&gt;    combo2 = new JComboBox(gender);&lt;br /&gt;    combo2.setBounds(425,200,100,20);&lt;br /&gt;    combo2.setForeground(Color.blue);&lt;br /&gt;    pane.add(combo2);&lt;br /&gt;&lt;br /&gt;MyTable tbl = new MyTable();&lt;br /&gt;inventTable=new JTable(tbl);&lt;br /&gt;inventScroll1=new JScrollPane(inventTable);&lt;br /&gt;inventScroll1.setBounds(10,280,500,100);&lt;br /&gt;pane.add(inventScroll1);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    JPanel bottompanel=new JPanel();&lt;br /&gt;      bottompanel.setBackground(Color.white);&lt;br /&gt;       &lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;//dimension size of button&lt;br /&gt;    Dimension size=new Dimension(50,30);&lt;br /&gt;//bevel JLabel label1 = newbutton&lt;br /&gt;    Border edge=BorderFactory.createRaisedBevelBorder();&lt;br /&gt;&lt;br /&gt;//declare bottons&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;JPanel panels=new JPanel();&lt;br /&gt;    panels.setBounds(30,235,200,40);&lt;br /&gt;    panels.setBorder(new CompoundBorder(BorderFactory.createLineBorder(Color.black,1),&lt;br /&gt;    BorderFactory.createBevelBorder(BevelBorder.LOWERED)));&lt;br /&gt;    buttonstudent=new JRadioButton("Student");&lt;br /&gt;    buttonstaff=new JRadioButton("Staff");&lt;br /&gt;    radiogroup=new ButtonGroup();&lt;br /&gt;    radiogroup.add(buttonstudent);&lt;br /&gt;    radiogroup.add(buttonstaff);&lt;br /&gt;    panels.add(buttonstudent);&lt;br /&gt;    panels.add(buttonstaff);&lt;br /&gt;    pane.add(panels);&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     &lt;br /&gt;     buttonadd = new JButton("ADD");&lt;br /&gt;     buttonadd.setBounds(50,520,80,30);&lt;br /&gt;     buttonadd.setPreferredSize(size);&lt;br /&gt;     buttonadd.setBorder(edge);&lt;br /&gt;     buttonadd.setToolTipText("click this button to add file.");&lt;br /&gt;     buttonadd.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;     buttonadd.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;     buttonadd.setBackground(new Color(10,250,210));&lt;br /&gt;     buttonadd.setForeground(new Color(0,5,255));&lt;br /&gt;     buttonadd.setMnemonic('A');&lt;br /&gt;     bottompanel.add(buttonadd);&lt;br /&gt;&lt;br /&gt;     buttonsave = new JButton("SAVE");&lt;br /&gt;     buttonsave.setPreferredSize(size);&lt;br /&gt;     buttonsave.setBorder(edge);&lt;br /&gt;     buttonsave.setToolTipText("it saves the files");&lt;br /&gt;     buttonsave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;     buttonsave.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;     buttonsave.setForeground(new Color(0,5,255));&lt;br /&gt;     buttonsave.setBackground(new Color(10,250,210));&lt;br /&gt;     buttonsave.setBounds(150,520,80,30);&lt;br /&gt;     buttonsave.setMnemonic('S');    &lt;br /&gt;     bottompanel.add(buttonsave);&lt;br /&gt;       &lt;br /&gt;     buttonprint = new JButton("PRINT");&lt;br /&gt;     buttonprint.setBounds(250,520,80,30);&lt;br /&gt;     buttonprint.setPreferredSize(size);&lt;br /&gt;     buttonprint.setBorder(edge);&lt;br /&gt;     buttonprint.setToolTipText("it gives you a hard copy");&lt;br /&gt;     buttonprint.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;     buttonprint.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;     buttonprint.setForeground(new Color(0,5,255));&lt;br /&gt;     buttonprint.setBackground(new Color(10,250,210));&lt;br /&gt;     buttonprint.setMnemonic('P');&lt;br /&gt;     bottompanel.add(buttonprint);&lt;br /&gt;&lt;br /&gt;    buttonsearch = new JButton("SEARCH");&lt;br /&gt;         buttonsearch.setBounds(350,520,80,30);&lt;br /&gt;        buttonsearch.setPreferredSize(size);&lt;br /&gt;    buttonsearch.setBorder(edge);&lt;br /&gt;         buttonsearch.setToolTipText("click this button to find");&lt;br /&gt;         buttonsearch.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;         buttonsearch.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;         buttonsearch.setForeground(new Color(0,5,255));&lt;br /&gt;         buttonsearch.setBackground(new Color(10,250,210));&lt;br /&gt;    buttonsearch.setMnemonic('R');&lt;br /&gt;         bottompanel.add(buttonsearch);&lt;br /&gt;&lt;br /&gt;    buttondelete = new JButton("DELETE");&lt;br /&gt;         buttondelete.setBounds(450,520,80,30);&lt;br /&gt;        buttondelete.setPreferredSize(size);&lt;br /&gt;    buttondelete.setBorder(edge);&lt;br /&gt;         buttondelete.setToolTipText("Click this button to erase the file");&lt;br /&gt;         buttondelete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;         buttondelete.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;         buttondelete.setForeground(new Color(0,5,255));&lt;br /&gt;         buttondelete.setBackground(new Color(10,250,210));&lt;br /&gt;    buttondelete.setMnemonic('D');&lt;br /&gt;         bottompanel.add(buttondelete);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    buttonclose = new JButton("CLOSE");&lt;br /&gt;         buttonclose.setBounds(550,520,80,30);&lt;br /&gt;        buttonclose.setPreferredSize(size);&lt;br /&gt;    buttonclose.setBorder(edge);&lt;br /&gt;         buttonclose.setToolTipText("Click this button to terminate the frame");&lt;br /&gt;         buttonclose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;         buttonclose.setFont(new Font("Arial",Font.BOLD,14));&lt;br /&gt;         buttonclose.setForeground(new Color(0,5,255));&lt;br /&gt;         buttonclose.setBackground(new Color(10,250,210));&lt;br /&gt;    buttonclose.setMnemonic('C');&lt;br /&gt;         bottompanel.add(buttonclose);&lt;br /&gt;&lt;br /&gt;    //pane.add(bottompanel);&lt;br /&gt;     pane.add(buttonsearch);   &lt;br /&gt;     pane.add(buttonadd);&lt;br /&gt;     pane.add(buttonprint);&lt;br /&gt;     pane.add(buttonsave);&lt;br /&gt;     pane.add(buttonclose);&lt;br /&gt;     pane.add(buttondelete);   &lt;br /&gt;&lt;br /&gt;    //pane.add(buttonstudent);&lt;br /&gt;    //pane.add(buttonstaff);&lt;br /&gt;&lt;br /&gt;buttonclose.addActionListener(new ActionListener(){&lt;br /&gt;        public void actionPerformed(ActionEvent e){&lt;br /&gt;setVisible(false);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;//TABLE HEREEEEEEEEEEEEEEEEEEEEEE&lt;br /&gt;&lt;br /&gt;class MyTable extends AbstractTableModel {&lt;br /&gt;        final String[] columndata={"DATE","CHARGE","CREDIT","BALANCE"};&lt;br /&gt;        final Object[][] data = new Object[14][6];&lt;br /&gt;&lt;br /&gt;       &lt;br /&gt;        public Object getValueAt(int row, int col) {&lt;br /&gt;            return data[row][col];&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        public int getColumnCount() {&lt;br /&gt;            return columndata.length;&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        public int getRowCount() {&lt;br /&gt;            return data.length;&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        public String getColumnName(int col) {&lt;br /&gt;            return columndata[col];&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;       &lt;br /&gt;        /*&lt;br /&gt;         * Don't need to implement this method unless your table's&lt;br /&gt;         * editable.&lt;br /&gt;         */&lt;br /&gt;&lt;br /&gt;        public boolean isCellEditable(int row, int col) {&lt;br /&gt;            //Note that the data/cell address is constant,&lt;br /&gt;            //no matter where the cell appears onscreen.&lt;br /&gt;            if (col &lt; 0) {&lt;br /&gt;                return false;&lt;br /&gt;            } else {&lt;br /&gt;                return true;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void setValueAt(Object value, int row, int col) {&lt;br /&gt;           &lt;br /&gt;            data[row][col] = value;&lt;br /&gt;            fireTableCellUpdated(row, col);&lt;br /&gt;            System.out.println(data[row][col]);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;      }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4833568462380486704?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4833568462380486704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4833568462380486704' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4833568462380486704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4833568462380486704'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/accounts-entry.html' title='Accounts Entry'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-9169616481993386595</id><published>2007-04-13T22:26:00.000-07:00</published><updated>2007-04-13T22:27:07.535-07:00</updated><title type='text'>Accession</title><content type='html'>import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class Accession extends JFrame {&lt;br /&gt;&lt;br /&gt;   boolean inAnApplet = true;&lt;br /&gt;    private boolean laidOut = false;&lt;br /&gt;   private JPanel panel;&lt;br /&gt; //   private JButton Loan, b2, b3,Next,Exit;&lt;br /&gt;    private JLabel label, label1,label3,label4,label2;&lt;br /&gt;  &lt;br /&gt;    private JTextField nameField,name,middle,last;&lt;br /&gt;   private JTable table;&lt;br /&gt; private JScrollPane scrollPane;&lt;br /&gt; private JButton Cancel, Exit,Menu,Save;&lt;br /&gt;    public Accession() {&lt;br /&gt;        Container contentPane = getContentPane();&lt;br /&gt;        contentPane.setLayout(null);&lt;br /&gt; panel = new JPanel();&lt;br /&gt;panel.setLayout( new BorderLayout() );&lt;br /&gt;        getContentPane().add( panel );&lt;br /&gt;       label1 = new JLabel("CJC  High school Library System");    &lt;br /&gt;      contentPane.add(label1);&lt;br /&gt;      label = new JLabel("Accession NO:");&lt;br /&gt;       contentPane.add(label);      &lt;br /&gt;      label2 = new JLabel("First Name");  &lt;br /&gt;    contentPane.add(label2); &lt;br /&gt;  label3= new JLabel("Last Name");    &lt;br /&gt;      contentPane.add(label3); &lt;br /&gt;label4= new JLabel("Middle Name");&lt;br /&gt;     contentPane.add(label4); &lt;br /&gt; nameField = new JTextField(1);&lt;br /&gt;    contentPane.add(nameField);&lt;br /&gt;&lt;br /&gt;     String columnNames[] = { "Name", "Address", "Grade/sec"," Return Book    "  ,  "Book Title  "    , " Due Date" };&lt;br /&gt;&lt;br /&gt;        // Create some data&lt;br /&gt;        String dataValues[][] =&lt;br /&gt;        {&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;   { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt; { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;  { "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt;{ "", "", "",  "", "", ""},&lt;br /&gt; &lt;br /&gt; };&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; table= new JTable(dataValues, columnNames);&lt;br /&gt; scrollPane = new JScrollPane(table);&lt;br /&gt;//variable.add(table);&lt;br /&gt;//contentPane.add(variable);&lt;br /&gt;panel.add( scrollPane, BorderLayout.CENTER );&lt;br /&gt;Exit = new JButton("Exit");&lt;br /&gt;        contentPane.add(Exit);&lt;br /&gt;     &lt;br /&gt;  Menu = new JButton("Main");&lt;br /&gt;        contentPane.add(Menu);&lt;br /&gt;        //b3 = new JButton("Inventory");&lt;br /&gt;        //contentPane.add(b3);&lt;br /&gt;        Save = new JButton("Save");&lt;br /&gt;   contentPane.add(Save);      &lt;br /&gt; Cancel= new JButton("Cancel");  &lt;br /&gt;  contentPane.add(Cancel); &lt;br /&gt;Insets insets = contentPane.getInsets();&lt;br /&gt;label1.setBounds(250+insets.left,1+insets.top,300,100); &lt;br /&gt;label.setBounds(100+insets.left,80+insets.top,100,30);&lt;br /&gt;      nameField.setBounds(200+insets.left,100+insets.top,80,20);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  //main.setBounds(60+insets.left,60+insets.top,10,30);    &lt;br /&gt;panel.setBounds(150 + insets.left, 180 + insets.top,500,200);&lt;br /&gt;        Exit.setBounds(200 + insets.left, 400 + insets.top, 100, 30);&lt;br /&gt;        Menu.setBounds(300 + insets.left,400 + insets.top, 100,30 );&lt;br /&gt;        Save.setBounds(400+ insets.left,400+insets.top,100,30);&lt;br /&gt;        Cancel.setBounds( 500+insets.left,400+insets.top,100,30);    &lt;br /&gt; &lt;br /&gt;&lt;br /&gt; Menu.addActionListener(new ActionListener(){&lt;br /&gt;  public void actionPerformed(ActionEvent l){&lt;br /&gt;NoneWindow e = new NoneWindow();&lt;br /&gt;e.setSize(600,600);&lt;br /&gt;e.show();&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt; Menu.addActionListener(new ActionListener(){&lt;br /&gt;  public void actionPerformed(ActionEvent l){&lt;br /&gt; NoneWindow e = new NoneWindow();&lt;br /&gt;e.setSize(600,600);&lt;br /&gt;e.show();&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;);       &lt;br /&gt;&lt;br /&gt;       &lt;br /&gt; // Loan.addActionListener(new ActionListener(){&lt;br /&gt; // public void actionPerformed(ActionEvent l){&lt;br /&gt;//Loan e = new Loan();&lt;br /&gt;//e.setSize(600,600);&lt;br /&gt;//e.show();&lt;br /&gt;//   }&lt;br /&gt; // }&lt;br /&gt;//);&lt;br /&gt;addWindowListener(new WindowAdapter() {&lt;br /&gt;            public void windowClosing(WindowEvent e) {&lt;br /&gt;                if (inAnApplet) {&lt;br /&gt;                    dispose();&lt;br /&gt;                } else {&lt;br /&gt;                    System.exit(0);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   public static void main(String args[]) {&lt;br /&gt;        Accession window = new Accession();&lt;br /&gt;        Insets insets = window.getInsets();&lt;br /&gt;        window.inAnApplet = false;&lt;br /&gt;&lt;br /&gt;        window.setTitle("ACCESSION NUMBER");&lt;br /&gt;        window.setSize(300 + insets.left + insets.right,&lt;br /&gt;                       200 + insets.top + insets.bottom);&lt;br /&gt;        window.setVisible(true);&lt;br /&gt;    }&lt;br /&gt;//public static void main (String args[]){  &lt;br /&gt;//}//&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-9169616481993386595?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/9169616481993386595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=9169616481993386595' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/9169616481993386595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/9169616481993386595'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/accession.html' title='Accession'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-1148711346566740651</id><published>2007-04-13T22:25:00.002-07:00</published><updated>2007-04-13T22:26:08.057-07:00</updated><title type='text'>Valentine</title><content type='html'>import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;public class Valentine extends JFrame{&lt;br /&gt;    Container pane;&lt;br /&gt;    JButton b;&lt;br /&gt;    JTextField c;&lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;        Valentine valdate = new Valentine();&lt;br /&gt;            valdate.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;            valdate.setSize(400,300);&lt;br /&gt;            valdate.setVisible(true);&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    public Valentine(){&lt;br /&gt;        // ds&lt;br /&gt;        String[] stars = {"Robert Redford","Manilyn Monroe","Boris Karloff","Lassie","Hopalang Cassidy","Trigger","Tom Hanks","Russel Crowe","Lone Ranger","Zorro"};&lt;br /&gt;       &lt;br /&gt;        String output="",Dates;&lt;br /&gt;        //super ("SUPER");&lt;br /&gt;        pane=getContentPane();&lt;br /&gt;        //pane.LayOut("null");&lt;br /&gt;        //pick the your valentine date by random&lt;br /&gt;        b=new JButton("OK");&lt;br /&gt;        b.setBounds(50,50,10,10);&lt;br /&gt;        pane.add(b);&lt;br /&gt;        //c=new JTextField(10);&lt;br /&gt;        //pane.add(c);&lt;br /&gt;        //0c.setBounds(100,100,100,100);&lt;br /&gt;        /*output +="Your Valentine Date is\n";&lt;br /&gt;        Dates = stars[(int)(stars.length*Math.random())];&lt;br /&gt;        output+=Dates;&lt;br /&gt;       &lt;br /&gt;        JOptionPane.showMessageDialog(null,output,"Your Valentine Date is", JOptionPane.INFORMATION_MESSAGE);&lt;br /&gt;        System.exit(0);*/&lt;br /&gt;        }&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-1148711346566740651?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/1148711346566740651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=1148711346566740651' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1148711346566740651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1148711346566740651'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/valentine.html' title='Valentine'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-3321233813662470899</id><published>2007-04-13T22:25:00.001-07:00</published><updated>2007-04-13T22:25:36.478-07:00</updated><title type='text'>SpringLayout</title><content type='html'>import javax.swing.JButton;&lt;br /&gt;import javax.swing.JFrame;&lt;br /&gt;import javax.swing.SpringLayout;&lt;br /&gt;import javax.swing.Spring;&lt;br /&gt;&lt;br /&gt;import java.awt.Container;&lt;br /&gt;import java.awt.Dimension;&lt;br /&gt;import java.awt.Toolkit;&lt;br /&gt;&lt;br /&gt;public class TrySpringLayout{&lt;br /&gt;    static JFrame win = new JFrame("This is a Spring Layout");&lt;br /&gt;   &lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;        TrySpringLayout springlayout = new TrySpringLayout();&lt;br /&gt;        Toolkit toolkit = win.getToolkit();  //get toolkit window&lt;br /&gt;        Dimension wndSize = toolkit.getScreenSize();  //Get screen size&lt;br /&gt;       &lt;br /&gt;        //set the position to scree center and size to half screen size&lt;br /&gt;        win.setBounds(wndSize.width/4, wndSize.height/4, wndSize.width/2, wndSize.height/2); //position,size&lt;br /&gt;        win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;        win.pack();&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        public TrySpringLayout(){&lt;br /&gt;            win.setVisible(true);&lt;br /&gt;           &lt;br /&gt;            SpringLayout layout = new SpringLayout();  //Create a layout manager&lt;br /&gt;            Container content = win.getContentPane();   //Get the content pane&lt;br /&gt;            content.setLayout(layout);&lt;br /&gt;           &lt;br /&gt;            JButton[] buttons = new JButton[6];   //Array to store buttons&lt;br /&gt;            for (int i=0; i&lt; buttons.length; i++){&lt;br /&gt;                buttons[i] = new JButton("Press" + (i+1));&lt;br /&gt;                content.add(buttons[i]);  //add a  button to content pane&lt;br /&gt;                }  // end for&lt;br /&gt;               &lt;br /&gt;                Spring xSpring = Spring.constant(5,15,25); //x constraint for 1st button&lt;br /&gt;                Spring ySpring = Spring.constant(10,30,50); // y constant for first button&lt;br /&gt;                Spring wSpring = Spring.constant(30,80,130); // width constraint for buttons&lt;br /&gt;               &lt;br /&gt;                //connect x,y for first button to left anf top of container by springs&lt;br /&gt;                SpringLayout.Constraints buttonConstr = layout.getConstraints(buttons[0]);&lt;br /&gt;                buttonConstr.setX(xSpring);&lt;br /&gt;                buttonConstr.setY(ySpring);&lt;br /&gt;               &lt;br /&gt;                //set width and heiht of buttons and hook buttons together&lt;br /&gt;                for (int i=0; i&lt;buttons.length; i++){&lt;br /&gt;                    buttonConstr = layout.getConstraints(buttons[i]);&lt;br /&gt;                    buttonConstr.setHeight(ySpring);   //Set the button height constraint&lt;br /&gt;                    buttonConstr.setWidth(wSpring);  // and its width constrainy&lt;br /&gt;                   &lt;br /&gt;                    if (i&gt;0){   // for buttons after the first&lt;br /&gt;                                 //tie W and N edges to E N of predecessor&lt;br /&gt;                                 layout.putConstraint(SpringLayout.WEST,buttons[i], xSpring,SpringLayout.EAST,buttons[i-1]);&lt;br /&gt;                                 layout.putConstraint(SpringLayout.NORTH,buttons[i], ySpring,SpringLayout.SOUTH,buttons[i-1]);&lt;br /&gt;                               }&lt;br /&gt;                           }&lt;br /&gt;                          &lt;br /&gt;                           //relating the size of the window to the springs&lt;br /&gt;                           SpringLayout.Constraints constr = layout.getConstraints(content);&lt;br /&gt;                           constr.setConstraint(SpringLayout.EAST,Spring.sum(buttonConstr.getConstraint(SpringLayout.EAST),Spring.constant(15)));&lt;br /&gt;                           constr.setConstraint(SpringLayout.SOUTH,Spring.sum(buttonConstr.getConstraint(SpringLayout.SOUTH),Spring.constant(10)));&lt;br /&gt;                         &lt;br /&gt;                           }&lt;br /&gt;                           }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-3321233813662470899?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/3321233813662470899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=3321233813662470899' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3321233813662470899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3321233813662470899'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/springlayout.html' title='SpringLayout'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-3305422945014471342</id><published>2007-04-13T22:23:00.000-07:00</published><updated>2007-04-13T22:24:20.216-07:00</updated><title type='text'>GridLayoutTest</title><content type='html'>import java.awt.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;&lt;br /&gt;public class GridBagLayoutTest extends JFrame{&lt;br /&gt;   &lt;br /&gt;    //main&lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;        GridBagLayoutTest gridbag = new GridBagLayoutTest();&lt;br /&gt;        gridbag.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;        gridbag.setSize(500,150);&lt;br /&gt;        gridbag.setVisible(true);&lt;br /&gt;        gridbag.pack();&lt;br /&gt;    }&lt;br /&gt;        //constructor&lt;br /&gt;        public GridBagLayoutTest(){&lt;br /&gt;            super("Using GridBagLayout");&lt;br /&gt;            buildLayout();&lt;br /&gt;        }&lt;br /&gt;        void buildLayout(){&lt;br /&gt;            Container pane = getContentPane();&lt;br /&gt;            GridBagConstraints constraints = new GridBagConstraints();&lt;br /&gt;            GridBagLayout layout = new GridBagLayout();&lt;br /&gt;            pane.setLayout(layout);&lt;br /&gt;           &lt;br /&gt;            constraints.anchor = GridBagConstraints.WEST;&lt;br /&gt;           &lt;br /&gt;            constraints.gridy = 0;&lt;br /&gt;            JLabel label = new JLabel("Firstname:");&lt;br /&gt;            label.setFont(new Font("Arial", Font.PLAIN,14));&lt;br /&gt;            pane.add(label,constraints);&lt;br /&gt;           &lt;br /&gt;            JTextField textfield = new JTextField(15);&lt;br /&gt;            textfield.setFont(new Font("Arial",Font.PLAIN,14));&lt;br /&gt;            pane.add(textfield, constraints);&lt;br /&gt;           &lt;br /&gt;            //add label2 and textfield2&lt;br /&gt;            label = new JLabel("LastName:");&lt;br /&gt;            label.setFont(new Font("Arial",Font.PLAIN,14));&lt;br /&gt;            pane.add(textfield,constraints);&lt;br /&gt;           &lt;br /&gt;            //position next textfield&lt;br /&gt;            constraints.gridx = 0;&lt;br /&gt;            constraints.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;            constraints.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;           &lt;br /&gt;            //add spaces between horizontalfields&lt;br /&gt;            constraints.gridy = 1;&lt;br /&gt;            label = new JLabel("Address:");&lt;br /&gt;            label.setFont(new Font("Arial",Font.PLAIN,14));&lt;br /&gt;            pane.add(label,constraints);&lt;br /&gt;           &lt;br /&gt;            constraints.gridx = 1;&lt;br /&gt;            textfield = new JTextField(30);&lt;br /&gt;            textfield.setFont(new Font("Arial", Font.PLAIN,14));&lt;br /&gt;            pane.add(textfield,constraints);&lt;br /&gt;           &lt;br /&gt;            constraints.gridy++;&lt;br /&gt;            JButton buttonOk = new JButton("Ok");&lt;br /&gt;            buttonOk.setBorder(BorderFactory.createRaisedBevelBorder());&lt;br /&gt;            buttonOk.setBackground(Color.orange);&lt;br /&gt;            buttonOk.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;            buttonOk.setToolTipText("...clickable, but actionless button");&lt;br /&gt;            buttonOk.setFont(new Font("Lucida HandWriting", Font.BOLD,14));&lt;br /&gt;            pane.add(buttonOk, constraints);&lt;br /&gt;        }&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-3305422945014471342?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/3305422945014471342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=3305422945014471342' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3305422945014471342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3305422945014471342'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/gridlayouttest.html' title='GridLayoutTest'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4691644325111683662</id><published>2007-04-13T22:18:00.000-07:00</published><updated>2007-04-13T22:21:19.555-07:00</updated><title type='text'>ForLoop</title><content type='html'>import javax.swing.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;import java.text.DecimalFormat;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;&lt;br /&gt;public class ForLoop extends JFrame{&lt;br /&gt;//cdm&lt;br /&gt;   String output="";&lt;br /&gt;   int row,col;&lt;br /&gt;   Container pane;&lt;br /&gt;   JTextArea textarea;&lt;br /&gt;   JPanel topPanel, bottomPanel;&lt;br /&gt;//define fonts&lt;br /&gt;   Font tisFont = new Font("Arial", Font.PLAIN, 14);&lt;br /&gt;   Font PanelFont = new Font ("Tahma", Font.BOLD,15);&lt;br /&gt;//format&lt;br /&gt;   DecimalFormat precision = new DecimalFormat("0.00000");&lt;br /&gt;&lt;br /&gt;public static void main(String[] args){&lt;br /&gt;    ForLoop frameDemo = new ForLoop();&lt;br /&gt;    frameDemo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;    frameDemo.setBounds(150, 100, 400, 300);&lt;br /&gt;    frameDemo.setVisible(true);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public ForLoop(){&lt;br /&gt;    super("Making Frames More Attractive");&lt;br /&gt;//display&lt;br /&gt;buildDisplay();&lt;br /&gt;//topDisplay&lt;br /&gt;topDisplay();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void buildDisplay(){&lt;br /&gt;  //local var&lt;br /&gt;  int i, starVal = 1, endVal = 50;&lt;br /&gt;  long square, cube;&lt;br /&gt;  double squareRoot, cubeRoot, pwrt = 0.3333;&lt;br /&gt; &lt;br /&gt;   pane = getContentPane();&lt;br /&gt;   textarea = new JTextArea (row, col);&lt;br /&gt;//heading&lt;br /&gt;   output += "number\tsqaure\tcube\tsquare root\tcube root\n";&lt;br /&gt;   &lt;br /&gt;   for (i=starVal; i &lt;=endVal; i++){&lt;br /&gt;     square = i *  i;&lt;br /&gt;     cube = i * i * 1;&lt;br /&gt;     squareRoot = Math.pow(i,0.5);&lt;br /&gt;     cubeRoot = Math.pow(i,pwrt);&lt;br /&gt;    &lt;br /&gt;     output +="  " + i + "\t" + square + "\t" + cube + "\t";&lt;br /&gt;     output += precision.format(squareRoot) + "\t";&lt;br /&gt;     output += precision.format(cubeRoot) + "\t";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;textarea.setText(output);&lt;br /&gt;textarea.setFont(tisFont);&lt;br /&gt;textarea.setBackground(Color.white);&lt;br /&gt;textarea.setEditable(false);&lt;br /&gt;textarea.setBorder(new CompoundBorder(&lt;br /&gt;&lt;br /&gt;    // BorderFactory.createLineBorder(Color.white),&lt;br /&gt;     BorderFactory.createBevelBorder(BevelBorder.LOWERED)));&lt;br /&gt;textarea.setToolTipText("&gt;output area&lt;");&lt;br /&gt;pane.add(textarea,BorderLayout.CENTER);&lt;br /&gt;JScrollPane scrollpane = new JScrollPane(textarea);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void topDisplay(){&lt;br /&gt;    topPanel = new JPanel();&lt;br /&gt;    topPanel.setBackground(Color.gray);&lt;br /&gt;    topPanel.setToolTipText("Top Panel");&lt;br /&gt;//label&lt;br /&gt;&lt;br /&gt;   JLabel label = new JLabel ("SQUARE, CUBE, AND ROOTS");&lt;br /&gt;   label.setFont(PanelFont);&lt;br /&gt;   //label.setBorder(BorderFactory.createBevelBorder(BevelBorder,RAISED));&lt;br /&gt;   label.setBackground(Color.red);&lt;br /&gt;&lt;br /&gt;   topPanel.add(label);&lt;br /&gt;   pane.add(topPanel,BorderLayout.NORTH);&lt;br /&gt;  }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4691644325111683662?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4691644325111683662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4691644325111683662' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4691644325111683662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4691644325111683662'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/forloop.html' title='ForLoop'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4259526930442270312</id><published>2007-04-09T17:59:00.002-07:00</published><updated>2007-04-09T18:01:11.001-07:00</updated><title type='text'>FilmCast</title><content type='html'>import java.util.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class FilmCastII extends JFrame{&lt;br /&gt;    //ds&lt;br /&gt;    Person person;&lt;br /&gt;    Cast filmCast = new Cast();&lt;br /&gt;   &lt;br /&gt;    String output = "";&lt;br /&gt;    int row,col;&lt;br /&gt;   &lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;        FilmCastII theCast = new FilmCastII();&lt;br /&gt;        theCast.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;        Toolkit toolkit = theCast.getToolkit();&lt;br /&gt;        Dimension winSize = toolkit.getScreenSize();&lt;br /&gt;       &lt;br /&gt;        //center screen&lt;br /&gt;        theCast.setBounds(winSize.width/4,winSize.height/4,winSize.width/2,winSize.height/2);&lt;br /&gt;        theCast.setVisible(true);&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    public FilmCastII(){&lt;br /&gt;        //window title&lt;br /&gt;        super("THE CAST FOR THE FILM");&lt;br /&gt;       &lt;br /&gt;        //populate the crowd&lt;br /&gt;        for(;;){&lt;br /&gt;            person = readPerson();&lt;br /&gt;            if (person == null){&lt;br /&gt;                break;&lt;br /&gt;            }&lt;br /&gt;           &lt;br /&gt;            filmCast.add(person);&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        int count = filmCast.size();&lt;br /&gt;        output += "You've added"+count+(count==1?"person":"people")+"to the film cast.\n";&lt;br /&gt;       &lt;br /&gt;        //show the members of the cast&lt;br /&gt;        Iterator thisLot = filmCast.iterator();&lt;br /&gt;       &lt;br /&gt;        output += "\nCasted in the Film are:\n";&lt;br /&gt;       &lt;br /&gt;        //display the people in the cast&lt;br /&gt;        while (thisLot.hasNext()){&lt;br /&gt;            output+=(thisLot.next())+"\n";&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;        //display output&lt;br /&gt;        Container pane = getContentPane();&lt;br /&gt;        JTextArea textarea = new JTextArea(row,col);&lt;br /&gt;       &lt;br /&gt;        textarea.setText(output);&lt;br /&gt;        textarea.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;        textarea.setBackground(new Color(250,250,0));&lt;br /&gt;       &lt;br /&gt;        pane.add(textarea);&lt;br /&gt;       &lt;br /&gt;        //add bottom panel&lt;br /&gt;        //pane.add(new BottomPanel(), BorderLayout.SOUTH);&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    //readPerson method&lt;br /&gt;    //enter person from keyboard&lt;br /&gt;    static public Person readPerson(){&lt;br /&gt;       &lt;br /&gt;        //read in the first name&lt;br /&gt;        String fullName = JOptionPane.showInputDialog(null,&lt;br /&gt;        "\nPlease enter fullname of the actor and actress\n"+&lt;br /&gt;        "format: familyname, firstname \nor enter ! to end.|n",&lt;br /&gt;        "INPUT FULLNAME OF STAR",JOptionPane.QUESTION_MESSAGE);&lt;br /&gt;       &lt;br /&gt;        fullName = fullName.trim();&lt;br /&gt;       &lt;br /&gt;        if(fullName.charAt(0) == '!'){&lt;br /&gt;            return null;&lt;br /&gt;            }&lt;br /&gt;           &lt;br /&gt;            //check if format is correct&lt;br /&gt;            char separator = ',';&lt;br /&gt;            int index = 0, endIndex = 0;&lt;br /&gt;            String firstname,surname;&lt;br /&gt;           &lt;br /&gt;            //extract firstname and Lastname of actor/actress&lt;br /&gt;            endIndex = fullName.indexOf(separator,index);&lt;br /&gt;            surname = fullName.substring(0,endIndex);&lt;br /&gt;            firstname = fullName.substring(endIndex + 1, fullName.length());&lt;br /&gt;           &lt;br /&gt;            return new Person(firstname,surname);&lt;br /&gt;            }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4259526930442270312?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4259526930442270312/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4259526930442270312' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4259526930442270312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4259526930442270312'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/filmcast.html' title='FilmCast'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-2484341894506614959</id><published>2007-04-09T17:59:00.001-07:00</published><updated>2007-04-09T17:59:22.364-07:00</updated><title type='text'>CalendarFormat</title><content type='html'>import java.util.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class CalendarFormat extends JFrame{&lt;br /&gt;   &lt;br /&gt;    //cdm&lt;br /&gt;    private static JFrame winframe = new JFrame();&lt;br /&gt;   &lt;br /&gt;    Container pane;&lt;br /&gt;    JTextArea textarea;&lt;br /&gt;   &lt;br /&gt;    int row, col;&lt;br /&gt;   &lt;br /&gt;    String output="";&lt;br /&gt;   &lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;        CalendarFormat formatdate = new CalendarFormat();&lt;br /&gt;        formatdate.setBounds(150,150,300,220);&lt;br /&gt;        formatdate.setVisible(true);&lt;br /&gt;    }&lt;br /&gt;    public CalendarFormat(){&lt;br /&gt;       &lt;br /&gt;        super ("Date Utility");&lt;br /&gt;       &lt;br /&gt;        //container&lt;br /&gt;        pane = getContentPane();&lt;br /&gt;        pane.setLayout(new FlowLayout());&lt;br /&gt;        pane.setBackground(new Color(5,255,30));&lt;br /&gt;        pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;       &lt;br /&gt;        //text area&lt;br /&gt;        textarea = new JTextArea(row,col);&lt;br /&gt;       &lt;br /&gt;        //window listener&lt;br /&gt;        addWindowListener(new WindowHandler());&lt;br /&gt;       &lt;br /&gt;        //output display&lt;br /&gt;        outputDisplay();&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    void outputDisplay(){&lt;br /&gt;       &lt;br /&gt;        //local var&lt;br /&gt;        int year, month, day;&lt;br /&gt;        Date date = new Date();&lt;br /&gt;        output+="Today is:"+date.toString()+"\n";&lt;br /&gt;        //calendar class&lt;br /&gt;        GregorianCalendar today = new GregorianCalendar();&lt;br /&gt;       &lt;br /&gt;        year = today.get(today.YEAR);&lt;br /&gt;        month = today.get(today.MONTH);&lt;br /&gt;        day = today.get(today.DATE);&lt;br /&gt;       &lt;br /&gt;        output += "\n\nYEAR:"+year+"\n";&lt;br /&gt;        output += "MONTH:"+(month +1)+"\n";&lt;br /&gt;        output += "DAY:"+day+"\n";&lt;br /&gt;       &lt;br /&gt;       &lt;br /&gt;        textarea.setText(output);&lt;br /&gt;        textarea.setFont(new Font("Tahoma",Font.PLAIN,14));&lt;br /&gt;        textarea.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));&lt;br /&gt;        pane.add(textarea);&lt;br /&gt;       &lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    class WindowHandler extends WindowAdapter{&lt;br /&gt;        public void windowClosing(WindowEvent e){&lt;br /&gt;            winframe.dispose();&lt;br /&gt;            System.exit(0);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-2484341894506614959?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/2484341894506614959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=2484341894506614959' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2484341894506614959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/2484341894506614959'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/calendarformat.html' title='CalendarFormat'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8995762603171826176</id><published>2007-04-09T17:56:00.000-07:00</published><updated>2007-04-09T17:58:00.089-07:00</updated><title type='text'>BorderLayout</title><content type='html'>&lt;username.length();i++){ else="" do="" not="" funny="" invalid="" return="" string="" local="" var="" int="" boolean="" char="" isok="true;" please="" enter="" n="" use="" the="" date="" format="" mm="" dd="" yyyy="" username="" input="" your="" birthdate="" discard="" all="" whitespaces="" dateofbirth="JOptionPane.showInputDialog(null,userName" check="" for="" length="10"&gt;&lt;dateofbirth.length();i++){ correct="" placement="" u002f="" else="" wrong="" input="" check="" for="" values="" of="" year="" gregoriancalendar="" thisdate="new" calendar="" isok="true;"&gt;import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;&lt;br /&gt;public class BoxLayoutTest{&lt;br /&gt;    //window&lt;br /&gt;    static JFrame window = new JFrame("Radio and Clickable Buttons");&lt;br /&gt;   &lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;        //&lt;br /&gt;        BoxLayoutTest boxlayout = new BoxLayoutTest();&lt;br /&gt;        Toolkit toolkit = window.getToolkit();&lt;br /&gt;        Dimension wndsize = toolkit.getScreenSize();&lt;br /&gt;        //center screen&lt;br /&gt;        window.setBounds(wndsize.width/4,wndsize.height/4,wndsize.width/2,wndsize.height/2);&lt;br /&gt;        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;        window.setVisible(true);&lt;br /&gt;        }&lt;br /&gt;        //constructor&lt;br /&gt;        public BoxLayoutTest(){&lt;br /&gt;            //holder&lt;br /&gt;            Container content = window.getContentPane();&lt;br /&gt;            content.setLayout(new BorderLayout());&lt;br /&gt;           &lt;br /&gt;            //radiobuttons&lt;br /&gt;            Box left = Box.createVerticalBox();&lt;br /&gt;            ButtonGroup radioGroup = new ButtonGroup();&lt;br /&gt;           &lt;br /&gt;            //series of radio buttons&lt;br /&gt;            JRadioButton rbutton;&lt;br /&gt;            radioGroup.add(rbutton = new JRadioButton("Red"));&lt;br /&gt;            left.add(rbutton);   &lt;br /&gt;           &lt;br /&gt;            radioGroup.add(rbutton = new JRadioButton("Green"));&lt;br /&gt;            left.add(rbutton);   &lt;br /&gt;           &lt;br /&gt;            radioGroup.add(rbutton = new JRadioButton("Blue"));&lt;br /&gt;            left.add(rbutton);   &lt;br /&gt;           &lt;br /&gt;            radioGroup.add(rbutton = new JRadioButton("Yellow"));&lt;br /&gt;            left.add(rbutton);   &lt;br /&gt;           &lt;br /&gt;            //click boxes&lt;br /&gt;            Box right = Box.createVerticalBox();&lt;br /&gt;            right.add(new JCheckBox("Dashed"));&lt;br /&gt;            right.add(new JCheckBox("Thick"));&lt;br /&gt;            right.add(new JCheckBox("Rounded"));&lt;br /&gt;           &lt;br /&gt;            //holder&lt;br /&gt;            Box top = Box.createHorizontalBox();&lt;br /&gt;            top.add(left);&lt;br /&gt;            top.add(right);&lt;br /&gt;           &lt;br /&gt;            content.add(top,BorderLayout.CENTER);&lt;br /&gt;           &lt;br /&gt;            //commands button&lt;br /&gt;            JPanel bottomPanel = new JPanel();&lt;br /&gt;            Border edge = BorderFactory.createRaisedBevelBorder();&lt;br /&gt;           &lt;br /&gt;            //series of commands buttons&lt;br /&gt;            JButton button;&lt;br /&gt;            Dimension size = new Dimension(80,20);&lt;br /&gt;           &lt;br /&gt;            bottomPanel.add(button = new JButton("Defaults"));&lt;br /&gt;            button.setBorder(edge);&lt;br /&gt;            button.setPreferredSize(size);&lt;br /&gt;           &lt;br /&gt;            bottomPanel.add(button = new JButton("OK"));&lt;br /&gt;            button.setBorder(edge);&lt;br /&gt;            button.setPreferredSize(size);&lt;br /&gt;           &lt;br /&gt;            bottomPanel.add(button = new JButton("Cancel"));&lt;br /&gt;            button.setBorder(edge);&lt;br /&gt;            button.setPreferredSize(size);&lt;br /&gt;            bottomPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));&lt;br /&gt;           &lt;br /&gt;            content.add(bottomPanel, BorderLayout.SOUTH);&lt;br /&gt;            content.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;&lt;/dateofbirth.length();i++){&gt;&lt;/username.length();i++){&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8995762603171826176?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8995762603171826176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8995762603171826176' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8995762603171826176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8995762603171826176'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/borderlayout.html' title='BorderLayout'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-5694205366554209917</id><published>2007-04-09T17:55:00.001-07:00</published><updated>2007-04-09T17:55:40.569-07:00</updated><title type='text'>Average of Numbers</title><content type='html'>import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class Average{&lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;        Average ave=new Average();&lt;br /&gt;    }&lt;br /&gt;    public Average(){&lt;br /&gt;    String output="",input,inputs;    &lt;br /&gt;    float num,sum=0,nums,ave;&lt;br /&gt;    input=JOptionPane.showInputDialog("Enter how many numbers to compute:");&lt;br /&gt;   &lt;br /&gt;    num=Float.parseFloat(input);&lt;br /&gt;    for (int x=1;x&lt;=num;x++)&lt;br /&gt;        {&lt;br /&gt;        inputs=JOptionPane.showInputDialog("Enter a number :");&lt;br /&gt;        nums=Float.parseFloat(inputs);&lt;br /&gt;        sum=sum+nums ;&lt;br /&gt;        }&lt;br /&gt;    ave=sum/num;&lt;br /&gt;        output+="The average is: "+ ave;&lt;br /&gt;    JOptionPane.showMessageDialog(null,output,"Average",JOptionPane.INFORMATION_MESSAGE);&lt;br /&gt;    System.exit(0);&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-5694205366554209917?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/5694205366554209917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=5694205366554209917' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/5694205366554209917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/5694205366554209917'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/average-of-numbers.html' title='Average of Numbers'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-7515722348158138250</id><published>2007-04-09T17:54:00.001-07:00</published><updated>2007-04-09T17:54:49.924-07:00</updated><title type='text'>AllDatesFormat</title><content type='html'>import java.util.Locale;&lt;br /&gt;import java.util.Date;&lt;br /&gt;import java.text.DateFormat;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class AllDateFormats extends JFrame{&lt;br /&gt; &lt;br /&gt;   String output = "";&lt;br /&gt;   int row, col;&lt;br /&gt; &lt;br /&gt;   Container pane;&lt;br /&gt;   JTextArea textarea;&lt;br /&gt; &lt;br /&gt;   private static JFrame winframe = new JFrame();&lt;br /&gt; &lt;br /&gt;   public static void main(String[] args){&lt;br /&gt;       AllDateFormats formats = new AllDateFormats();&lt;br /&gt;       formats.setSize(450,560);&lt;br /&gt;       formats.setVisible(true);&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   public AllDateFormats(){&lt;br /&gt;       super("More on Date Utilities");&lt;br /&gt;     &lt;br /&gt;       //container&lt;br /&gt;       pane = getContentPane();&lt;br /&gt;       pane.setLayout(new FlowLayout());&lt;br /&gt;       pane.setBackground(new Color(10,5,255));&lt;br /&gt;       pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));&lt;br /&gt;     &lt;br /&gt;       //text area&lt;br /&gt;       textarea = new JTextArea(row,col);&lt;br /&gt;     &lt;br /&gt;       //window listener&lt;br /&gt;       addWindowListener(new WindowHandler());&lt;br /&gt;     &lt;br /&gt;       //output display&lt;br /&gt;       outputDisplay();&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   void outputDisplay(){&lt;br /&gt;     &lt;br /&gt;       Date today = new Date();&lt;br /&gt;     &lt;br /&gt;       Locale[] locales = {Locale.US, Locale.UK, Locale.CANADA,Locale.GERMANY,Locale.FRANCE,Locale.ITALY};&lt;br /&gt;       int[] styles = {DateFormat.FULL,DateFormat.LONG,DateFormat.MEDIUM,DateFormat.SHORT};&lt;br /&gt;     &lt;br /&gt;       DateFormat fmt;&lt;br /&gt;     &lt;br /&gt;       String[] styleText = {"FULL","LONG","MEDIUM","SHORT"};&lt;br /&gt;     &lt;br /&gt;       //output the Date for each local in four styles&lt;br /&gt;       for (int i=0; i&lt;locales.length;i++){&gt;&lt;br /&gt;           output +="\nThe Date fot"+locales[i].getDisplayCountry()+":";&lt;br /&gt;           for (int j=0; j&lt;styles.length;&gt;&lt;br /&gt;               fmt = DateFormat.getDateInstance(styles[j],locales[i]);&lt;br /&gt;               output +="\tIn"+ styleText[j] + "is" + fmt.format(today)+"\n";&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;     &lt;br /&gt;       textarea.setText(output);&lt;br /&gt;       textarea.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));&lt;br /&gt;       textarea.setFont(new Font("Lucida Sans",Font.PLAIN,12));&lt;br /&gt;       textarea.setToolTipText("Dates Formats in Java");&lt;br /&gt;       pane.add(textarea);&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   class WindowHandler extends WindowAdapter{&lt;br /&gt;       public void windowClosing(WindowEvent e){&lt;br /&gt;           winframe.dispose();&lt;br /&gt;           System.exit(0);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/styles.length;&gt;&lt;/locales.length;i++){&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-7515722348158138250?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/7515722348158138250/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=7515722348158138250' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/7515722348158138250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/7515722348158138250'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/alldatesformat.html' title='AllDatesFormat'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-1886434712321109304</id><published>2007-04-09T17:48:00.000-07:00</published><updated>2007-04-09T17:51:24.705-07:00</updated><title type='text'>Sphere</title><content type='html'>import java.util.*;&lt;br /&gt;&lt;br /&gt;class Sphere{&lt;br /&gt;   &lt;br /&gt;    //data members&lt;br /&gt;    static int count = 0;&lt;br /&gt;   &lt;br /&gt;    //instance&lt;br /&gt;    static double radius;&lt;br /&gt;   &lt;br /&gt;    //coordinates&lt;br /&gt;    double xCenter;&lt;br /&gt;    double yCenter;&lt;br /&gt;    double zCenter;&lt;br /&gt;   &lt;br /&gt;    //constructor&lt;br /&gt;    Sphere(double radiusR, double x, double y, double z){&lt;br /&gt;        radius = radiusR;&lt;br /&gt;        xCenter = x;&lt;br /&gt;        yCenter = y;&lt;br /&gt;        zCenter = z;&lt;br /&gt;       &lt;br /&gt;        //increment instance of sphere&lt;br /&gt;        ++count;&lt;br /&gt;    }&lt;br /&gt;    //number of objects&lt;br /&gt;    static int getCount(){&lt;br /&gt;        return count;&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    //compute volume of sphere&lt;br /&gt;    static double getVolume(){&lt;br /&gt;        return 4.0/3.0*Math.PI*Math.pow(radius,3);&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-1886434712321109304?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/1886434712321109304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=1886434712321109304' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1886434712321109304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1886434712321109304'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/sphere.html' title='Sphere'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-3686563598241421086</id><published>2007-04-04T00:57:00.000-07:00</published><updated>2007-04-04T01:04:49.007-07:00</updated><title type='text'>Employee Tracking System(with image)</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_fKXlq2YJyKk/RhNaoAHmW_I/AAAAAAAAAA4/yQRaLpix448/s1600-h/employee.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_fKXlq2YJyKk/RhNaoAHmW_I/AAAAAAAAAA4/yQRaLpix448/s320/employee.jpg" alt="" id="BLOGGER_PHOTO_ID_5049479250485599218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.lancestreetcity.com"&gt;www.lancestreetcity.com&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;You may also download the complete source files at &lt;a href="http://www.pscode.com"&gt;pscode.com&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;/*&lt;br /&gt;*Project:employee.java&lt;br /&gt;*Date:April 04,2007.&lt;br /&gt;*Purpose:To All Java Developers&lt;br /&gt;**/&lt;br /&gt;&lt;br /&gt;package frm.employee;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import java.sql.*;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; public class employee extends JFrame implements ActionListener&lt;br /&gt; {&lt;br /&gt;      JTextField txtID,txtFirstName,txtLastName,txtAddress;&lt;br /&gt;      JButton cmdAdd,cmdSave,cmdSearch,cmdDelete,cmdEdit,cmdClose;&lt;br /&gt;      JComboBox cboGender;&lt;br /&gt;    &lt;br /&gt;      String url="jdbc:odbc:employee";&lt;br /&gt;      String driver="sun.jdbc.odbc.JdbcOdbcDriver";&lt;br /&gt;      Connection connection;&lt;br /&gt;      Statement statement;&lt;br /&gt;      ResultSet rs;&lt;br /&gt;    &lt;br /&gt;      JLabel ImageLabel;&lt;br /&gt;    String imagename = "me_new.jpg";&lt;br /&gt;    ImageIcon ii = new ImageIcon(imagename);&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;        public employee()&lt;br /&gt;        {&lt;br /&gt;              setTitle("Employee Tracking System");&lt;br /&gt;              setBounds(140,150,520,300);&lt;br /&gt;              setVisible(true);&lt;br /&gt;              init();&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;         void init()&lt;br /&gt;         {&lt;br /&gt;              Container c=this.getContentPane();&lt;br /&gt;              this.setLayout(null);&lt;br /&gt;            &lt;br /&gt;              JLabel mainTitle=new JLabel("Employee Tracking System");&lt;br /&gt;              c.add(mainTitle).setBounds(150,3,260,24);&lt;br /&gt;              mainTitle.setFont(new Font("Verdana",Font.BOLD,14));&lt;br /&gt;            &lt;br /&gt;              ImageLabel=new JLabel(" ", ii ,JLabel.CENTER);//---default image&lt;br /&gt;              c.add(ImageLabel).setBounds(340,30,150,130);&lt;br /&gt;            ImageLabel.setFont(new Font("Verdana",Font.PLAIN,13));&lt;br /&gt;               ImageLabel.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED) );&lt;br /&gt;   &lt;br /&gt;            &lt;br /&gt;              JLabel t1=new JLabel("EmpID");&lt;br /&gt;              c.add(t1).setBounds(10,50,100,24); &lt;br /&gt;             &lt;br /&gt;              JLabel t2=new JLabel("FirstName");&lt;br /&gt;              c.add(t2).setBounds(10,80,100,24); &lt;br /&gt;             &lt;br /&gt;              JLabel t3=new JLabel("LastName");&lt;br /&gt;              c.add(t3).setBounds(10,110,100,24); &lt;br /&gt;            &lt;br /&gt;              JLabel t4=new JLabel("Address");&lt;br /&gt;              c.add(t4).setBounds(10,140,100,24); &lt;br /&gt;            &lt;br /&gt;             &lt;br /&gt;              txtID=new JTextField(10);&lt;br /&gt;              c.add(txtID).setBounds(100,50,140,24);&lt;br /&gt;              txtID.addActionListener(this);&lt;br /&gt;                               &lt;br /&gt;              txtFirstName=new JTextField(10);&lt;br /&gt;              c.add(txtFirstName).setBounds(100,80,170,24);&lt;br /&gt;                               &lt;br /&gt;              txtLastName=new JTextField(10);&lt;br /&gt;              c.add(txtLastName).setBounds(100,110,170,24);&lt;br /&gt;                               &lt;br /&gt;            txtAddress=new JTextField(10);&lt;br /&gt;              c.add(txtAddress).setBounds(100,140,240,24);&lt;br /&gt;        &lt;br /&gt;      &lt;br /&gt;            cmdAdd=new JButton("Add");&lt;br /&gt;            c.add(cmdAdd).setBounds(10,240,80,24);&lt;br /&gt;            cmdAdd.addActionListener(this);&lt;br /&gt;          &lt;br /&gt;            cmdSave=new JButton("Save");&lt;br /&gt;            c.add(cmdSave).setBounds(90,240,80,24);&lt;br /&gt;            cmdSave.addActionListener(this);&lt;br /&gt;          &lt;br /&gt;            cmdSearch=new JButton("Search");&lt;br /&gt;            c.add(cmdSearch).setBounds(170,240,80,24);&lt;br /&gt;            cmdSearch.addActionListener(this);&lt;br /&gt;          &lt;br /&gt;            cmdDelete=new JButton("Delete");&lt;br /&gt;            c.add(cmdDelete).setBounds(250,240,80,24);&lt;br /&gt;            cmdDelete.addActionListener(this);&lt;br /&gt;          &lt;br /&gt;            cmdClose=new JButton("Edit");&lt;br /&gt;            c.add(cmdClose).setBounds(330,240,80,24);&lt;br /&gt;            cmdClose.addActionListener(this);&lt;br /&gt;          &lt;br /&gt;  &lt;br /&gt;            cmdEdit=new JButton("Close");&lt;br /&gt;            c.add(cmdEdit).setBounds(400,240,80,24);&lt;br /&gt;            cmdEdit.addActionListener(this);&lt;br /&gt;                                 &lt;br /&gt;         }&lt;br /&gt;       //---Save        &lt;br /&gt;         public void onSave()&lt;br /&gt;         {&lt;br /&gt;            try&lt;br /&gt;                 {&lt;br /&gt;                    Class.forName(driver);&lt;br /&gt;                    connection=DriverManager.getConnection(url);&lt;br /&gt;                    statement=connection.createStatement();&lt;br /&gt;                    String query="INSERT INTO employee(EmployeeID,FirstName,LastName,Address)VALUES('"+txtID.getText()+"','"+txtFirstName.getText()+"','"+txtLastName.getText()+"','"+txtAddress.getText()+"')";&lt;br /&gt;                    statement.executeUpdate(query);&lt;br /&gt;                    }&lt;br /&gt;                    catch(ClassNotFoundException c)&lt;br /&gt;                    {&lt;br /&gt;                         System.err.println(c);&lt;br /&gt;                    }&lt;br /&gt;                    catch(SQLException sql)&lt;br /&gt;                    {&lt;br /&gt;                         System.err.println(sql);&lt;br /&gt;                    }&lt;br /&gt;        }&lt;br /&gt;         //--Search&lt;br /&gt;       &lt;br /&gt;         public void onSearch()&lt;br /&gt;         {&lt;br /&gt;            try&lt;br /&gt;                 {&lt;br /&gt;                    Class.forName(driver);&lt;br /&gt;                    connection=DriverManager.getConnection(url);&lt;br /&gt;                    statement=connection.createStatement();&lt;br /&gt;                    String query="SELECT EmployeeID,FirstName,LastName,Address,Photo FROM employee WHERE EmployeeID='"+txtID.getText()+"'";&lt;br /&gt;                    rs=statement.executeQuery(query);&lt;br /&gt;                  &lt;br /&gt;                    rs.next();&lt;br /&gt;                  &lt;br /&gt;                    txtID.setText(rs.getString(1));&lt;br /&gt;                    txtFirstName.setText(rs.getString(2));&lt;br /&gt;                    txtLastName.setText(rs.getString(3));&lt;br /&gt;                    txtAddress.setText(rs.getString(4));&lt;br /&gt;                  &lt;br /&gt;                     String image=rs.getString(5);&lt;br /&gt;                    //ImageLabel.setText(image);&lt;br /&gt;                  &lt;br /&gt;                    ImageLabel.setIcon(new ImageIcon(image));    &lt;br /&gt; &lt;br /&gt;                    }&lt;br /&gt;                    catch(ClassNotFoundException c)&lt;br /&gt;                    {&lt;br /&gt;                         System.err.println(c);&lt;br /&gt;                    }&lt;br /&gt;                    catch(SQLException sql)&lt;br /&gt;                    {&lt;br /&gt;                         //System.err.println(sql);&lt;br /&gt;                    JOptionPane.showMessageDialog(null,"Record Not Found","No Record found",JOptionPane.WARNING_MESSAGE);&lt;br /&gt;                    }&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;       &lt;br /&gt;       &lt;br /&gt;         public void actionPerformed(ActionEvent e)&lt;br /&gt;         {&lt;br /&gt;              Object source=e.getSource();&lt;br /&gt;                   if(source==cmdSave)&lt;br /&gt;                   {&lt;br /&gt;                       onSave();&lt;br /&gt;                   }&lt;br /&gt;                   if(source==txtID)&lt;br /&gt;                   {&lt;br /&gt;                       onSearch();&lt;br /&gt;                   }      &lt;br /&gt;            &lt;br /&gt;         }&lt;br /&gt;       &lt;br /&gt; }//End of Class&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-3686563598241421086?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/3686563598241421086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=3686563598241421086' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3686563598241421086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3686563598241421086'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/employee-tracking-systemwith-image.html' title='Employee Tracking System(with image)'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_fKXlq2YJyKk/RhNaoAHmW_I/AAAAAAAAAA4/yQRaLpix448/s72-c/employee.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-9204673531462102040</id><published>2007-04-03T01:13:00.000-07:00</published><updated>2007-04-03T01:21:22.245-07:00</updated><title type='text'>Introduction to JDBC</title><content type='html'>&lt;p&gt;&lt;b&gt;JDBC&lt;/b&gt; is an &lt;a href="http://en.wikipedia.org/wiki/Application_programming_interface" title="Application programming interface"&gt;API&lt;/a&gt; for the &lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29" title="Java (programming language)"&gt;Java programming language&lt;/a&gt; that defines how a client may access a &lt;a href="http://en.wikipedia.org/wiki/Database" title="Database"&gt;database&lt;/a&gt;. It provides methods for querying and updating data in a database. JDBC is oriented towards &lt;a href="http://en.wikipedia.org/wiki/Relational_database_management_system" title="Relational database management system"&gt;relational databases&lt;/a&gt;.&lt;/p&gt; The &lt;a href="http://en.wikipedia.org/wiki/Java_Platform%2C_Standard_Edition" title="Java Platform, Standard Edition"&gt;Java Platform, Standard Edition&lt;/a&gt; includes the JDBC API together with an &lt;a href="http://en.wikipedia.org/wiki/Open_database_connectivity" title="Open database connectivity"&gt;ODBC&lt;/a&gt; implementation of the API enabling connections to any relational database that supports &lt;a href="http://en.wikipedia.org/wiki/Open_database_connectivity" title="Open database connectivity"&gt;ODBC&lt;/a&gt;. This driver is &lt;a href="http://en.wikipedia.org/wiki/Native_code" title="Native code"&gt;native code&lt;/a&gt; and not Java, and is &lt;a href="http://en.wikipedia.org/wiki/Closed_source" title="Closed source"&gt;closed source&lt;/a&gt;।&lt;br /&gt;&lt;br /&gt;&lt;p&gt;JDBC has been part of the Java Standard Edition since the release of JDK 1.1. The JDBC classes are contained in the &lt;a href="http://en.wikipedia.org/wiki/Java_package" title="Java package"&gt;Java package&lt;/a&gt; &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/package-summary.html" rel="nofollow"&gt;java.sql&lt;/a&gt;&lt;/code&gt;. Starting with version 3.0, JDBC has been developed under the &lt;a href="http://en.wikipedia.org/wiki/Java_Community_Process" title="Java Community Process"&gt;Java Community Process&lt;/a&gt;. JSR 54 specifies JDBC 3.0 (included in J2SE 1.4), JSR 114 specifies the JDBC Rowset additions, and JSR 221 is the specification of JDBC 4.0 (included in Java SE 6).&lt;/p&gt; &lt;p&gt;JDBC allows multiple implementations to exist and be used by the same application. The API provides a mechanism for dynamically loading the correct Java packages and registering them with the JDBC Driver Manager. The Driver Manager is used as a connection factory for creating JDBC connections.&lt;/p&gt; &lt;p&gt;JDBC connections support creating and executing statements. These statements may be update statements such as &lt;a href="http://en.wikipedia.org/wiki/SQL" title="SQL"&gt;SQL&lt;/a&gt; CREATE, INSERT, UPDATE and DELETE or they may be query statements using the SELECT statement. Additionally, stored procedures may be invoked through a statement. Statements are one of the following types:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/Statement.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/Statement.html" rel="nofollow"&gt;Statement&lt;/a&gt;&lt;/code&gt; – the statement is sent to the database server each and every time.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html" rel="nofollow"&gt;PreparedStatement&lt;/a&gt;&lt;/code&gt; – the statement is cached and then the execution path is pre determined on the database server allowing it to be executed multiple times in an efficient manner.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html" rel="nofollow"&gt;CallableStatement&lt;/a&gt;&lt;/code&gt; – used for executing stored procedures on the database.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Update statements such as INSERT, UPDATE and DELETE return an update count that indicates how many rows were affected in the database. These statements do not return any other information.&lt;/p&gt; &lt;p&gt;Query statements return a JDBC row result set. The row result set is used to walk over the result set. Individual columns in a row are retrieved either by name or by column number. There may be any number of rows in the result set. The row result set has metadata that describes the names of the columns and their types.&lt;/p&gt; &lt;p&gt;There is an extension to the basic JDBC API in the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/sql/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/sql/package-summary.html" rel="nofollow"&gt;javax.sql&lt;/a&gt;&lt;/code&gt; package that allows for scrollable result sets and cursor support among other things.&lt;/p&gt; &lt;p&gt;&lt;a name="Example" id="Example"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The method &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#forName%28java.lang.String%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#forName(java.lang.String)" rel="nofollow"&gt;Class.forName(String)&lt;/a&gt;&lt;/code&gt; is used to load the JDBC driver class. The line below causes the JDBC driver from &lt;i&gt;some jdbc vendor&lt;/i&gt; to be loaded into the application. (Some JVMs also require the class to be instantiated with &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#newInstance%28%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#newInstance()" rel="nofollow"&gt;.newInstance()&lt;/a&gt;&lt;/code&gt;.)&lt;/p&gt; &lt;pre&gt;Class.forName( "com.somejdbcvendor.TheirJdbcDriver" );&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;When a &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/Driver.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/Driver.html" rel="nofollow"&gt;Driver&lt;/a&gt;&lt;/code&gt; class is loaded, it creates an instance of itself and registers it with the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/DriverManager.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/DriverManager.html" rel="nofollow"&gt;DriverManager&lt;/a&gt;&lt;/code&gt;. This can be done by including the needed code in the driver class's &lt;code&gt;static&lt;/code&gt; block. e.g. &lt;code&gt;DriverManager.registerDriver(Driver driver)&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Now when a connection is needed, one of the &lt;code&gt;DriverManager.getConnection()&lt;/code&gt; methods is used to create a JDBC connection.&lt;/p&gt; &lt;pre&gt;Connection conn = DriverManager.getConnection(&lt;br /&gt;    "jdbc:somejdbcvendor:other data needed by some jdbc vendor",&lt;br /&gt;    "myLogin",&lt;br /&gt;    "myPassword" );&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;The URL used is dependent upon the particular JDBC driver. It will always begin with the "jdbc:" protocol, but the rest is up to the particular vendor. Once a connection is established, a statement must be created.&lt;/p&gt; &lt;pre&gt;Statement stmt = conn.createStatement();&lt;br /&gt;try {&lt;br /&gt;   stmt.executeUpdate( "INSERT INTO MyTable( name ) VALUES ( 'my name' ) " );&lt;br /&gt;} finally {&lt;br /&gt;   //It's important to close the statement when you are done with it&lt;br /&gt;   stmt.close();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Note that connections, statements, and resultsets often tie up &lt;a href="http://en.wikipedia.org/wiki/Operating_system" title="Operating system"&gt;operating system&lt;/a&gt; resources such as sockets or file descriptors. In the case of connections to remote database servers, further resources are tied up on the server, eg. cursors for currently open resultsets. It is vital to &lt;code&gt;close()&lt;/code&gt; any JDBC object as soon as it has played its part; garbage collection shall not be relied upon. Forgetting to &lt;code&gt;close()&lt;/code&gt; things properly results in spurious errors and misbehaviour. The above try-finally construct is a recommended code pattern to use with JDBC objects.&lt;/p&gt; &lt;p&gt;Data is retrieved from the database using a database query mechanism. The example below shows creating a statement and executing a query.&lt;/p&gt; &lt;pre&gt;Statement stmt = conn.createStatement();&lt;br /&gt;try {&lt;br /&gt;   ResultSet rs = stmt.executeQuery( "SELECT * FROM MyTable" );&lt;br /&gt;   try {&lt;br /&gt;       while ( rs.next() ) {&lt;br /&gt;           int numColumns = rs.getMetaData().getColumnCount();&lt;br /&gt;           for ( int i = 1 ; i &lt;= numColumns ; i++ ) {&lt;br /&gt;              //Column numbers start at 1.&lt;br /&gt;              //Also there are many methods on the result set to return&lt;br /&gt;              // the column as a particular type. Refer to the Sun documentation&lt;br /&gt;              // for the list of valid conversions.&lt;br /&gt;              System.out.println( "COLUMN " + i + " = " + rs.getObject(i) );&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;   } finally {&lt;br /&gt;       rs.close();&lt;br /&gt;   }&lt;br /&gt;} finally {&lt;br /&gt;   stmt.close();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Typically, however, it would be rare for a seasoned Java programmer to code in such a fashion. The usual practice would be to abstract the database logic into an entirely different class and to pass preprocessed strings (perhaps derived themselves from a further abstracted class) containing SQL statements and the connection to the required methods. Abstracting the data model from the application code makes it more likely that changes to the application and data model can be made independently.&lt;/p&gt; &lt;p&gt;An example of a &lt;code&gt;PreparedStatement&lt;/code&gt; query. Using &lt;code&gt;conn&lt;/code&gt; and class from first example.&lt;/p&gt; &lt;pre&gt;   PreparedStatement ps = conn.prepareStatement( "SELECT i.*, j.* FROM Omega i, Zappa j"&lt;br /&gt;    + "WHERE i = ? AND j = ?" );&lt;br /&gt;  try {&lt;br /&gt;    // In the prepared statement ps, the question mark denotes variable input,&lt;br /&gt;    // which can be passed through a parameter list, for example.&lt;br /&gt;    // The following replaces the question marks,&lt;br /&gt;    // with the string or int, before sending it to SQL.&lt;br /&gt;    // The first parameter corresponds to the first occurrence of the ?,&lt;br /&gt;    // the second parameter tells Java to replace it with&lt;br /&gt;    // the second item.&lt;br /&gt;    // The nth parameter corresponds to the nth ?&lt;br /&gt;    ps.setString(1, "Poor Yorick");&lt;br /&gt;    ps.setInt(2, 8008);&lt;br /&gt;    // The ResultSet rs, receives the SQL Query response.&lt;br /&gt;    ResultSet rs = ps.executeQuery();&lt;br /&gt;    try {&lt;br /&gt;      while ( rs.next() ) {&lt;br /&gt;        int numColumns = rs.getMetaData().getColumnCount();&lt;br /&gt;        for ( int i = 1 ; i &lt;= numColumns ; i++ ) {&lt;br /&gt;          //Column numbers start at 1.&lt;br /&gt;          //Also there are many methods on the result set to return&lt;br /&gt;          // the column as a particular type. Refer to the Sun documentation&lt;br /&gt;          // for the list of valid conversions.&lt;br /&gt;          System.out.println( "COLUMN " + i + " = " + rs.getObject(i) );&lt;br /&gt;        } // for&lt;br /&gt;      } // while&lt;br /&gt;    } finally {&lt;br /&gt;      rs.close();&lt;br /&gt;    }&lt;br /&gt;  } finally {&lt;br /&gt;    ps.close;&lt;br /&gt;  } // try&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;When a database operation fails, an &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html" rel="nofollow"&gt;SQLException&lt;/a&gt;&lt;/code&gt; is raised. There is typically very little one could do to recover from such an error, apart from logging it with as much detail as possible. It is recommended that the SQLException be translated into an application domain exception (an unchecked one) that eventually results in a transaction rollback and a notification to the user.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Here are examples of host database types, Java can convert to with a function&lt;/b&gt;. &lt;/p&gt; &lt;p&gt;&lt;tt&gt;&lt;span&gt;setXXX()&lt;/span&gt;&lt;/tt&gt;Methods&lt;/p&gt; &lt;table border="1" cellpadding="3" cellspacing="0"&gt; &lt;tbody&gt;&lt;tr class="FormalW"&gt; &lt;th class="FormalW" align="left" valign="top"&gt;&lt;b&gt;&lt;span style="font-family:Arial, Helvetica, sans-serif;"&gt;Oracle Datatype&lt;/span&gt;&lt;/b&gt;&lt;/th&gt; &lt;th class="FormalW" align="left" valign="bottom"&gt;&lt;b&gt;&lt;span style="font-family:Arial, Helvetica, sans-serif;"&gt;setXXX()&lt;/span&gt;&lt;/b&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;CHAR &lt;/div&gt; &lt;/td&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setString()&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;VARCHAR2 &lt;/div&gt; &lt;/td&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setString()&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td rowspan="8" class="FormalW"&gt; &lt;div class="TB"&gt;NUMBER &lt;/div&gt; &lt;/td&gt; &lt;td class="FormalW"&gt;setBigDecimal()&lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setBoolean() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setByte() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setShort() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setInt() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setLong() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setFloat() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setDouble()&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt;INTEGER&lt;/td&gt; &lt;td class="FormalW"&gt;setInt()&lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt;FLOAT&lt;/td&gt; &lt;td class="FormalW"&gt;setDouble() &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt;CLOB&lt;/td&gt; &lt;td class="FormalW"&gt;setClob() &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt;BLOB&lt;/td&gt; &lt;td class="FormalW"&gt;setBlob() &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;RAW&lt;/div&gt; &lt;/td&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setBytes()&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;LONGRAW &lt;/div&gt; &lt;/td&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setBytes() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td rowspan="3" class="FormalW"&gt; &lt;div class="TB"&gt;DATE &lt;/div&gt; &lt;/td&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setDate() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setTime() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="FormalW" align="left" valign="top"&gt; &lt;td class="FormalW"&gt; &lt;div class="TB"&gt;setTimestamp() &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;For an example of a &lt;code&gt;CallableStatement&lt;/code&gt; (to call stored procedures in the database), see the &lt;a href="http://java.sun.com/javase/6/docs/technotes/guides/jdbc/getstart/callablestatement.html" class="external text" title="http://java.sun.com/javase/6/docs/technotes/guides/jdbc/getstart/callablestatement.html" rel="nofollow"&gt;JDBC API Guide&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name="Drivers" id="Drivers"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Drivers are client-side adaptors (they are installed in the client machine, not in the server) that convert requests from Java programs to a protocol that the DBMS can understand.&lt;/p&gt; &lt;p&gt;&lt;a name="Types" id="Types"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There are commercial and free drivers available for most relational database servers. These drivers fall into one of the following types:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JDBC_type_1_driver" title="JDBC type 1 driver"&gt;Type 1&lt;/a&gt;, the JDBC-ODBC bridge&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JDBC_type_2_driver" title="JDBC type 2 driver"&gt;Type 2&lt;/a&gt;, the Native-API driver&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JDBC_type_3_driver" title="JDBC type 3 driver"&gt;Type 3&lt;/a&gt;, the network-protocol driver&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JDBC_type_4_driver" title="JDBC type 4 driver"&gt;Type 4&lt;/a&gt;, the native-protocol drivers&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Internal_JDBC_driver&amp;action=edit" class="new" title="Internal JDBC driver"&gt;Internal JDBC driver&lt;/a&gt;, driver embedded with JRE in Java-enabled SQL databases. Used for Java stored procedures.&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=JDBC_URL&amp;amp;action=edit" class="new" title="JDBC URL"&gt;JDBC URL&lt;/a&gt;, all Database Connection String&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name="Sources" id="Sources"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.sqlsummit.com/JDBCVend.htm" class="external text" title="http://www.SQLSummit.com/JDBCVend.htm" rel="nofollow"&gt;SQLSummit.com&lt;/a&gt; publishes list of drivers, including JDBC drivers and vendors&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Sun_Microsystems" title="Sun Microsystems"&gt;Sun Microsystems&lt;/a&gt; provides a &lt;a href="http://servlet.java.sun.com/products/jdbc/drivers" class="external text" title="http://servlet.java.sun.com/products/jdbc/drivers" rel="nofollow"&gt;list of some JDBC drivers and vendors&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Simba_Technologies" title="Simba Technologies"&gt;Simba Technologies&lt;/a&gt; ships an SDK for building custom JDBC Drivers for any custom/proprietary relational data source&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.datadirect.com/products/jdbc/index.ssp" class="external text" title="http://www.datadirect.com/products/jdbc/index.ssp" rel="nofollow"&gt;DataDirect Technologies&lt;/a&gt; provides a comprehensive suite of fast Type 4 JDBC drivers for all major database&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.idssoftware.com/idsserver.html" class="external text" title="http://www.idssoftware.com/idsserver.html" rel="nofollow"&gt;IDS Software&lt;/a&gt; provides a Type 3 JDBC driver for concurrent access to all major databases. Supported features include resultset caching, SSL encryption, custom data source, dbShield.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.inetsoftware.de/products/jdbc/" class="external text" title="http://www.inetsoftware.de/products/jdbc/" rel="nofollow"&gt;i-net software&lt;/a&gt; provides fast Type 4 JDBC drivers for all major databases&lt;/li&gt;&lt;li&gt;&lt;a href="http://uda.openlinksw.com/jdbc/" class="external text" title="http://uda.openlinksw.com/jdbc/" rel="nofollow"&gt;OpenLink Software&lt;/a&gt; ships JDBC Drivers for a number of target databases, including Bridges to other data access mechanisms (e.g., ODBC, JDBC) which can provide more functionality than the targeted mechanism&lt;/li&gt;&lt;li&gt;&lt;a href="http://jdbaccess.com/" class="external text" title="http://jdbaccess.com/" rel="nofollow"&gt;JDBaccess&lt;/a&gt; is a Java persistence library for &lt;a href="http://en.wikipedia.org/wiki/MySQL" title="MySQL"&gt;MySQL&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Oracle" title="Oracle"&gt;Oracle&lt;/a&gt; which defines major database access operations in an easy usable API above JDBC&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name="External_links" id="External_links"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;a href="http://www.jdbc-tutorial.com/" class="external text" title="http://www.jdbc-tutorial.com" rel="nofollow"&gt;JDBC Tutorial&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://java.sun.com/javase/6/docs/technotes/guides/jdbc" class="external text" title="http://java.sun.com/javase/6/docs/technotes/guides/jdbc" rel="nofollow"&gt;JDBC API Guide&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/sql/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/sql/package-summary.html" rel="nofollow"&gt;java.sql&lt;/a&gt;&lt;/code&gt; API &lt;a href="http://en.wikipedia.org/wiki/Javadoc" title="Javadoc"&gt;Javadoc&lt;/a&gt; documentation&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/sql/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/sql/package-summary.html" rel="nofollow"&gt;javax.sql&lt;/a&gt;&lt;/code&gt; API Javadoc documentation&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.datadirect.com/knowledgebase/kbase.nsf/Code+Samples?OpenView&amp;RestrictToCategory=Connect+for+JDBC" class="external text" title="http://www.datadirect.com/knowledgebase/kbase.nsf/Code+Samples?OpenView&amp;amp;RestrictToCategory=Connect+for+JDBC" rel="nofollow"&gt;DataDirect Technologies - JDBC Code Samples&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://java.sun.com/docs/books/tutorial/jdbc/" class="external text" title="http://java.sun.com/docs/books/tutorial/jdbc/" rel="nofollow"&gt;Sun tutorial&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://java.sun.com/developer/technicalArticles//Database/dukesbakery/" class="external text" title="http://java.sun.com/developer/technicalArticles//Database/dukesbakery/" rel="nofollow"&gt;Duke's Bakery - A JDBC Order Entry Prototype&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://java.sun.com/developer/technicalArticles//Database/dbaccessor/" class="external text" title="http://java.sun.com/developer/technicalArticles//Database/dbaccessor/" rel="nofollow"&gt;DBAccessor: A JDBC Wrapper Package&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://java-source.net/open-source/database-engines" class="external text" title="http://java-source.net/open-source/database-engines" rel="nofollow"&gt;List of Java Open Source Databases with JDBC drivers&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://docs.maggi.cc/my_thesis_polijdbc.pdf" class="external text" title="http://docs.maggi.cc/my_thesis_polijdbc.pdf" rel="nofollow"&gt;A sample implementation of a tiny-JDBC layer for an embedded DBMS&lt;/a&gt; (PDF) by Federico Maggi (Introduction in both Italian and English: Other chapters in English)&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.easysoft.com/developer/interfaces/jdbc/index.html" class="external text" title="http://www.easysoft.com/developer/interfaces/jdbc/index.html" rel="nofollow"&gt;JDBC Articles and Resources&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.alnaja7.org/Programmer/393/JDBC/jdbc.htm" class="external text" title="http://www.alnaja7.org/Programmer/393/JDBC/jdbc.htm" rel="nofollow"&gt;Useful site for JDBC using Derby&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://bottomline.sourceforge.net/" class="external text" title="http://bottomline.sourceforge.net" rel="nofollow"&gt;Dynamic loading of JDBC drivers directly from JAR files using custom class loader&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Scriptella" title="Scriptella"&gt;Scriptella ETL&lt;/a&gt; Open source &lt;a href="http://en.wikipedia.org/wiki/Extract_transform_load" title="Extract transform load"&gt;ETL (Extract-Transform-Load)&lt;/a&gt; and script execution tool. Written in Java and supports any JDBC compliant driver.&lt;/li&gt;&lt;li&gt;&lt;a href="http://developers.sun.com/product/jdbc/drivers" class="external text" title="http://developers.sun.com/product/jdbc/drivers" rel="nofollow"&gt;Sun's list of available JDBC drivers&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-9204673531462102040?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/9204673531462102040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=9204673531462102040' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/9204673531462102040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/9204673531462102040'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/04/jdbc.html' title='Introduction to JDBC'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-7508729362849809515</id><published>2007-03-25T21:42:00.000-07:00</published><updated>2007-03-25T21:45:41.785-07:00</updated><title type='text'>How to use JFrame in Java</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: arial;"&gt; //Using JFrame in Java&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;      import javax.swing.JFrame;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;           public class myWindow extends JFrame&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;          {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                    public static void main(String args[]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                          new myWindow();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                    public myWindow()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                     display();                    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                         void display()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                          setBounds(x1,y1,x2,y2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                         setVisible(true);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-7508729362849809515?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/7508729362849809515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=7508729362849809515' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/7508729362849809515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/7508729362849809515'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/how-to-use-jframe-in-java.html' title='How to use JFrame in Java'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4723741626481602614</id><published>2007-03-25T20:09:00.000-07:00</published><updated>2007-03-25T20:11:40.232-07:00</updated><title type='text'>How to use JOptionPane</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: arial;"&gt;//call class JOptionPane&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;     import javax.swing.JOptionPane&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;          public class MyPane&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;          {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;               public static void main(String args[]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;               {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                      JOptionPane.showMessageDialog(null,"Welcome to         JOptionPane","JOptionPane",JOptionPane.INFORMATION_MESSAGE);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;               }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;             &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;          }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                   &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4723741626481602614?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4723741626481602614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4723741626481602614' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4723741626481602614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4723741626481602614'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/how-to-use-joptionpane.html' title='How to use JOptionPane'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-1186221798253617690</id><published>2007-03-22T18:35:00.001-07:00</published><updated>2007-03-22T18:38:45.167-07:00</updated><title type='text'>Java Runtime Environment</title><content type='html'>The &lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Runtime_Environment" title="Java Runtime Environment"&gt;Java Runtime Environment&lt;/a&gt;&lt;/b&gt; or &lt;b&gt;JRE&lt;/b&gt; is the software required to run any &lt;a href="http://en.wikipedia.org/wiki/Application_software" title="Application software"&gt;application&lt;/a&gt; deployed on the Java Platform. &lt;a href="http://en.wikipedia.org/wiki/End-user" title="End-user"&gt;End-users&lt;/a&gt; commonly use a JRE in &lt;a href="http://en.wikipedia.org/wiki/Software_package" title="Software package"&gt;software packages&lt;/a&gt; and Web browser &lt;a href="http://en.wikipedia.org/wiki/Plugin" title="Plugin"&gt;plugins&lt;/a&gt;. Sun also distributes a superset of the JRE called the Java 2 &lt;a href="http://en.wikipedia.org/wiki/SDK" title="SDK"&gt;SDK&lt;/a&gt; (more commonly known as the JDK), which includes development tools such as the &lt;a href="http://en.wikipedia.org/wiki/Java_compiler" title="Java compiler"&gt;Java compiler&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Javadoc" title="Javadoc"&gt;Javadoc&lt;/a&gt;, and &lt;a href="http://en.wikipedia.org/wiki/Debugger" title="Debugger"&gt;debugger&lt;/a&gt;. &lt;p&gt;&lt;a name="Components" id="Components"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4&gt;&lt;span class="editsection"&gt;&lt;/span&gt; &lt;span class="mw-headline"&gt;Components&lt;/span&gt;&lt;/h4&gt; &lt;ul&gt;&lt;li&gt;Java &lt;a href="http://en.wikipedia.org/wiki/Library_%28computer_science%29" title="Library (computer science)"&gt;libraries&lt;/a&gt; are the compiled &lt;a href="http://en.wikipedia.org/wiki/Byte_code" title="Byte code"&gt;byte codes&lt;/a&gt; of &lt;a href="http://en.wikipedia.org/wiki/Source_code" title="Source code"&gt;source code&lt;/a&gt; developed by the JRE implementor to support application development in Java. Examples of these libraries are: &lt;ul&gt;&lt;li&gt;The core libraries, which include: &lt;ul&gt;&lt;li&gt;Collection libraries which implement &lt;a href="http://en.wikipedia.org/wiki/Data_structure" title="Data structure"&gt;data structures&lt;/a&gt; such as &lt;a href="http://en.wikipedia.org/wiki/List_%28computing%29" title="List (computing)"&gt;lists&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Associative_array" title="Associative array"&gt;dictionaries&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Tree_structure" title="Tree structure"&gt;trees&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Set_%28computer_science%29" title="Set (computer science)"&gt;sets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/XML" title="XML"&gt;XML&lt;/a&gt; Processing (Parsing, Transforming, Validating) libraries&lt;/li&gt;&lt;li&gt;Security&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/I18n" title="I18n"&gt;Internationalization and localization&lt;/a&gt; libraries&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;The integration libraries, which allow the application writer to communicate with external systems. These libraries include: &lt;ul&gt;&lt;li&gt;The &lt;a href="http://en.wikipedia.org/wiki/Java_Database_Connectivity" title="Java Database Connectivity"&gt;Java Database Connectivity&lt;/a&gt; (JDBC) &lt;a href="http://en.wikipedia.org/wiki/Application_Programming_Interface" title="Application Programming Interface"&gt;API&lt;/a&gt; for database access&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Naming_and_Directory_Interface" title="Java Naming and Directory Interface"&gt;Java Naming and Directory Interface&lt;/a&gt; (JNDI) for lookup and discovery&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_remote_method_invocation" title="Java remote method invocation"&gt;RMI&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/CORBA" title="CORBA"&gt;CORBA&lt;/a&gt; for distributed application development&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/User_Interface" title="User Interface"&gt;User Interface&lt;/a&gt; libraries, which include: &lt;ul&gt;&lt;li&gt;The (heavyweight, or &lt;a href="http://en.wikipedia.org/wiki/Native_mode" title="Native mode"&gt;native&lt;/a&gt;) &lt;a href="http://en.wikipedia.org/wiki/Abstract_Windowing_Toolkit" title="Abstract Windowing Toolkit"&gt;Abstract Windowing Toolkit&lt;/a&gt; (AWT), which provides &lt;a href="http://en.wikipedia.org/wiki/Graphical_user_interface" title="Graphical user interface"&gt;GUI&lt;/a&gt; components, the means for laying out those components and the means for handling events from those components&lt;/li&gt;&lt;li&gt;The (lightweight) &lt;a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" title="Swing (Java)"&gt;Swing&lt;/a&gt; libraries, which are built on AWT but provide (non-native) implementations of the AWT widgetry&lt;/li&gt;&lt;li&gt;APIs for audio capture, processing, and playback&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;A platform dependent implementation of &lt;a href="http://en.wikipedia.org/wiki/Java_virtual_machine" title="Java virtual machine"&gt;Java virtual machine&lt;/a&gt; (JVM) which is the means by which the byte codes of the Java libraries and third party applications are executed&lt;/li&gt;&lt;li&gt;Plugins, which enable &lt;a href="http://en.wikipedia.org/wiki/Java_applet" title="Java applet"&gt;applets&lt;/a&gt; to be run in &lt;a href="http://en.wikipedia.org/wiki/Web_browser" title="Web browser"&gt;Web browsers&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Web_Start" title="Java Web Start"&gt;Java Web Start&lt;/a&gt;, which allows Java applications to be efficiently distributed to &lt;a href="http://en.wikipedia.org/wiki/End_user" title="End user"&gt;end users&lt;/a&gt; across the &lt;a href="http://en.wikipedia.org/wiki/Internet" title="Internet"&gt;Internet&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Licensing and documentation&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a name="APIs" id="APIs"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt; &lt;span class="mw-headline"&gt;APIs&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;Sun has defined three platforms targeting different application environments and segmented many of its &lt;a href="http://en.wikipedia.org/wiki/Application_programming_interface" title="Application programming interface"&gt;APIs&lt;/a&gt; so that they belong to one of the platforms. The platforms are:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Platform%2C_Micro_Edition" title="Java Platform, Micro Edition"&gt;Java Platform, Micro Edition&lt;/a&gt; (Java ME) — targeting environments with limited resources,&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Platform%2C_Standard_Edition" title="Java Platform, Standard Edition"&gt;Java Platform, Standard Edition&lt;/a&gt; (Java SE) — targeting workstation environments, and&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Platform%2C_Enterprise_Edition" title="Java Platform, Enterprise Edition"&gt;Java Platform, Enterprise Edition&lt;/a&gt; (Java EE) — targeting large distributed enterprise or Internet environments.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The &lt;a href="http://en.wikipedia.org/wiki/Class_%28computer_science%29" title="Class (computer science)"&gt;classes&lt;/a&gt; in the Java APIs are organized into separate groups called &lt;a href="http://en.wikipedia.org/wiki/Java_package" title="Java package"&gt;packages&lt;/a&gt;. Each package contains a set of related &lt;a href="http://en.wikipedia.org/wiki/Interface_%28Java%29" title="Interface (Java)"&gt;interfaces&lt;/a&gt;, classes and &lt;a href="http://en.wikipedia.org/wiki/Exception_handling" title="Exception handling"&gt;exceptions&lt;/a&gt;. Refer to the separate platforms for a description of the packages available.&lt;/p&gt; &lt;p&gt;The set of APIs is controlled by Sun Microsystems in cooperation with others through the &lt;a href="http://en.wikipedia.org/wiki/Java_Community_Process" title="Java Community Process"&gt;Java Community Process&lt;/a&gt; program. Companies or individuals participating in this process can influence the design and development of the APIs. This process has been a subject of controversy.&lt;/p&gt; &lt;p&gt;&lt;a name="Licensing" id="Licensing"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Licensing&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;In 2004, IBM and BEA publicly supported the notion of creating an official open source implementation of Java. On November 13, 2006, Sun announced that all of the Java source code will be released entirely under a &lt;a href="http://en.wikipedia.org/wiki/Free_software_license" title="Free software license"&gt;free software license&lt;/a&gt;, the &lt;a href="http://en.wikipedia.org/wiki/GNU_General_Public_License" title="GNU General Public License"&gt;GNU General Public License&lt;/a&gt;, by March 2007.&lt;sup id="_ref-9" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-9" title=""&gt;[10]&lt;/a&gt;&lt;/sup&gt; The javac compiler and the hotspot java VM (but not the class library) were released under the GPL on 11 November 2006.&lt;sup id="_ref-10" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-10" title=""&gt;[11]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="Extensions_and_related_architectures" id="Extensions_and_related_architectures"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;span class="editsection"&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Java_%28programming_language%29&amp;action=edit&amp;amp;section=24" title="Edit section: Extensions and related architectures"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class="mw-headline"&gt;Extensions and related architectures&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;The &lt;a href="http://en.wikipedia.org/wiki/Extension_%28computing%29" title="Extension (computing)"&gt;extensions&lt;/a&gt; to standard Java are typically in &lt;code&gt;javax.*&lt;/code&gt; packages. They are not included in the JDK or JRE. Extensions and architectures closely tied to the Java programming language include:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Platform%2C_Enterprise_Edition" title="Java Platform, Enterprise Edition"&gt;Java EE&lt;/a&gt; (previously J2EE) (Java Platform, Enterprise Edition—for distributed enterprise applications)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Platform%2C_Micro_Edition" title="Java Platform, Micro Edition"&gt;Java ME&lt;/a&gt; (previously J2ME) (Java Platform, Micro Edition—for PDAs and cellular phones)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JMF" title="JMF"&gt;JMF&lt;/a&gt; (Java Media Framework)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JNDI" title="JNDI"&gt;JNDI&lt;/a&gt; (Java Naming and Directory Interface)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JSML" title="JSML"&gt;JSML&lt;/a&gt; (Java Speech API Markup Language)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JDBC" title="JDBC"&gt;JDBC&lt;/a&gt; (Java DataBase Connectivity)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Data_Objects" title="Java Data Objects"&gt;JDO&lt;/a&gt; (Java Data Objects)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Advanced_Imaging" title="Java Advanced Imaging"&gt;JAI&lt;/a&gt; (Java Advanced Imaging)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JAIN" title="JAIN"&gt;JAIN&lt;/a&gt; (Java API for Integrated Networks)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JDMK" title="JDMK"&gt;JDMK&lt;/a&gt; (Java Dynamic Management Kit)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Jini" title="Jini"&gt;Jini&lt;/a&gt; (a network architecture for the construction of &lt;a href="http://en.wikipedia.org/wiki/Federated" title="Federated"&gt;federated&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Distributed_system" title="Distributed system"&gt;distributed systems&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Jiro" title="Jiro"&gt;Jiro&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Card" title="Java Card"&gt;Java Card&lt;/a&gt; (Java for &lt;a href="http://en.wikipedia.org/wiki/Smart_cards" title="Smart cards"&gt;smart cards&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JavaSpaces" title="JavaSpaces"&gt;JavaSpaces&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Modeling_Language" title="Java Modeling Language"&gt;JML&lt;/a&gt; (Java Modeling Language)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Metadata_Interface" title="Java Metadata Interface"&gt;JMI&lt;/a&gt; (Java Metadata Interface)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Management_Extensions" title="Java Management Extensions"&gt;JMX&lt;/a&gt; (Java Management Extensions)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JavaServer_Pages" title="JavaServer Pages"&gt;JSP&lt;/a&gt; (JavaServer Pages)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JavaServer_Faces" title="JavaServer Faces"&gt;JSF&lt;/a&gt; (JavaServer Faces)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Native_Interface" title="Java Native Interface"&gt;JNI&lt;/a&gt; (Java Native Interface)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/JXTA" title="JXTA"&gt;JXTA&lt;/a&gt; (Open Protocols for &lt;a href="http://en.wikipedia.org/wiki/Peer-to-Peer" title="Peer-to-Peer"&gt;Peer-to-Peer&lt;/a&gt; (P2P) Virtual Network)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_3D" title="Java 3D"&gt;Java 3D&lt;/a&gt; (A high level API for 3D graphics programming)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_OpenGL" title="Java OpenGL"&gt;JOGL&lt;/a&gt; (Java OpenGL—A low level API for 3D graphics programming, using &lt;a href="http://en.wikipedia.org/wiki/OpenGL" title="OpenGL"&gt;OpenGL&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Lightweight_Java_Game_Library" title="Lightweight Java Game Library"&gt;LWJGL&lt;/a&gt; (Light Weight Java Game Library—A low level API providing access to &lt;a href="http://en.wikipedia.org/wiki/OpenGL" title="OpenGL"&gt;OpenGL&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/OpenAL" title="OpenAL"&gt;OpenAL&lt;/a&gt; and various input devices)&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/OSGi" title="OSGi"&gt;OSGi&lt;/a&gt; (Dynamic Service Management and Remote Maintenance)&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-1186221798253617690?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/1186221798253617690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=1186221798253617690' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1186221798253617690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1186221798253617690'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/java-runtime-environment.html' title='Java Runtime Environment'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8547942198812974153</id><published>2007-03-22T18:28:00.000-07:00</published><updated>2007-03-22T19:52:00.819-07:00</updated><title type='text'>Look and feel</title><content type='html'>&lt;p&gt;The default &lt;a href="http://en.wikipedia.org/wiki/Look_and_feel" title="Look and feel"&gt;look and feel&lt;/a&gt; of &lt;a href="http://en.wikipedia.org/wiki/Graphical_User_Interface" title="Graphical User Interface"&gt;GUI&lt;/a&gt; applications written in Java using the &lt;a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" title="Swing (Java)"&gt;Swing&lt;/a&gt; toolkit is very different from native applications. It is possible to specify a different look and feel through the &lt;a href="http://en.wikipedia.org/wiki/Pluggable_look_and_feel" title="Pluggable look and feel"&gt;pluggable look and feel&lt;/a&gt; system of Swing. Clones of &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Windows" title="Microsoft Windows"&gt;Windows&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/GTK" title="GTK"&gt;GTK&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Motif_%28widget_toolkit%29" title="Motif (widget toolkit)"&gt;Motif&lt;/a&gt; are supplied by Sun. &lt;a href="http://en.wikipedia.org/wiki/Apple_Computer" title="Apple Computer"&gt;Apple&lt;/a&gt; also provides an &lt;a href="http://en.wikipedia.org/wiki/Aqua_%28theme%29" title="Aqua (theme)"&gt;Aqua&lt;/a&gt; look and feel for &lt;a href="http://en.wikipedia.org/wiki/Mac_OS_X" title="Mac OS X"&gt;Mac OS X&lt;/a&gt;. Though prior implementations of these look and feels have been considered lacking, Swing in Java SE 6 addresses this problem by using more native &lt;a href="http://en.wikipedia.org/wiki/Widget_%28computing%29" title="Widget (computing)"&gt;widget&lt;/a&gt; drawing routines of the underlying platforms. Alternatively, third party toolkits such as &lt;a href="http://en.wikipedia.org/wiki/Wx4j" title="Wx4j"&gt;wx4j&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Standard_Widget_Toolkit" title="Standard Widget Toolkit"&gt;SWT&lt;/a&gt; may be used for increased integration with the native windowing system.&lt;/p&gt; &lt;p&gt;&lt;a name="Lack_of_OO_purity" id="Lack_of_OO_purity"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Java's &lt;a href="http://en.wikipedia.org/wiki/Primitive_type" title="Primitive type"&gt;primitive types&lt;/a&gt; are not objects. &lt;a href="http://en.wikipedia.org/wiki/Primitive_type" title="Primitive type"&gt;Primitive types&lt;/a&gt; store their values in the &lt;a href="http://en.wikipedia.org/wiki/Stack-based_memory_allocation" title="Stack-based memory allocation"&gt;stack&lt;/a&gt; rather than being references to values. This was a conscious decision by Java's designers for performance reasons. Because of this, Java is not considered to be a pure object-oriented programming language. However, as of Java 5.0, &lt;a href="http://en.wikipedia.org/wiki/Object_type" title="Object type"&gt;autoboxing&lt;/a&gt; enables programmers to write as if primitive types are their wrapper classes, and freely interchange between them for improved flexibility.&lt;/p&gt; &lt;p&gt;&lt;a name="Single-paradigm_language" id="Single-paradigm_language"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Java is predominantly a single-&lt;a href="http://en.wikipedia.org/wiki/Programming_paradigm" title="Programming paradigm"&gt;paradigm&lt;/a&gt; language. However, with the addition of &lt;i&gt;static imports&lt;/i&gt; in Java 5.0 the &lt;a href="http://en.wikipedia.org/wiki/Procedural_programming" title="Procedural programming"&gt;procedural paradigm&lt;/a&gt; is better accommodated than in earlier versions of Java.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8547942198812974153?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8547942198812974153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8547942198812974153' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8547942198812974153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8547942198812974153'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/look-and-feel.html' title='Look and feel'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-7013366091449584714</id><published>2007-03-22T18:26:00.000-07:00</published><updated>2007-03-22T18:27:27.749-07:00</updated><title type='text'>Performance</title><content type='html'>&lt;i&gt;Main article: &lt;a href="http://en.wikipedia.org/wiki/Java_performance" title="Java performance"&gt;Java performance&lt;/a&gt;&lt;/i&gt; &lt;p&gt;Java can be perceived as significantly slower and more memory-consuming than &lt;a href="http://en.wikipedia.org/wiki/Compiled_language" title="Compiled language"&gt;natively compiled languages&lt;/a&gt; such as &lt;a href="http://en.wikipedia.org/wiki/C_%28programming_language%29" title="C (programming language)"&gt;C&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/C%2B%2B" title="C++"&gt;C++&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Java's performance has increased substantially since the early versions, and performance of &lt;a href="http://en.wikipedia.org/wiki/JIT_compiler" title="JIT compiler"&gt;JIT compilers&lt;/a&gt; relative to native compilers has in some tests been shown to be quite similar.&lt;sup id="_ref-5" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-5" title=""&gt;[6]&lt;/a&gt;&lt;/sup&gt;&lt;sup id="_ref-6" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-6" title=""&gt;[7]&lt;/a&gt;&lt;/sup&gt;&lt;sup id="_ref-7" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-7" title=""&gt;[8]&lt;/a&gt;&lt;/sup&gt; The performance of the compilers does not necessarily indicate the performance of the compiled code; only careful testing can reveal the true performance issues in any system.&lt;/p&gt; &lt;p&gt;In a paper written in 1999 by Lutz Prechelt it is outlined that, statistically, programmer efficiency and experience has a bearing many standard deviations greater on run-time and memory usage than language choice. This paper specifically uses Java as a basis for the comparison, due to its bad reputation.&lt;sup id="_ref-8" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-8" title=""&gt;[9]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-7013366091449584714?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/7013366091449584714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=7013366091449584714' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/7013366091449584714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/7013366091449584714'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/performance.html' title='Performance'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4626276127250846709</id><published>2007-03-22T18:22:00.001-07:00</published><updated>2007-03-22T18:22:45.015-07:00</updated><title type='text'>Swing application</title><content type='html'>&lt;h4&gt;&lt;span class="mw-headline"&gt;Swing application&lt;/span&gt;&lt;/h4&gt; &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" title="Swing (Java)"&gt;Swing&lt;/a&gt; is a graphical user interface &lt;a href="http://en.wikipedia.org/wiki/Library_%28computer_science%29" title="Library (computer science)"&gt;library&lt;/a&gt; for the Java SE platform. This example Swing application creates a single window with "Hello, world!" inside:&lt;/p&gt; &lt;pre&gt;import java.awt.BorderLayout;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class Hello extends JFrame {&lt;br /&gt;  public Hello() {&lt;br /&gt;     super("hello");&lt;br /&gt;     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;     getContentPane().setLayout(new BorderLayout());&lt;br /&gt;     getContentPane().add(new JLabel("Hello, world!"));&lt;br /&gt;     pack();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public static void main(String[] args) {&lt;br /&gt;     new Hello().setVisible(true);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;The first &lt;b&gt;&lt;code&gt;import&lt;/code&gt;&lt;/b&gt; statement directs the Java compiler to include the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/BorderLayout.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/BorderLayout.html" rel="nofollow"&gt;BorderLayout&lt;/a&gt;&lt;/code&gt; class from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/package-summary.html" rel="nofollow"&gt;java.awt&lt;/a&gt;&lt;/code&gt; package in the compilation; the second &lt;b&gt;&lt;code&gt;import&lt;/code&gt;&lt;/b&gt; includes all of the public classes and interfaces from the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/package-summary.html" rel="nofollow"&gt;javax.swing&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; package.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;Hello&lt;/b&gt;&lt;/code&gt; class &lt;code&gt;&lt;b&gt;extends&lt;/b&gt;&lt;/code&gt; the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html" rel="nofollow"&gt;JFrame&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; class; the &lt;code&gt;JFrame&lt;/code&gt; class implements a &lt;a href="http://en.wikipedia.org/wiki/Window_%28computing%29" title="Window (computing)"&gt;window&lt;/a&gt; with a &lt;a href="http://en.wikipedia.org/wiki/Title_bar" title="Title bar"&gt;title bar&lt;/a&gt; with a close &lt;a href="http://en.wikipedia.org/wiki/Widget_%28computing%29" title="Widget (computing)"&gt;control&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;Hello()&lt;/b&gt;&lt;/code&gt; &lt;a href="http://en.wikipedia.org/wiki/Constructor_%28computer_science%29" title="Constructor (computer science)"&gt;constructor&lt;/a&gt; initializes the frame by first calling the superclass constructor, passing the parameter &lt;code&gt;"hello"&lt;/code&gt;, which is used as the window's title. It then calls the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation%28int%29" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation(int)" rel="nofollow"&gt;setDefaultCloseOperation(int)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from &lt;code&gt;JFrame&lt;/code&gt; to set the default operation when the close control on the title bar is selected to &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#EXIT_ON_CLOSE" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#EXIT_ON_CLOSE" rel="nofollow"&gt;JFrame.EXIT_ON_CLOSE&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; — this causes the &lt;code&gt;JFrame&lt;/code&gt; to be disposed of when the frame is closed (as opposed to merely hidden), which allows the JVM to exit and the program to terminate. Next, the layout of the frame is set to a &lt;code&gt;BorderLayout&lt;/code&gt;; this tells Swing how to arrange the components that will be added to the frame. A &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JLabel.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JLabel.html" rel="nofollow"&gt;JLabel&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; is created for the string &lt;b&gt;"Hello, world!"&lt;/b&gt; and the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#add%28java.awt.Component%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#add(java.awt.Component)" rel="nofollow"&gt;add(Component)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Container.html" rel="nofollow"&gt;Container&lt;/a&gt;&lt;/code&gt; superclass is called to add the label to the frame. The &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Window.html#pack%28%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Window.html#pack()" rel="nofollow"&gt;pack()&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Window.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Window.html" rel="nofollow"&gt;Window&lt;/a&gt;&lt;/code&gt; superclass is called to size the window and &lt;a href="http://en.wikipedia.org/wiki/Layout_manager#Example_in_Java_Swing" title="Layout manager"&gt;lay out&lt;/a&gt; its contents, in the manner indicated by the &lt;code&gt;BorderLayout&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;main()&lt;/b&gt;&lt;/code&gt; method is called by the JVM when the program starts. It &lt;a href="http://en.wikipedia.org/wiki/Instance_%28programming%29" title="Instance (programming)"&gt;instantiates&lt;/a&gt; a &lt;b&gt;&lt;code&gt;new Hello&lt;/code&gt;&lt;/b&gt; frame and causes it to be displayed by calling the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setVisible%28boolean%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setVisible(boolean)" rel="nofollow"&gt;setVisible(boolean)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Component.html" rel="nofollow"&gt;Component&lt;/a&gt;&lt;/code&gt; superclass with the boolean parameter &lt;code&gt;&lt;b&gt;true&lt;/b&gt;&lt;/code&gt;. Note that once the frame is displayed, exiting the &lt;code&gt;main&lt;/code&gt; method does not cause the program to terminate because the AWT &lt;a href="http://en.wikipedia.org/wiki/Event_dispatching_thread" title="Event dispatching thread"&gt;event dispatching thread&lt;/a&gt; remains active until all of the Swing top-level windows have been disposed.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4626276127250846709?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4626276127250846709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4626276127250846709' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4626276127250846709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4626276127250846709'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/swing-application.html' title='Swing application'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-6863841329782637957</id><published>2007-03-22T00:17:00.000-07:00</published><updated>2007-03-26T17:19:40.734-07:00</updated><title type='text'>Swing application</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" title="Swing (Java)"&gt;Swing&lt;/a&gt; is a graphical user interface &lt;a href="http://en.wikipedia.org/wiki/Library_%28computer_science%29" title="Library (computer science)"&gt;library&lt;/a&gt; for the Java SE platform. This example Swing application creates a single window with "Hello, world!" inside: &lt;pre&gt;// Hello.java (Java SE 5)&lt;br /&gt;import java.awt.BorderLayout;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class Hello extends JFrame {&lt;br /&gt;public Hello() {&lt;br /&gt;  super("hello");&lt;br /&gt;  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;  getContentPane().setLayout(new BorderLayout());&lt;br /&gt;  getContentPane().add(new JLabel("Hello, world!"));&lt;br /&gt;  pack();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt;  new Hello().setVisible(true);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;The first &lt;b&gt;&lt;code&gt;import&lt;/code&gt;&lt;/b&gt; statement directs the Java compiler to include the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/BorderLayout.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/BorderLayout.html" rel="nofollow"&gt;BorderLayout&lt;/a&gt;&lt;/code&gt; class from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/package-summary.html" rel="nofollow"&gt;java.awt&lt;/a&gt;&lt;/code&gt; package in the compilation; the second &lt;b&gt;&lt;code&gt;import&lt;/code&gt;&lt;/b&gt; includes all of the public classes and interfaces from the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/package-summary.html" rel="nofollow"&gt;javax.swing&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; package.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;Hello&lt;/b&gt;&lt;/code&gt; class &lt;code&gt;&lt;b&gt;extends&lt;/b&gt;&lt;/code&gt; the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html" rel="nofollow"&gt;JFrame&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; class; the &lt;code&gt;JFrame&lt;/code&gt; class implements a &lt;a href="http://en.wikipedia.org/wiki/Window_%28computing%29" title="Window (computing)"&gt;window&lt;/a&gt; with a &lt;a href="http://en.wikipedia.org/wiki/Title_bar" title="Title bar"&gt;title bar&lt;/a&gt; with a close &lt;a href="http://en.wikipedia.org/wiki/Widget_%28computing%29" title="Widget (computing)"&gt;control&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;Hello()&lt;/b&gt;&lt;/code&gt; &lt;a href="http://en.wikipedia.org/wiki/Constructor_%28computer_science%29" title="Constructor (computer science)"&gt;constructor&lt;/a&gt; initializes the frame by first calling the superclass constructor, passing the parameter &lt;code&gt;"hello"&lt;/code&gt;, which is used as the window's title. It then calls the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation%28int%29" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation(int)" rel="nofollow"&gt;setDefaultCloseOperation(int)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from &lt;code&gt;JFrame&lt;/code&gt; to set the default operation when the close control on the title bar is selected to &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#EXIT_ON_CLOSE" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#EXIT_ON_CLOSE" rel="nofollow"&gt;JFrame.EXIT_ON_CLOSE&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; — this causes the &lt;code&gt;JFrame&lt;/code&gt; to be disposed of when the frame is closed (as opposed to merely hidden), which allows the JVM to exit and the program to terminate. Next, the layout of the frame is set to a &lt;code&gt;BorderLayout&lt;/code&gt;; this tells Swing how to arrange the components that will be added to the frame. A &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JLabel.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JLabel.html" rel="nofollow"&gt;JLabel&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; is created for the string &lt;b&gt;"Hello, world!"&lt;/b&gt; and the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#add%28java.awt.Component%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#add(java.awt.Component)" rel="nofollow"&gt;add(Component)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Container.html" rel="nofollow"&gt;Container&lt;/a&gt;&lt;/code&gt; superclass is called to add the label to the frame. The &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Window.html#pack%28%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Window.html#pack()" rel="nofollow"&gt;pack()&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Window.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Window.html" rel="nofollow"&gt;Window&lt;/a&gt;&lt;/code&gt; superclass is called to size the window and &lt;a href="http://en.wikipedia.org/wiki/Layout_manager#Example_in_Java_Swing" title="Layout manager"&gt;lay out&lt;/a&gt; its contents, in the manner indicated by the &lt;code&gt;BorderLayout&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;main()&lt;/b&gt;&lt;/code&gt; method is called by the JVM when the program starts. It &lt;a href="http://en.wikipedia.org/wiki/Instance_%28programming%29" title="Instance (programming)"&gt;instantiates&lt;/a&gt; a &lt;b&gt;&lt;code&gt;new Hello&lt;/code&gt;&lt;/b&gt; frame and causes it to be displayed by calling the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setVisible%28boolean%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Component.html#setVisible(boolean)" rel="nofollow"&gt;setVisible(boolean)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Component.html" rel="nofollow"&gt;Component&lt;/a&gt;&lt;/code&gt; superclass with the boolean parameter &lt;code&gt;&lt;b&gt;true&lt;/b&gt;&lt;/code&gt;. Note that once the frame is displayed, exiting the &lt;code&gt;main&lt;/code&gt; method does not cause the program to terminate because the AWT &lt;a href="http://en.wikipedia.org/wiki/Event_dispatching_thread" title="Event dispatching thread"&gt;event dispatching thread&lt;/a&gt; remains active until all of the Swing top-level windows have been disposed.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-6863841329782637957?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/6863841329782637957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=6863841329782637957' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/6863841329782637957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/6863841329782637957'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/javaserver-page.html' title='Swing application'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4569357659868895254</id><published>2007-03-22T00:15:00.000-07:00</published><updated>2007-03-22T00:16:08.963-07:00</updated><title type='text'>Servlet</title><content type='html'>&lt;p&gt;Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. Servlets are &lt;a href="http://en.wikipedia.org/wiki/Server-side" title="Server-side"&gt;server-side&lt;/a&gt; Java EE components that generate responses (typically &lt;a href="http://en.wikipedia.org/wiki/HTML" title="HTML"&gt;HTML&lt;/a&gt; pages) to requests (typically &lt;a href="http://en.wikipedia.org/wiki/HTTP" title="HTTP"&gt;HTTP&lt;/a&gt; requests) from &lt;a href="http://en.wikipedia.org/wiki/Client_%28computing%29" title="Client (computing)"&gt;clients&lt;/a&gt;. A servlet can almost be thought of as an applet that runs on the server side—without a face.&lt;/p&gt; &lt;pre&gt;&lt;br /&gt;import java.io.*;&lt;br /&gt;import javax.servlet.*;&lt;br /&gt;&lt;br /&gt;public class Hello extends GenericServlet {&lt;br /&gt;   public void service(ServletRequest request, ServletResponse response)&lt;br /&gt;      throws ServletException, IOException {&lt;br /&gt;      response.setContentType("text/html");&lt;br /&gt;      final PrintWriter pw = response.getWriter();&lt;br /&gt;      pw.println("Hello, world!");&lt;br /&gt;      pw.close();&lt;br /&gt;   }&lt;br /&gt;}  &lt;br /&gt;&lt;/pre&gt; &lt;p&gt;The &lt;b&gt;&lt;code&gt;import&lt;/code&gt;&lt;/b&gt; statements direct the Java compiler to include all of the public classes and &lt;a href="http://en.wikipedia.org/wiki/Interface_%28Java%29" title="Interface (Java)"&gt;interfaces&lt;/a&gt; from the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/io/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/io/package-summary.html" rel="nofollow"&gt;java.io&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; and &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/package-summary.html" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/package-summary.html" rel="nofollow"&gt;javax.servlet&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; &lt;a href="http://en.wikipedia.org/wiki/Java_package" title="Java package"&gt;packages&lt;/a&gt; in the compilation.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;Hello&lt;/b&gt;&lt;/code&gt; class &lt;code&gt;&lt;b&gt;extends&lt;/b&gt;&lt;/code&gt; the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/GenericServlet.html" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/GenericServlet.html" rel="nofollow"&gt;GenericServlet&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; class; the &lt;code&gt;GenericServlet&lt;/code&gt; class provides the interface for the &lt;a href="http://en.wikipedia.org/wiki/Server_%28computing%29" title="Server (computing)"&gt;server&lt;/a&gt; to forward requests to the servlet and control the servlet's lifecycle.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;Hello&lt;/code&gt; class overrides the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Servlet.html#service%28javax.servlet.ServletRequest,javax.servlet.ServletResponse%29" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Servlet.html#service(javax.servlet.ServletRequest,javax.servlet.ServletResponse)" rel="nofollow"&gt;service(ServletRequest, ServletResponse)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method defined by the &lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Servlet.html" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Servlet.html" rel="nofollow"&gt;Servlet&lt;/a&gt;&lt;/code&gt; &lt;a href="http://en.wikipedia.org/wiki/Interface_%28Java%29" title="Interface (Java)"&gt;interface&lt;/a&gt; to provide the code for the service request handler. The &lt;code&gt;service()&lt;/code&gt; method is passed a &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html" rel="nofollow"&gt;ServletRequest&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; object that contains the request from the client and a &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html" rel="nofollow"&gt;ServletResponse&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; object used to create the response returned to the client. The &lt;code&gt;service()&lt;/code&gt; method declares that it &lt;code&gt;&lt;b&gt;throws&lt;/b&gt;&lt;/code&gt; the &lt;a href="http://en.wikipedia.org/wiki/Exception_handling" title="Exception handling"&gt;exceptions&lt;/a&gt; &lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletException.html" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletException.html" rel="nofollow"&gt;ServletException&lt;/a&gt;&lt;/code&gt; and &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/io/IOException.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/io/IOException.html" rel="nofollow"&gt;IOException&lt;/a&gt;&lt;/code&gt; if a problem prevents it from responding to the request.&lt;/p&gt; &lt;p&gt;The &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#setContentType%28java.lang.String%29" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#setContentType(java.lang.String)" rel="nofollow"&gt;setContentType(String)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method in the response object is called to set the &lt;a href="http://en.wikipedia.org/wiki/MIME" title="MIME"&gt;MIME&lt;/a&gt; content type of the returned data to &lt;b&gt;"text/html"&lt;/b&gt;. The &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#getWriter%28%29" class="external text" title="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#getWriter()" rel="nofollow"&gt;getWriter()&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method in the response returns a &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html" rel="nofollow"&gt;PrintWriter&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; object that is used to write the data that is sent to the client. The &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html#println%28java.lang.String%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html#println(java.lang.String)" rel="nofollow"&gt;println(String)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method is called to write the &lt;b&gt;"Hello, world!"&lt;/b&gt; string to the response and then the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html#close%28%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html#close()" rel="nofollow"&gt;close()&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method is called to close the print writer, which causes the data that has been written to the stream to be returned to the client.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4569357659868895254?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4569357659868895254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4569357659868895254' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4569357659868895254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4569357659868895254'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/servlet.html' title='Servlet'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-859956803073182919</id><published>2007-03-22T00:02:00.000-07:00</published><updated>2007-03-22T00:11:40.130-07:00</updated><title type='text'>Applet</title><content type='html'>&lt;p&gt;Java applets are programs that are embedded in other applications, typically in a Web page displayed in a &lt;a href="http://en.wikipedia.org/wiki/Web_browser" title="Web browser"&gt;Web browser&lt;/a&gt;.&lt;/p&gt; &lt;pre&gt;import java.applet.Applet;&lt;br /&gt;import java.awt.Graphics;&lt;br /&gt;&lt;br /&gt;public class Hello extends Applet {&lt;br /&gt; public void paint(Graphics gc) {&lt;br /&gt;    gc.drawString("Hello, world!", 65, 95);&lt;br /&gt; }  &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;The &lt;b&gt;&lt;code&gt;import&lt;/code&gt;&lt;/b&gt; statements direct the &lt;a href="http://en.wikipedia.org/wiki/Java_compiler" title="Java compiler"&gt;Java compiler&lt;/a&gt; to include the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/applet/Applet.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/applet/Applet.html" rel="nofollow"&gt;java.applet.Applet&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; and &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html" rel="nofollow"&gt;java.awt.Graphics&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; classes in the compilation. The import statement allows these classes to be referenced in the &lt;a href="http://en.wikipedia.org/wiki/Source_code" title="Source code"&gt;source code&lt;/a&gt; using the &lt;i&gt;simple class name&lt;/i&gt; (i.e. &lt;code&gt;Applet&lt;/code&gt;) instead of the &lt;i&gt;fully qualified class name&lt;/i&gt; (i.e. &lt;code&gt;java.applet.Applet&lt;/code&gt;).&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&lt;b&gt;Hello&lt;/b&gt;&lt;/code&gt; class &lt;code&gt;&lt;b&gt;extends&lt;/b&gt;&lt;/code&gt; (&lt;a href="http://en.wikipedia.org/wiki/Subclass_%28computer_science%29" title="Subclass (computer science)"&gt;subclasses&lt;/a&gt;) the &lt;b&gt;&lt;code&gt;Applet&lt;/code&gt;&lt;/b&gt; class; the &lt;code&gt;Applet&lt;/code&gt; class provides the framework for the host application to display and control the &lt;a href="http://en.wikipedia.org/wiki/Object_lifetime" title="Object lifetime"&gt;lifecycle&lt;/a&gt; of the applet. The &lt;code&gt;Applet&lt;/code&gt; class is an &lt;a href="http://en.wikipedia.org/wiki/Abstract_Windowing_Toolkit" title="Abstract Windowing Toolkit"&gt;Abstract Windowing Toolkit&lt;/a&gt; (AWT) &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Component.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Component.html" rel="nofollow"&gt;Component&lt;/a&gt;&lt;/code&gt;, which provides the applet with the capability to display a &lt;a href="http://en.wikipedia.org/wiki/Graphical_user_interface" title="Graphical user interface"&gt;graphical user interface&lt;/a&gt; (GUI) and respond to user &lt;a href="http://en.wikipedia.org/wiki/Event-driven_programming" title="Event-driven programming"&gt;events&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;Hello&lt;/code&gt; class &lt;a href="http://en.wikipedia.org/wiki/Method_overriding_%28programming%29" title="Method overriding (programming)"&gt;overrides&lt;/a&gt; the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#paint%28java.awt.Graphics%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Container.html#paint(java.awt.Graphics)" rel="nofollow"&gt;paint(Graphics)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method inherited from the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Container.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Container.html" rel="nofollow"&gt;Container&lt;/a&gt;&lt;/code&gt; &lt;a href="http://en.wikipedia.org/wiki/Superclass_%28computer_science%29" title="Superclass (computer science)"&gt;superclass&lt;/a&gt; to provide the code to display the applet. The &lt;code&gt;paint()&lt;/code&gt; method is passed a &lt;b&gt;&lt;code&gt;Graphics&lt;/code&gt;&lt;/b&gt; object that contains the graphic context used to display the applet. The &lt;code&gt;paint()&lt;/code&gt; method calls the graphic context &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html#drawString%28java.lang.String,%20int,%20int%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html#drawString(java.lang.String,%20int,%20int)" rel="nofollow"&gt;drawString(String, int, int)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method to display the &lt;b&gt;"Hello, world!"&lt;/b&gt; string at a &lt;a href="http://en.wikipedia.org/wiki/Pixel" title="Pixel"&gt;pixel&lt;/a&gt; offset of (&lt;code&gt;&lt;b&gt;65, 95&lt;/b&gt;&lt;/code&gt;) from the upper-left corner in the applet's display.&lt;/p&gt;An applet is placed in an &lt;a href="http://en.wikipedia.org/wiki/HTML" title="HTML"&gt;HTML&lt;/a&gt; document using the &lt;b&gt;&lt;code&gt;&lt;applet&gt;&lt;/applet&gt;&lt;/code&gt;&lt;/b&gt; &lt;a href="http://en.wikipedia.org/wiki/HTML_element" title="HTML element"&gt;HTML element&lt;/a&gt;. The &lt;code&gt;applet&lt;/code&gt; tag has three attributes set: &lt;b&gt;&lt;code&gt;code="Hello"&lt;/code&gt;&lt;/b&gt; specifies the name of the &lt;code&gt;Applet&lt;/code&gt; class and &lt;b&gt;&lt;code&gt;width="200" height="200"&lt;/code&gt;&lt;/b&gt; sets the pixel width and height of the applet. (Applets may also be embedded in HTML using either the &lt;code&gt;object&lt;/code&gt; or &lt;code&gt;embed&lt;/code&gt; element, although support for these elements by Web browsers is inconsistent.&lt;a href="http://java.sun.com/docs/books/tutorial/deployment/applet/applettag.html" class="external autonumber" title="http://java.sun.com/docs/books/tutorial/deployment/applet/applettag.html" rel="nofollow"&gt;[3]&lt;/a&gt;&lt;a href="http://java.sun.com/docs/books/tutorial/deployment/applet/mixedbrowser.html" class="external autonumber" title="http://java.sun.com/docs/books/tutorial/deployment/applet/mixedbrowser.html" rel="nofollow"&gt;[4]&lt;/a&gt;) However, the &lt;code&gt;applet&lt;/code&gt; tag is deprecated, so the &lt;code&gt;object&lt;/code&gt; tag is preferred where supported. &lt;p&gt;The host application, typically a Web browser, instantiates the &lt;b&gt;&lt;code&gt;Hello&lt;/code&gt;&lt;/b&gt; applet and creates an &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/applet/AppletContext.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/applet/AppletContext.html" rel="nofollow"&gt;AppletContext&lt;/a&gt;&lt;/code&gt; for the applet. Once the applet has initialized itself, it is added to the AWT display hierarchy. The &lt;code&gt;paint&lt;/code&gt; method is called by the AWT &lt;a href="http://en.wikipedia.org/wiki/Event_dispatching_thread" title="Event dispatching thread"&gt;event dispatching thread&lt;/a&gt; whenever the display needs the applet to draw itself.&lt;/p&gt; &lt;p&gt;&lt;a name="Servlet" id="Servlet"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4&gt;&lt;br /&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/h4&gt; &lt;applet&gt;HTML element. The applet tag has three attributes set: code="Hello" specifies the name of the Applet class and width="200" height="200" sets the pixel width and height of the applet. (Applets may also be embedded in HTML using either the object or embed element, although support for these elements by Web browsers is inconsistent.[3][4]) However, the applet tag is deprecated, so the object tag is preferred where supported.&lt;br /&gt;&lt;br /&gt;The host application, typically a Web browser, instantiates the Hello applet and creates an AppletContext for the applet. Once the applet has initialized itself, it is added to the AWT display hierarchy. The paint method is called by the AWT event dispatching thread whenever the display needs the applet to draw itself.&lt;br /&gt;&lt;br /&gt;[edit]&lt;br /&gt;&lt;/applet&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-859956803073182919?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/859956803073182919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=859956803073182919' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/859956803073182919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/859956803073182919'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/applet.html' title='Applet'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-6566327328532523408</id><published>2007-03-22T00:00:00.001-07:00</published><updated>2007-03-22T00:00:42.196-07:00</updated><title type='text'>Syntax</title><content type='html'>&lt;p&gt;The syntax of Java is largely derived from C++. However, unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built from the ground up as an object oriented language. As a result, almost everything is an object and all code is written inside a class. The exceptions are the intrinsic data types (ordinal and real numbers, boolean values, and characters), which are not classes for performance reasons.&lt;/p&gt; &lt;p&gt;&lt;a name="Hello_world" id="Hello_world"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Java_%28programming_language%29&amp;action=edit&amp;amp;section=8" title="Edit section: Hello world"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Hello world&lt;/span&gt;&lt;/h3&gt; &lt;dl&gt;&lt;dd&gt;&lt;i&gt;For an explanation of the tradition of programming "Hello World" see: &lt;a href="http://en.wikipedia.org/wiki/Hello_world_program" title="Hello world program"&gt;Hello world program&lt;/a&gt;.&lt;/i&gt;&lt;/dd&gt;&lt;/dl&gt; &lt;p&gt;&lt;a name="Stand-alone_application" id="Stand-alone_application"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4&gt;&lt;span class="editsection"&gt;[&lt;a href="http://en.wikipedia.org/w/index.php?title=Java_%28programming_language%29&amp;action=edit&amp;amp;section=9" title="Edit section: Stand-alone application"&gt;edit&lt;/a&gt;]&lt;/span&gt; &lt;span class="mw-headline"&gt;Stand-alone application&lt;/span&gt;&lt;/h4&gt; &lt;p&gt;This is a minimal usage of Java, but it does not demonstrate object-oriented programming well. No object is explicitly created since the &lt;a href="http://en.wikipedia.org/wiki/Keyword" title="Keyword"&gt;keyword&lt;/a&gt; &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_keywords#new" title="Java keywords"&gt;new&lt;/a&gt;&lt;/i&gt; is never used.&lt;/p&gt; &lt;pre&gt;// Hello.java&lt;br /&gt;public class Hello {&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;       System.out.println("Hello, World!");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;To execute this program, one first saves the above code as a file named &lt;code&gt;Hello.java&lt;/code&gt;. One then compiles it to bytecode:&lt;/p&gt; &lt;pre&gt;$ javac Hello.java&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;which produces a file named &lt;code&gt;Hello.class&lt;/code&gt; . This class is then &lt;i&gt;launched&lt;/i&gt; with the java launcher (usually named java, java.exe, or some variant depending on the &lt;a href="http://en.wikipedia.org/wiki/Operating_system" title="Operating system"&gt;operating system&lt;/a&gt;).&lt;/p&gt; &lt;pre&gt;$ java Hello&lt;br /&gt;Hello, World!&lt;br /&gt;&lt;br /&gt;$&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;The above example merits a bit of explanation.&lt;/p&gt; &lt;ul&gt;&lt;li&gt;All executable statements in Java are written inside a class, including stand-alone programs.&lt;/li&gt;&lt;li&gt;Source files are by convention named the same as the class they contain, appending the mandatory suffix &lt;i&gt;.java&lt;/i&gt;. A &lt;code&gt;&lt;b&gt;class&lt;/b&gt;&lt;/code&gt; which is declared &lt;code&gt;&lt;b&gt;public&lt;/b&gt;&lt;/code&gt; is required to follow this convention. (In this case, the class is &lt;code&gt;&lt;b&gt;Hello&lt;/b&gt;&lt;/code&gt;, therefore the source must be stored in a file called &lt;i&gt;Hello.java&lt;/i&gt;).&lt;/li&gt;&lt;li&gt;The compiler will generate a class file for each class defined in the source file. The name of the class file is the name of the class, with &lt;i&gt;.class&lt;/i&gt; appended. For class file generation, anonymous classes are treated as if their name was the concatenation of the name of their enclosing class, a &lt;i&gt;$&lt;/i&gt;, and an integer.&lt;/li&gt;&lt;li&gt;The &lt;a href="http://en.wikipedia.org/wiki/Java_keywords" title="Java keywords"&gt;keyword&lt;/a&gt; &lt;code&gt;&lt;b&gt;void&lt;/b&gt;&lt;/code&gt; indicates that the main method does not return any value to the caller.&lt;/li&gt;&lt;li&gt;The main method must accept an &lt;a href="http://en.wikipedia.org/wiki/Array" title="Array"&gt;array&lt;/a&gt; of &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/String.html" rel="nofollow"&gt;String&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; objects. By convention, it is referenced as &lt;code&gt;&lt;b&gt;args&lt;/b&gt;&lt;/code&gt; although any other legal identifier name can be used. Since Java 5, the main method can also use &lt;a href="http://en.wikipedia.org/wiki/Varargs" title="Varargs"&gt;variable arguments&lt;/a&gt;, in the form of &lt;code&gt;public static void main(String... args)&lt;/code&gt;, allowing the main method to be invoked with an arbitrary number of &lt;code&gt;String&lt;/code&gt; arguments. The effect of this alternate declaration is semantically identical (the &lt;code&gt;args&lt;/code&gt; parameter is still an array of &lt;code&gt;String&lt;/code&gt; objects), but allows an alternate syntax for creating and passing the array.&lt;/li&gt;&lt;li&gt;The keyword &lt;code&gt;&lt;b&gt;static&lt;/b&gt;&lt;/code&gt; indicates that the method is a &lt;a href="http://en.wikipedia.org/wiki/Class_method" title="Class method"&gt;static method&lt;/a&gt;, associated with the class rather than object instances.&lt;/li&gt;&lt;li&gt;The keyword &lt;code&gt;&lt;b&gt;public&lt;/b&gt;&lt;/code&gt; denotes that a method can be called from code in other classes, or that a class may be used by classes outside the class hierarchy.&lt;/li&gt;&lt;li&gt;The Java launcher launches Java by loading a given class (specified on the command line) and starting its &lt;code&gt;public static void main(String[])&lt;/code&gt; method. Stand-alone programs must declare this method explicitly. The &lt;code&gt;String[] args&lt;/code&gt; parameter is an &lt;a href="http://en.wikipedia.org/wiki/Array" title="Array"&gt;array&lt;/a&gt; of &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/String.html" rel="nofollow"&gt;String&lt;/a&gt;&lt;/code&gt; objects containing any arguments passed to the class. The parameter to &lt;code&gt;main&lt;/code&gt; are often passed by means of a &lt;a href="http://en.wikipedia.org/wiki/Command_line" title="Command line"&gt;command line&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;The method name "&lt;code&gt;main&lt;/code&gt;" is not a keyword in the Java language. It is simply the name of the method the Java launcher calls to pass control to the program. Java classes that run in managed environments such as applets and Enterprise Java Beans do not use or need a &lt;code&gt;main()&lt;/code&gt; method.&lt;/li&gt;&lt;li&gt;The printing facility is part of the Java standard library: The &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/System.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/System.html" rel="nofollow"&gt;System&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; class defines a public static field called &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/System.html#out" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/System.html#out" rel="nofollow"&gt;out&lt;/a&gt;&lt;/code&gt;&lt;/b&gt;. The &lt;code&gt;out&lt;/code&gt; object is an instance of the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html" rel="nofollow"&gt;PrintStream&lt;/a&gt;&lt;/code&gt; class and provides the method &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html#println%28java.lang.String%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html#println(java.lang.String)" rel="nofollow"&gt;println(String)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; for displaying data to the screen while creating a new line (&lt;a href="http://en.wikipedia.org/wiki/Standard_streams" title="Standard streams"&gt;standard out&lt;/a&gt;).&lt;/li&gt;&lt;li&gt;Standalone programs are run by giving the Java runtime the name of the class whose main method is to be invoked. For example, at a &lt;a href="http://en.wikipedia.org/wiki/Unix" title="Unix"&gt;Unix&lt;/a&gt; command line &lt;code&gt;java -cp . Hello&lt;/code&gt; will start the above program (compiled into &lt;i&gt;Hello.class&lt;/i&gt;) from the current directory. The name of the class whose main method is to be invoked can also be specified in the &lt;i&gt;MANIFEST&lt;/i&gt; of a &lt;a href="http://en.wikipedia.org/wiki/Jar_%28file_format%29" title="Jar (file format)"&gt;Java archive (Jar) file&lt;/a&gt; (see &lt;a href="http://en.wikipedia.org/wiki/Classpath_%28Java%29" title="Classpath (Java)"&gt;Classpath&lt;/a&gt;).&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;b&gt;An example that better demonstrates &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming" title="Object-oriented programming"&gt;object-oriented programming&lt;/a&gt;:&lt;/b&gt;&lt;/p&gt; &lt;pre&gt;// OddEven.java&lt;br /&gt;import javax.swing.JOptionPane;&lt;br /&gt;&lt;br /&gt;public class OddEven {&lt;br /&gt;   private int input;&lt;br /&gt;&lt;br /&gt;   public OddEven() {&lt;br /&gt;       input = Integer.parseInt(JOptionPane.showInputDialog("Please Enter A Number"));&lt;br /&gt;   }&lt;br /&gt;      &lt;br /&gt;   public void calculate() {&lt;br /&gt;       if (input % 2 == 0)&lt;br /&gt;           System.out.println("Even");&lt;br /&gt;       else&lt;br /&gt;           System.out.println("Odd");&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;       OddEven number = new OddEven();&lt;br /&gt;       number.calculate();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;ul&gt;&lt;li&gt;The &lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_keywords#import" title="Java keywords"&gt;import&lt;/a&gt;&lt;/b&gt; statement imports the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JOptionPane.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/JOptionPane.html" rel="nofollow"&gt;JOptionPane&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; class from the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/package-summary.html" class="external text" title="http://java.sun.com/javase/6/docs/api/javax/swing/package-summary.html" rel="nofollow"&gt;javax.swing&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; package.&lt;/li&gt;&lt;li&gt;The &lt;code&gt;&lt;b&gt;OddEven&lt;/b&gt;&lt;/code&gt; class declares a single &lt;code&gt;&lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_keywords#private" title="Java keywords"&gt;private&lt;/a&gt;&lt;/b&gt;&lt;/code&gt; &lt;a href="http://en.wikipedia.org/wiki/Field_%28computer_science%29" title="Field (computer science)"&gt;field&lt;/a&gt; of type &lt;code&gt;&lt;b&gt;int&lt;/b&gt;&lt;/code&gt; named &lt;code&gt;&lt;b&gt;input&lt;/b&gt;&lt;/code&gt;. Every instance of the &lt;code&gt;OddEven&lt;/code&gt; class has its own copy of the &lt;code&gt;input&lt;/code&gt; field. The private declaration means that no other class can access (read or write) the &lt;code&gt;input&lt;/code&gt; field.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;b&gt;OddEven()&lt;/b&gt;&lt;/code&gt; is a &lt;code&gt;&lt;b&gt;public&lt;/b&gt;&lt;/code&gt; &lt;a href="http://en.wikipedia.org/wiki/Constructor_%28computer_science%29" title="Constructor (computer science)"&gt;constructor&lt;/a&gt;. Constructors have the same name as the enclosing class they are declared in, and unlike a method, have no &lt;a href="http://en.wikipedia.org/wiki/Return_type" title="Return type"&gt;return type&lt;/a&gt;. A constructor is used to initialize an &lt;a href="http://en.wikipedia.org/wiki/Object_%28computer_science%29" title="Object (computer science)"&gt;object&lt;/a&gt; that is a newly created instance of the class. In this case, the constructor initializes the &lt;code&gt;input&lt;/code&gt; field to the value entered into a &lt;code&gt;&lt;b&gt;JOptionPane&lt;/b&gt;&lt;/code&gt; input dialog. The dialog returns a &lt;code&gt;String&lt;/code&gt; which is converted to an &lt;code&gt;int&lt;/code&gt; by the &lt;b&gt;&lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#parseInt%28String%29" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#parseInt(String)" rel="nofollow"&gt;Integer.parseInt(String)&lt;/a&gt;&lt;/code&gt;&lt;/b&gt; method.&lt;/li&gt;&lt;li&gt;The &lt;code&gt;&lt;b&gt;calculate()&lt;/b&gt;&lt;/code&gt; method is declared without the &lt;code&gt;static&lt;/code&gt; keyword. This means that the method is invoked using a specific instance of the &lt;code&gt;OddEven&lt;/code&gt; class. (The &lt;a href="http://en.wikipedia.org/wiki/Reference_%28computer_science%29" title="Reference (computer science)"&gt;reference&lt;/a&gt; used to invoke the method is passed as an undeclared parameter of type &lt;code&gt;OddEven&lt;/code&gt; named &lt;code&gt;&lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_keywords#this" title="Java keywords"&gt;this&lt;/a&gt;&lt;/b&gt;&lt;/code&gt;.) The method tests the expression &lt;code&gt;input % 2 == 0&lt;/code&gt; using the &lt;code&gt;&lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_keywords#if" title="Java keywords"&gt;if&lt;/a&gt;&lt;/b&gt;&lt;/code&gt; keyword to see if the remainder of dividing the &lt;code&gt;input&lt;/code&gt; field belonging to the instance of the class by two is zero. If this expression is true, then it prints &lt;b&gt;Even&lt;/b&gt;; if this expression is false it prints &lt;b&gt;Odd&lt;/b&gt;. (The &lt;code&gt;input&lt;/code&gt; field can be equivalently accessed as &lt;code&gt;this.input&lt;/code&gt;, which explicitly uses the undeclared &lt;code&gt;this&lt;/code&gt; parameter.)&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;b&gt;OddEven number = new OddEven();&lt;/b&gt;&lt;/code&gt; declares a local object &lt;a href="http://en.wikipedia.org/wiki/Reference_%28computer_science%29" title="Reference (computer science)"&gt;reference&lt;/a&gt; variable in the &lt;code&gt;main&lt;/code&gt; method named &lt;code&gt;number&lt;/code&gt;. This variable can hold a reference to an object of type &lt;code&gt;OddEven&lt;/code&gt;. The declaration initializes &lt;code&gt;number&lt;/code&gt; by instantiating an instance of the &lt;code&gt;OddEven&lt;/code&gt; class using the &lt;code&gt;&lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_keywords#new" title="Java keywords"&gt;new&lt;/a&gt;&lt;/b&gt;&lt;/code&gt; keyword and then calling the &lt;code&gt;OddEven()&lt;/code&gt; constructor to initialize the newly created object.&lt;/li&gt;&lt;li&gt;The statement &lt;code&gt;&lt;b&gt;number.calculate();&lt;/b&gt;&lt;/code&gt; calls the calculate method. The instance of &lt;code&gt;OddEven&lt;/code&gt; object referenced by the &lt;code&gt;number&lt;/code&gt; &lt;a href="http://en.wikipedia.org/wiki/Local_variable" title="Local variable"&gt;local variable&lt;/a&gt; is used to invoke the method and passed as the undeclared &lt;code&gt;this&lt;/code&gt; parameter to the &lt;code&gt;calculate&lt;/code&gt; method.&lt;/li&gt;&lt;li&gt;For simplicity, &lt;a href="http://en.wikipedia.org/wiki/Error_handling" title="Error handling"&gt;error handling&lt;/a&gt; has been ignored in this example. Entering a value that is not a number will cause the program to crash. This can be avoided by catching and handling the &lt;code&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/NumberFormatException.html" class="external text" title="http://java.sun.com/javase/6/docs/api/java/lang/NumberFormatException.html" rel="nofollow"&gt;NumberFormatException&lt;/a&gt;&lt;/code&gt; thrown by &lt;code&gt;Integer.parseInt(String)&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-6566327328532523408?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/6566327328532523408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=6566327328532523408' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/6566327328532523408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/6566327328532523408'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/syntax.html' title='Syntax'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-1401560980454809907</id><published>2007-03-21T23:59:00.000-07:00</published><updated>2007-03-22T00:00:03.845-07:00</updated><title type='text'>Automatic garbage collection</title><content type='html'>&lt;p&gt;One of the ideas behind Java's automatic memory management model is that programmers be spared the burden of having to perform manual memory management. In some languages the programmer allocates memory for the creation of objects stored on the heap and the responsibility of later deallocating that memory thus resides with the programmer. If the programmer forgets to deallocate memory or writes code that fails to do so, a &lt;a href="http://en.wikipedia.org/wiki/Memory_leak" title="Memory leak"&gt;memory leak&lt;/a&gt; occurs and the program can consume an arbitrarily large amount of memory. Additionally, if the program attempts to deallocate the region of memory more than once, the result is undefined and the program may become unstable and may crash. Finally, in non garbage collected environments, there is a certain degree of overhead and complexity of user-code to track and finalize allocations. Often developers may box themselves into certain designs to provide reasonable assurances that memory leaks will not occur &lt;a href="http://www.research.att.com/%7Ebs/bs_faq2.html#memory-leaks" class="external autonumber" title="http://www.research.att.com/~bs/bs_faq2.html#memory-leaks" rel="nofollow"&gt;[2]&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;In Java, this potential problem is avoided by &lt;a href="http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29" title="Garbage collection (computer science)"&gt;automatic garbage collection&lt;/a&gt;. The programmer determines when objects are created, and the Java runtime is responsible for managing the &lt;a href="http://en.wikipedia.org/wiki/Object_lifetime" title="Object lifetime"&gt;object's lifecycle&lt;/a&gt;. The program or other objects can reference an object by holding a reference to it (which, from a low-level point of view, is its address on the heap). When no references to an object remain, the Java garbage collector automatically deletes the &lt;a href="http://en.wikipedia.org/wiki/Unreachable_object" title="Unreachable object"&gt;unreachable object&lt;/a&gt;, freeing memory and preventing a memory leak. Memory leaks may still occur if a programmer's code holds a reference to an object that is no longer needed—in other words, they can still occur but at higher conceptual levels.&lt;/p&gt; &lt;p&gt;The use of garbage collection in a language can also affect programming paradigms. If, for example, the developer assumes that the cost of memory allocation/recollection is low, they may choose to more freely construct objects instead of pre-initializing, holding and reusing them. With the small cost of potential performance penalties (inner-loop construction of large/complex objects), this facilitates thread-isolation (no need to synchronize as different threads work on different object instances) and data-hiding. The use of transient immutable value-objects minimizes side-effect programming.&lt;/p&gt; &lt;p&gt;Comparing Java and &lt;a href="http://en.wikipedia.org/wiki/C%2B%2B" title="C++"&gt;C++&lt;/a&gt;, it is possible in C++ to implement similar functionality (for example, a memory management model for specific classes can be designed in C++ to improve speed and lower memory fragmentation considerably), with the possible cost of adding comparable runtime overhead to that of Java's garbage collector, and of added development time and application complexity if one favors manual implementation over using an existing third-party library. In Java, garbage collection is built-in and virtually invisible to the developer. That is, developers may have no notion of when garbage collection will take place as it may not necessarily correlate with any actions being explicitly performed by the code they write. Depending on intended application, this can be beneficial or disadvantageous: the programmer is freed from performing low-level tasks, but at the same time loses the option of writing lower level code.&lt;/p&gt; &lt;p&gt;Java does not support &lt;a href="http://en.wikipedia.org/wiki/Pointer_%28computing%29" title="Pointer (computing)"&gt;pointer arithmetic&lt;/a&gt; as is supported in for example C++. This is because the garbage collector may relocate referenced objects, invalidating such pointers. Another reason that Java forbids this is that type safety and security can no longer be guaranteed if arbitrary manipulation of pointers is allowed.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-1401560980454809907?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/1401560980454809907/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=1401560980454809907' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1401560980454809907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1401560980454809907'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/automatic-garbage-collection.html' title='Automatic garbage collection'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-302278137326298042</id><published>2007-03-21T23:58:00.001-07:00</published><updated>2007-03-21T23:58:49.182-07:00</updated><title type='text'>Platform independence</title><content type='html'>&lt;p&gt;One characteristic, &lt;a href="http://en.wikipedia.org/wiki/Cross-platform" title="Cross-platform"&gt;platform independence&lt;/a&gt;, means that &lt;a href="http://en.wikipedia.org/wiki/Computer_program" title="Computer program"&gt;programs&lt;/a&gt; written in the Java language must run similarly on any supported hardware/operating-system platform. One should be able to write a program once, compile it once, and run it anywhere.&lt;/p&gt; &lt;p&gt;This is achieved by most Java &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compilers&lt;/a&gt; by compiling the Java language code "halfway" to &lt;a href="http://en.wikipedia.org/wiki/Bytecode" title="Bytecode"&gt;bytecode&lt;/a&gt; (specifically &lt;a href="http://en.wikipedia.org/wiki/Java_bytecode" title="Java bytecode"&gt;Java bytecode&lt;/a&gt;)—simplified machine instructions specific to the Java platform. The code is then run on a &lt;a href="http://en.wikipedia.org/wiki/Virtual_machine" title="Virtual machine"&gt;virtual machine&lt;/a&gt; (VM), a program written in native code on the host hardware that &lt;a href="http://en.wikipedia.org/wiki/Interpreter_%28computing%29" title="Interpreter (computing)"&gt;interprets&lt;/a&gt; and executes generic Java bytecode. (In some JVM versions, bytecode can also be compiled to native code, resulting in faster execution.) Further, standardized libraries are provided to allow access to features of the host machines (such as graphics, &lt;a href="http://en.wikipedia.org/wiki/Thread_%28computer_science%29" title="Thread (computer science)"&gt;threading&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Computer_network" title="Computer network"&gt;networking&lt;/a&gt;) in unified ways. Note that, although there's an explicit compiling stage, at some point, the Java bytecode is interpreted or converted to native &lt;a href="http://en.wikipedia.org/wiki/Assembly_language" title="Assembly language"&gt;machine instructions&lt;/a&gt; by the &lt;a href="http://en.wikipedia.org/wiki/Just-in-time_compilation" title="Just-in-time compilation"&gt;JIT compiler&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;There are also implementations of Java compilers that translate the Java language code to native &lt;a href="http://en.wikipedia.org/wiki/Object_code" title="Object code"&gt;object code&lt;/a&gt;, such as &lt;a href="http://en.wikipedia.org/wiki/GCJ" title="GCJ"&gt;GCJ&lt;/a&gt;, removing the intermediate bytecode stage, but the output of these compilers can only be run on a single &lt;a href="http://en.wikipedia.org/wiki/Computer_architecture" title="Computer architecture"&gt;architecture&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Sun's license for Java insists that all implementations be "compatible". This resulted in a legal dispute with &lt;a href="http://en.wikipedia.org/wiki/Microsoft" title="Microsoft"&gt;Microsoft&lt;/a&gt; after Sun claimed that the Microsoft implementation did not support the &lt;a href="http://en.wikipedia.org/wiki/Java_remote_method_invocation" title="Java remote method invocation"&gt;RMI&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Java_Native_Interface" title="Java Native Interface"&gt;JNI&lt;/a&gt; interfaces and had added platform-specific features of their own. Sun sued and won both damages (some $20 million) and a court order enforcing the terms of the license from Sun. As a result, Microsoft no longer ships Java with &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Windows" title="Microsoft Windows"&gt;Windows&lt;/a&gt;, and in recent versions of Windows, &lt;a href="http://en.wikipedia.org/wiki/Internet_Explorer" title="Internet Explorer"&gt;Internet Explorer&lt;/a&gt; cannot support Java applets without a third-party plugin. However, Sun and others have made available Java run-time systems at no cost for those and other versions of Windows.&lt;/p&gt; &lt;p&gt;The first implementations of the language used an interpreted virtual machine to achieve &lt;a href="http://en.wikipedia.org/wiki/Porting" title="Porting"&gt;portability&lt;/a&gt;. These implementations produced programs that ran more slowly than programs compiled to native executables, for instance written in C or C++, so the language suffered a reputation for poor performance. More recent JVM implementations produce programs that run significantly faster than before, using multiple techniques.&lt;/p&gt; &lt;p&gt;The first technique is to simply compile directly into native code like a more traditional compiler, skipping bytecodes entirely. This achieves good performance, but at the expense of portability. Another technique, known as &lt;i&gt;just-in-time compilation&lt;/i&gt; (JIT), translates the Java bytecodes into native code at the time that the program is run which results in a program that executes faster than interpreted code but also incurs &lt;a href="http://en.wikipedia.org/w/index.php?title=Compilation_overhead&amp;amp;action=edit" class="new" title="Compilation overhead"&gt;compilation overhead&lt;/a&gt; during execution. More sophisticated VMs use &lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Dynamic_recompilation" title="Dynamic recompilation"&gt;dynamic recompilation&lt;/a&gt;&lt;/i&gt;, in which the VM can analyze the behavior of the running program and selectively recompile and optimize critical parts of the program. Dynamic recompilation can achieve optimizations superior to static compilation because the dynamic compiler can base optimizations on knowledge about the runtime environment and the set of loaded classes, and can identify the "hot spots" (parts of the program, often inner loops, that take up most of execution time). JIT compilation and dynamic recompilation allow Java programs to take advantage of the speed of native code without losing portability.&lt;/p&gt; &lt;p&gt;Portability is a technically difficult goal to achieve, and Java's success at that goal has been mixed. Although it is indeed possible to write programs for the Java platform that behave consistently across many host platforms, the large number of available platforms with small errors or inconsistencies led some to parody Sun's "&lt;a href="http://en.wikipedia.org/wiki/Write_once%2C_run_anywhere" title="Write once, run anywhere"&gt;Write once, run anywhere&lt;/a&gt;" slogan as "Write once, &lt;a href="http://en.wikipedia.org/wiki/Debug" title="Debug"&gt;debug&lt;/a&gt; everywhere".&lt;/p&gt; &lt;p&gt;Platform-independent Java is however very successful with server-side applications, such as &lt;a href="http://en.wikipedia.org/wiki/Web_service" title="Web service"&gt;Web services&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Servlet" title="Servlet"&gt;servlets&lt;/a&gt;, and &lt;a href="http://en.wikipedia.org/wiki/Enterprise_JavaBean" title="Enterprise JavaBean"&gt;Enterprise JavaBeans&lt;/a&gt;, as well as with &lt;a href="http://en.wikipedia.org/wiki/Embedded_system" title="Embedded system"&gt;Embedded systems&lt;/a&gt; based on &lt;a href="http://en.wikipedia.org/wiki/OSGi" title="OSGi"&gt;OSGi&lt;/a&gt;, using &lt;a href="http://en.wikipedia.org/wiki/Embedded_Java" title="Embedded Java"&gt;Embedded Java&lt;/a&gt; environments.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-302278137326298042?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/302278137326298042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=302278137326298042' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/302278137326298042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/302278137326298042'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/platform-independence.html' title='Platform independence'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-8916081878431245511</id><published>2007-03-21T23:40:00.000-07:00</published><updated>2007-03-21T23:41:12.163-07:00</updated><title type='text'>Primary Goals</title><content type='html'>&lt;p&gt;There were five primary goals in the creation of the Java language:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;It should use the &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming" title="Object-oriented programming"&gt;object-oriented programming&lt;/a&gt; methodology.&lt;/li&gt;&lt;li&gt;It should allow the same program to be &lt;a href="http://en.wikipedia.org/wiki/Execution_%28computers%29" title="Execution (computers)"&gt;executed&lt;/a&gt; on multiple &lt;a href="http://en.wikipedia.org/wiki/Operating_system" title="Operating system"&gt;operating systems&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;It should contain built-in support for using &lt;a href="http://en.wikipedia.org/wiki/Computer_network" title="Computer network"&gt;computer networks&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;It should be designed to execute code from &lt;a href="http://en.wikipedia.org/wiki/Remote_procedure_call" title="Remote procedure call"&gt;remote sources&lt;/a&gt; securely.&lt;/li&gt;&lt;li&gt;It should be easy to use by selecting what was considered the good parts of other object-oriented languages.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;To achieve the goals of networking support and remote code execution, Java programmers sometimes find it necessary to use extensions such as &lt;a href="http://en.wikipedia.org/wiki/CORBA" title="CORBA"&gt;CORBA&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Internet_Communications_Engine" title="Internet Communications Engine"&gt;Internet Communications Engine&lt;/a&gt;, or &lt;a href="http://en.wikipedia.org/wiki/OSGi" title="OSGi"&gt;OSGi&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-8916081878431245511?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/8916081878431245511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=8916081878431245511' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8916081878431245511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/8916081878431245511'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/primary-goals.html' title='Primary Goals'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-1042199845463486797</id><published>2007-03-21T23:38:00.000-07:00</published><updated>2007-03-22T17:51:04.407-07:00</updated><title type='text'>History</title><content type='html'>Java started as a project called "Oak" (The name came from an oak tree that stood outside the Sun Microsystems office) by &lt;a href="http://en.wikipedia.org/wiki/James_Gosling" title="James Gosling"&gt;James Gosling&lt;/a&gt; in June 1991.&lt;sup id="_ref-0" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-0" title=""&gt;[1]&lt;/a&gt;&lt;/sup&gt; Gosling's goals were to implement a &lt;a href="http://en.wikipedia.org/wiki/Virtual_machine" title="Virtual machine"&gt;virtual machine&lt;/a&gt; and a language that had a familiar C/C++ style of notation. The first public implementation was Java 1.0 in 1995. It promised "&lt;a href="http://en.wikipedia.org/wiki/Write_once%2C_run_anywhere" title="Write once, run anywhere"&gt;Write Once, Run Anywhere&lt;/a&gt;" (WORA), providing no-cost runtimes on popular platforms. It was fairly secure and its security was configurable, allowing network and file access to be restricted. Major web browsers soon incorporated the ability to run secure Java "&lt;a href="http://en.wikipedia.org/wiki/Applet" title="Applet"&gt;applets&lt;/a&gt;" within web pages. Java became popular quickly. With the advent of "Java 2", new versions had multiple configurations built for different types of platform. For example, &lt;a href="http://en.wikipedia.org/wiki/J2EE" title="J2EE"&gt;J2EE&lt;/a&gt; was for enterprise applications and the greatly stripped down version &lt;a href="http://en.wikipedia.org/wiki/J2ME" title="J2ME"&gt;J2ME&lt;/a&gt; was for mobile applications. &lt;a href="http://en.wikipedia.org/wiki/J2SE" title="J2SE"&gt;J2SE&lt;/a&gt; is the designation for the Standard Edition. &lt;p&gt;In 1997, Sun approached the &lt;a href="http://en.wikipedia.org/wiki/International_Organization_for_Standardization#ISO.2FIEC_Joint_Technical_Committee_1" title="International Organization for Standardization"&gt;ISO/IEC JTC1 standards body&lt;/a&gt; and later the &lt;a href="http://en.wikipedia.org/wiki/Ecma_International" title="Ecma International"&gt;Ecma International&lt;/a&gt; to formalize Java, but it soon withdrew from the process.&lt;sup id="_ref-1" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-1" title=""&gt;[2]&lt;/a&gt;&lt;/sup&gt;&lt;sup id="_ref-2" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-2" title=""&gt;[3]&lt;/a&gt;&lt;/sup&gt;&lt;sup id="_ref-3" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-3" title=""&gt;[4]&lt;/a&gt;&lt;/sup&gt; Java remains a proprietary de facto standard that is controlled through the &lt;a href="http://en.wikipedia.org/wiki/Java_Community_Process" title="Java Community Process"&gt;Java Community Process&lt;/a&gt;.&lt;sup id="_ref-4" class="reference"&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29#_note-4" title=""&gt;[5]&lt;/a&gt;&lt;/sup&gt; Sun makes most of its Java implementations available without charge, with revenue being generated by specialized products such as the Java Enterprise System. Sun distinguishes between its Software Development Kit (SDK) and &lt;a href="http://en.wikipedia.org/wiki/HotSpot" title="HotSpot"&gt;Runtime Environment (JRE)&lt;/a&gt; which is a subset of the SDK, the primary distinction being that in the JRE the compiler is not present.&lt;/p&gt; &lt;p&gt;On &lt;a href="http://en.wikipedia.org/wiki/November_13" title="November 13"&gt;November 13&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/2006" title="2006"&gt;2006&lt;/a&gt;, Sun released parts of Java as &lt;a href="http://en.wikipedia.org/wiki/Free_software" title="Free software"&gt;free&lt;/a&gt;/&lt;a href="http://en.wikipedia.org/wiki/Open_Source_Software" title="Open Source Software"&gt;open source&lt;/a&gt; software, under the &lt;a href="http://en.wikipedia.org/wiki/GNU_General_Public_License" title="GNU General Public License"&gt;GNU General Public License&lt;/a&gt; (GPL). The release of the complete &lt;a href="http://en.wikipedia.org/wiki/Source_code" title="Source code"&gt;source code&lt;/a&gt; under GPL is expected in the first quarter of &lt;a href="http://en.wikipedia.org/wiki/2007" title="2007"&gt;2007&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-1042199845463486797?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/1042199845463486797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=1042199845463486797' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1042199845463486797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/1042199845463486797'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/history.html' title='History'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-4587925317519331186</id><published>2007-03-21T23:33:00.000-07:00</published><updated>2007-03-21T23:34:59.024-07:00</updated><title type='text'>What is Java?</title><content type='html'>&lt;p&gt;&lt;b&gt;Java&lt;/b&gt; is an &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming" title="Object-oriented programming"&gt;object-oriented&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Programming_language" title="Programming language"&gt;programming language&lt;/a&gt; developed by &lt;a href="http://en.wikipedia.org/wiki/Sun_Microsystems" title="Sun Microsystems"&gt;Sun Microsystems&lt;/a&gt; in the early 1990s. &lt;a href="http://en.wikipedia.org/wiki/Java_application" title="Java application"&gt;Java applications&lt;/a&gt; are &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compiled&lt;/a&gt; to &lt;a href="http://en.wikipedia.org/wiki/Bytecode" title="Bytecode"&gt;bytecode&lt;/a&gt;, which at &lt;a href="http://en.wikipedia.org/wiki/Runtime" title="Runtime"&gt;runtime&lt;/a&gt; is either &lt;a href="http://en.wikipedia.org/wiki/Interpreter_%28computing%29" title="Interpreter (computing)"&gt;interpreted&lt;/a&gt; or compiled to native &lt;a href="http://en.wikipedia.org/wiki/Machine_code" title="Machine code"&gt;machine code&lt;/a&gt; for execution.&lt;/p&gt; &lt;p&gt;The language itself derives much of its &lt;a href="http://en.wikipedia.org/wiki/Syntax#Syntax_in_computer_science" title="Syntax"&gt;syntax&lt;/a&gt; from &lt;a href="http://en.wikipedia.org/wiki/C_%28programming_language%29" title="C (programming language)"&gt;C&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/C%2B%2B" title="C++"&gt;C++&lt;/a&gt; but has a simpler &lt;a href="http://en.wikipedia.org/wiki/Object_model" title="Object model"&gt;object model&lt;/a&gt; and fewer low-level facilities. &lt;a href="http://en.wikipedia.org/wiki/JavaScript" title="JavaScript"&gt;JavaScript&lt;/a&gt;, a scripting language, shares a similar name and has similar syntax, but is not directly related to Java.&lt;/p&gt; &lt;p&gt;Sun Microsystems provides a &lt;a href="http://en.wikipedia.org/wiki/GNU_General_Public_License" title="GNU General Public License"&gt;GNU General Public License&lt;/a&gt; implementation of a Java &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compiler&lt;/a&gt; and Java &lt;a href="http://en.wikipedia.org/wiki/Virtual_machine" title="Virtual machine"&gt;virtual machine&lt;/a&gt;, in compliance with the specifications of the &lt;a href="http://en.wikipedia.org/wiki/Java_Community_Process" title="Java Community Process"&gt;Java Community Process&lt;/a&gt;, although the class library that is required to run Java programs is not &lt;a href="http://en.wikipedia.org/wiki/Free_software" title="Free software"&gt;free software&lt;/a&gt; yet.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-4587925317519331186?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/4587925317519331186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=4587925317519331186' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4587925317519331186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/4587925317519331186'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/what-is-java.html' title='What is Java?'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5252893760990180746.post-3416964630691213746</id><published>2007-03-21T22:25:00.000-07:00</published><updated>2007-03-21T23:25:10.135-07:00</updated><title type='text'>Introduction to Java Swing</title><content type='html'>&lt;span style="font-size:-1;"&gt;Swing is a GUI toolkit for Java. Swing is one part of the Java Foundation Classes (JFC). Swing includes graphical user interface (GUI) widgets such as text boxes, buttons, split-panes, and tables. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5252893760990180746-3416964630691213746?l=artofjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://artofjava.blogspot.com/feeds/3416964630691213746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5252893760990180746&amp;postID=3416964630691213746' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3416964630691213746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5252893760990180746/posts/default/3416964630691213746'/><link rel='alternate' type='text/html' href='http://artofjava.blogspot.com/2007/03/java-programming-basic.html' title='Introduction to Java Swing'/><author><name>themaster</name><uri>http://www.blogger.com/profile/17141864107870357966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
