brief history of java

Description

This is an example of brief history of java. This document is useful for studying brief history of java.

Reviews
Stats
views:
578
rating:
not rated
reviews:
0
posted:
7/23/2008
language:
English
pages:
0
Java for Web Page Production ~ Java for Web Page Production ~ Session 1 - Learn about Java, and create your first Applet << Back to Course Outline Contents Introduction Health & Safety Registration Course aims & Objectives Session 1 Overview What is a program? A brief history of Java How can Java be used What is an Applet? How can applets spice up your web pages? Compilers & Interpreters; Bytecode Java and your browser - the JVM The Java JDK (Java Development Kit) Creating your first Applet Summary & Further Sources =+[(-:] BREAK [:-)]+= Introduction to the basic JDK tools Introduction Welcome to the course in Java for Web Page Production, held at Northampton College. Your course tutor is Simon Huggins, who will be taking you through and facilitating your learning of the details of this course. The course lasts for ten weeks, with each session running to approximately three hours. Each session starts promptly at 6.00pm in order to prevent finishing too late. Refreshments will be available from 5.45pm, with a short break at around 7.45 for approximately fifteen minutes. Each session will start with an recap of the previous session, and overview of the topics to be covered in the coming session, and at the end, a summary of that session. Each session will be taught using a mixture of seminar-style teaching, demonstration using a computer-linked projector, and a chance to try out what has been learned with a practical session. A bit about me - Page 123 - Java for Web Page Production I work locally in Northampton with a company called Scottish And Newcastle Retail, which owns a few thousand pubs, restaurants, and hotel lodges. They own pubs like the Rat & Parrot, Britannia, Greyhound, and Red Lion at Brafield. I am an Analyst / Programmer working with a system called PeopleSoft that deals with accounts and Human Resources. It uses its own proprietary programming language designed for business working. Having graduated from the University of Sheffield in 1995, I had a good knowledge of object-oriented concepts, and immediately took up a remarkable new programming language called Delphi which is still going strong today with version 6. It took the reins from Visual Basic and introduced a visual programming environment with database facilities, and a proper structured and object-oriented programming language. The AWT (Advanced Windows Toolkit) is the library in Java that gives you the tools to build a user interface (i.e. buttons, text-boxes, labels, pictures etc.) so that you can design how your program will look to the user. This was based largely on the design of Delphi's component scheme. Thus, it was a natural progression to look at Java for future programming projects. I started with a language called JavaScript to create fancier web pages - specifically to create interactive web-based crosswords from my puzzle-creation program, WordPuzzle Pro. The limitations of this language lead me naturally on to Java, which I have been researching and creating sample applications, over the last year. I have a web site, located at http://www.simonhuggins.com which features my main interests, including the writing of software to be distributed across the internet, mostly written in Delphi. In case you're interested, i'm married, with two inherited children and now i'm a sortof-grandfather! At the tender age of 29! Photos are on my web site. I also have an interest in poetry, writing fiction, and somehow fell into creating a web site for fans of the US TV Series Beauty And The Beast that was around in the late eighties / early nineties. Just goes to prove that, even in this day and age, programmers are still often strange creatures. Health & Safety Information will be handed out separately regarding Health & Safety. Registration Registration will take place at the start of this session. At the start of each subsequent session, you will be required to sign a register to confirm your attendance. - Page 223 - Java for Web Page Production Course aims and Objectives The Java For Web Page Production course aims to give the attendees a good grounding of programming fundamentals, and specifically in the use of the Java programming languages to create Applets (programs that can be included in web pages). At the end of the course, course participants should:       Be able to create simple applets for the purpose of attracting attention to web pages - for example, through moving text, and simple games. Understand the capabilities and restrictions of Java applets Understand basic programming principles, including some concepts of objectorientation. Be familiar with the basic tools of the Sun JDK in order to compile and test Java classes. Understand how to embed a Java Applet to run from a web page Understand the basic concepts of using an Integrated Development Environment for larger-scale programming projects Be able to package classes up into a class library for web distribution Session One Overview In this session we will be covering:        What is a program? A brief introduction to what a program is, and the various styles of programming. Also a brief history of programming languages leading up to the introduction of Java. A brief history of Java A description of the evolution of Java from its earliest days as a language called Oak. How can Java be used? An overview of the different current and future possible uses of Java What is an applet? Overview of an applet in Java, it uses, and how it differs from an Application. How applets can spice up your web pages Some examples of how applets can bring more interest and functionality to your web pages than mere HTML alone. Java and your browser - the JVM An explanation and demonstration of how Java integrates with an Internet Browser through the Java Virtual Machine, and how this enables a degree of platform independence. Compilers & Interpreters - Bytecode The difference between Compilers and Interpreters, and how Java sits in the middle with bytecode. The JDK (Java Development Kit) The Java Software Development Kit - what it is, where to get it, how to install it, where it's used - Page 323 - Java for Web Page Production    Introduction to the basic JDK tools Introduction to the tools within the JDK - particularly the compiler and applet viewer. Also note on file paths. Creating your first applet An example of how to create an applet - walked-through by the course tutor so that students can follow the example and create their own applet using the tools of the JDK. Summary and further sources Summary of the session, with some examples of further resources (typically web-based) which students can research to broaden their knowledge of the subject areas covered within the session. What is a program? A program is a list of instructions that described a task that you wish the computer perform. In order to specify precisely your intentions, the instructions are limited to a number of core words called keywords. For example, a common keyword is IF which is used to tell the computer you wish to do something, only if something else has happened. This language is not understood by the computer, which uses a very fast and simplified language designed to work well with the electronic components of your computer. This is called machine code or machine language. Few people program using this directly, unless of extreme masochistic tendency. This means that you need something that will translate the program that you have written in to machine code. This is done using a compiler. Instead, you could just translate the program straight from the source code without converting it to machine code. This would be done by an interpreter. Java uses something in-between the two of these, which will be described later. Large programs can get very difficult to follow, and are thus split up into logical steps, each of which are called procedures. These procedures may be able to be reused in different parts of your program, thus reducing the complexity and time it takes to write your program. Most programming languages come with a number of commonly used procedures, so that a lot of the work has been done for you. These procedures are packaged-up and put into a library. Finally, most modern languages are in some way object-oriented. The principles of this are quite simple - imagine an object (e.g. a bicycle). It is an object. It can do various things - e.g. go, brake, accelerate and change gears. Each of these is a procedure that can be performed with the bicycle. But associated with the bicycle is various information - e.g. the make, model, current acceleration, colour, etc. These are known as attributes. - Page 423 - Java for Web Page Production Now, let's say you wish to design a souped-up version of the sample bike - more gears, different colour, and with a bell!!! With object-orientation, rather than redoing everything again, you would borrow the design of the old bike, and just add to and replace various aspects of the object - e.g. a new attribute called bell and a new procedure called ring. Saves a lot of time. This principle is known as inheritance. Finally, lets says we have a new object called shop. This has 50 spaces for bicycles, but until they are bought, who knows what they will be? So, we define 50 spaces that can hold a bike object (all of which share similar basic attributes and procedures) and pop different types of bikes into and out of those spaces as they are needed. In this way, we may not know in advance that the bike has a bell, but we know it can go, break, accelerate, and change gears! This principle is known as polymorphism - just to make it sound clever! This is the basics of object-oriented programming. You build programs to reflect 'things' or objects that exist in the task or tasks you are trying to achieve. We'll look at these concepts later and see how they can be useful in real programming. A brief history of computer languages In that late 1940's, a German engineer called Konrad Zuse sought a better way to program computers. He developed a system of symbols that could be used to solve problems step-by-step, called Plankalkul. Alan Turing wrote a shorthand code for writing programs on the Mark I computer but still pretty indecipherable to the untrained. John Mauchly then developed Short Code which allowed equations to be entered using a special code. Grace Hopper, inspired by this, became the first real advocate of High Level Languages - languages that are closer to language that humans might use to describe tasks. One of the first widely-used languages was IBM Fortran, developed in the 1950's, working with mathematical data. The language ALGOL was developed in 1958, but was never as well accepted as Fortran. COBOL (Common Business Oriented Language) was created in 1960, to serve mainly large businesses and governmental institutes. COBOL is still widely used in industry today, especially on large mainframe computers. In 1964, BASIC (Beginners All-Purpose Symbolic Instruction Code) was released, making programming accessible to many more people. Variants are still in wide use today - e.g. Microsoft Visual Basic. - Page 523 - Java for Web Page Production In 1965, a language called PL/1 was introduced to be a 'cure-all' language. Being overly complex, it met with only limited success. Simula I and 67 had little impact at the time, but introduced the early concepts of object-oriented programming that underpins most languages, including Java, used today. In 1971, a Swiss professor called Niklaus Wirth introduced a teaching language called Pascal, which introduced important concepts in structured programming to reduce errors and increase readability. C was created in 1972, intended as a lower-level language for writing operating systems for different computers, although its uptake has been far more universal than intended. On the surface, Java and C programs look similar - e.g. blocks are denoted by curly brackets. Smalltalk, designed in the late 1970's, was the biggest breakthrough in many years, being both graphical and object-oriented. The concepts developed in Smalltalk contribute largely to modern languages such as C++ and Java. ADA is used by the US Department of Defense, and was released in the early 1980's it is large and very complex. C++ was released in the mid-1980's to extend the popular C language to include object-oriented concepts. Finally, Java was released in the mid-1990's to an enthusiastic audience. Soon to arrive is Microsoft’s answer to Java, the .Net platform, which allows different languages to produce the same code, ultimately on different platforms. From this, you can clearly see that Java is only the latest in a whole history of languages. It may be that as Java is widely used, better ways of working will be discovered that fit how technology progresses. Java has the advantage in that it preempted a flourishing internet industry, so was in the right place at the right time, with a product that was solidly built and has thus stood the test of time. A brief history of Java Java was originally started as an elite project codenamed Green to find a way of allowing different electronic devices such as TV-top boxes and controllers to speak a common language. This was originally dubbed Oak but failed to find a niche despite its potential. In 1993, the first web browser Mosaic was born, revolutionising the internet from an environment for educators and scientist to one taken up by a ever-increasing crosssection of people from all walks of life. - Page 623 - Java for Web Page Production This changed the (now a company called First Person) team's focus to producing a software system for online multimedia. The decision was made to give the source away free on the internet. The first oak-ready browser, WebRunner was created with the first ever applet, showing a character called Duke (which can now be found throughout Sun's Java web site) waving back at his parents. Sun decided to rename the language, to become Java. WebRunner became HotJava due to a trademark conflict, and then in 1995, Netscape signed a deal with Sun to incorporate Java technology in its hugely popular web browser. The uptake has increased ever since. Java has now evolved into a programming language that can be used across different computers, electronic devices, and internet browsers without having to produce different versions of the program to suit each one. This has always been a major problem for the software development industry, or lone programmer wishing to reach the widest possible audience. How can Java be used? In this course, we will be concentrating on using Java to attract interest in your web pages, and giving you the fundamental understanding of programming to go on to create Java Programs to suit your own purposes. However, Java has been taken up voraciously by many developers across all major industries, and the need for Java programmers has thus rocketed, such that demand far exceeds supply. For this reason, Java programmers are currently earning good salaries (typically £30-£40k+) and enjoying being on the cutting edge of technology. So why has Java been taken up by big business as well as the small developer producing a web site, or simple applications to share with net surfers? The biggest reason is interoperability or the ability to write a Java program for one computer, and be able to run it on virtually any computer that can run Java programs (and due to Java's popularity, most computers can) with little or no change in the program. This might seem an obvious need, but until Java, there was no universally accepted language that could work across different types of computers. Java can be run on computers called web servers - these are the computers that you are linking to when you are browsing the web, and contain web pages to send back to your computer, or instead, programs that determine how the web pages should look when they are viewed on your computer. So Java can be run on servers as well as clients (that's your computer when you're browsing the internet) - another advantage. It can also be used to link to stores of data called databases, it can control how to communicate with other computers across the internet in a variety of ways, it can create real-time three-dimensional games that run from your web browser. In short, it can cope with the majority of common computing tasks that you choose to throw at it. - Page 723 - Java for Web Page Production Finally, Java can also be used to program electronic devices - and as a result of its innate ability to talk to other computers across the internet, this allows for devices that can talk to each other, or that can be controlled across the internet from, say, your web browser. Uptake for this technology has been quite slow, largely due to this being a fairly young and volatile part of the industry, but is increasing. So what are it's shortcomings? Well, Java is owned by Sun microsystems, who thus control how it develops, although they do generously allow anybody to freely download the tools required to get going with programming in Java (the JDK - Java Development Kit). This means that other companies who wish to produce competing products (e.g. Microsoft with its .net project) will naturally wish to squash its use in industry as much as possible. For example, in the Microsoft's latest Windows XP operating system, Java does not come bundled with the web browser as it has done before - you will need to download Java from Sun's web site before Java Applets will work OK. However, many computer manufacturers such as Dell and Compaq have chosen to pre-load Java onto their new PCs, so this may not be a real problem. Java has traditionally had a reputation for being slow. This is inevitable, as the programs must be independent of the different languages that different computer processors understand (known as machine language or machine code). However, as processor speeds have increased, and Java technology has improved (with such help as Just-In-Time Compilers - where the code gets converted into machine code just when the Java program is about to be run) this barrier has been less noticeable. Despite Microsoft's competition, Java looks set to maintain prominence in the computing world - partly due to its continuing evolution, partly because a lot of people are now using it, and partly because it has such a solid basis on which to build virtually any type of application, aided by the frenzy of activity in trying to get anything and everything connected to the internet. Indeed, a recent report released by Evans Data Corp [eWeek 16-08-2001] indicates that in the US, Java is set to overtake the use of both C++ and Visual Basic next year, with an estimated 60% of developers using Java. What is an Applet? An applet is a Java program which can be put on a web page amongst the rest of your content . If you browse the web regularly, you will undoubtedly have come across examples of Java Applets - they tend to start as grey boxes which burst into life once the Java program has been loaded and starts. Creating an applet is a fairly simple process:    Create your web page and put in a special tag to show where the applet is to go, and how big it is to be. Create a Java class or set of classes to perform the task you require Compile / Debug the Java class until it does not show that your source code has an error Test the Java class using either Appletviewer or a web browser. - Page 823 - Java for Web Page Production    Continue with the Debug / Test phases until the applet works as you expect Package the class into a JAR file (optional) Copy the web page and the applet (e.g. as a JAR file) to the web server, where your web site is located. A more technical explanation of an Applet is that it is a Class (or program) that inherits (reuses) the details of the Applet Class, and uses and extends these details to form an application that can be used within a Java-enabled web browser. The first sample of a Java application given later in this session will demonstrate this more effectively than this somewhat vague description. How applets can spice up your web pages So what's the point? There are alternatives to Java. Let's go through a few of them and highlight a few pros and cons:- Platform Pros Cons Java Free; Well-used; Not compiled, so fairly Extensive capabilities; slow; Daunting to the Lots of good on-line beginner; resources; MultiTools for Java tend to be Platform; Programmable; geared to the programmer. Transferrable skills. Commercially supported; Costs £300+; Fast (to paint & load) Restricted animations; Geared to Programmability; presentation; available on Updates infrequent; several platforms; Skills not transferrable to Programmable if other types of purchase developer programming version. On-line resources limited; Free; Special graphical Little used; effects, including moving Incompatabilities between objects; Programmable browsers; Limited effects and programmability. Free; Well used and known; Good on-line resources; Limited capability; Relies Programmable; on page being static; Good for form-filling and triggers, Free tools available; Animations or still Not programmable; GIF format is patented; Image Flash DHTML JavaScript / HTML GIF animations - Page 923 - Java for Web Page Production pictures can be animated, but cannot itself move. It is not uncommon to mix these methods, even in the same page, according to the suitability to the task - e.g. use GIFs for banner ads, JavaScript and HTML for formfilling, and Java for a more interactive section, or news-banner. Common uses for Java Applets might be to create interactive games (e.g. arcade games, crossword or other word-puzzle, etc.), to show scrolling banner-style text, to create graphical eye-catching animations, to connect to another computer (e.g. using a Telnet or Chat session), and so on... Compilers and interpreters; Bytecode When you write your list of instructions for the computer to perform a task, called a program, you have to write it using one of the many available programming languages available today - Java, C, C++, Pascal, BASIC etc. etc. Once you have created your instructions, you will need to start a program called a compiler, which will take your instructions, an translate it into a form understood by the computer that the program is being created on - effectively, it translates a language you can understand reasonably well to a language the computer can understand. Many compilers have an in-between stage, where the original program (source code) is converted to something called object code - this is often used to package up procedures into libraries, so that they can be distributed to other programmers, without them being able to see (and thus copy) the original source code. It also tends to be a lot smaller in size than the original source code, and can also be scrambled for extra security. This object code can then be converted into machine code. Java goes one step further. When a Java program is compiled, it produces a language known as bytecode - which is quite similar in principle to object code. This bytecode can be packaged into libraries, but even more useful, the same bytecode will be created whichever computer is being used. Thus, the bytecode can be used on any computer, and is a lot more efficient to execute than the original source code, if not quite as fast as the computer's machine code. The final stage is that the bytecode is read by the Java Virtual Machine, and translated to machine code as it reads the bytecode. Thus, the bytecode can be used on any computer that has a copy of the Java Virtual Machine on it - i.e. most computers with Web Browsers. Java and your browser - the JVM - Page 1023 - Java for Web Page Production The Java Virtual Machine is a rather grand sounding name for quite a simple concept. In days gone by, there were several languages (as we saw earlier), each of which would compile (produce) different final machine code (i.e. language that a computer can understand). Moreover, each type of computer, and operating system (e.g. Windows 3.1, Windows 95, Windows 2000, Unix, MacOS, etc.) would need to produce different machine code for the specific machine/operating system combination. In simple terms, each computer speaks a different language, and programmers were writing in different languages too. And then everyone wanted the different programs/computers to talk to each other. Mayhem and confusion ensued. The Java Virtual Machine and the Java language sought to remove this confusion. The Java Virtual Machine is a translator that takes the highly optimized (i.e. designed to execute as quickly as possible) Java Bytecode (described in the previous section) and converts it into machine language that is understand by a specific computer. Thus, every computer that has a Java Virtual Machine can run Java programs. And most computers (desktops, laptops, servers and hand-helds) do have a JVM, because it makes the computer more appealing, as it can then execute a lot of programs written in Java. In fact, it is possible to take programs written in other languages than Java, and convert them to produce Java ByteCode - thus, the original language you wrote the program instruction in, does not necessarily even need to be Java. There are obviously complications with this! One note - after version 1.1 of Java, the Java Plug-in was introduced, which introduced new facilities for better Java applications. This 'plugs-in' to your browser so that it can run Java applications, but web pages that make use of v1.1 or later must use applets in a slightly different way. One further advantage of this is that although Microsoft has not updated the version of the Java JVM in its browsers since version 1.1, the plug-in it can be downloaded from Sun to give the latest enhancements, and as a plug-in, can be downloaded automatically when your browser detects it is needed. The JDK (Java Development Kit) The Java Development Kit (JDK) is a set of programs that form the basis of writing applications in Java. They are available for free (downloadable from the java.sun.com site). The JDK also contains documentation, samples, and a full class library that lets you perform a host of tasks on your computer. The tools include a compiler for translating the Java source language to bytecode, a Java Application (bytecode) runner, a Java Applet (bytecode) runner, a documentation tool, a library packaging tool, several security tools, and several other smaller utilities. - Page 1123 - Java for Web Page Production As the JDK is freely available, we will be using this for the majority of our work on this course. Integrated Development Environments (IDEs) QuickCup There are also available several tools that build on the JDK to provide what is known as an IDE (Integrated Development Environment). This combines several of the tools, plus form-designing and on-line help in a single application. This can be very useful for larger-scale projects, but can take some getting used to. Sun provide a free-to-use application called Forte for Java Community Edition, and Borland provide an excellent tool called JBuilder 5 PE (Personal Edition) - some instructions for installing this are available as extra documentation for this course. There are several other products from industry leaders such as IBM, MicroSoft, and Symantec. On this course, we will be utilizing a cut-down IDE which is adequate for the purposes of creating Java Applets for the web, and much easier to learn than the tools described above. The application is called QuickCup and has been written by the tutor of the course with teaching in mind. The application is FreeWare, so feel free to distribute it to others (but not for profit) or use it yourself at home. The application QuickCup lets you create Java projects, into which you can add any java / html etc. source files, and edit, compile, test and package them for distribution. However, it doesn't cater for more involved tasks, such as integrated debugging, form design, and context help. More on QuickCup later. Introduction to the basic JDK tools The JDK has a number of tools. These are listed below. The most important program must be javac which checks your source code to see if it is correct, and if it is OK, generates java bytecode. You can then test that this works OK using either the appletviewer program, or direct from your web browser! Pretty straightforward! Text Editors It may seem odd that one of those tools is not a source code editor! This is because an editor is something that tends to be an individual choice, and every computer has its own standard text editor(s), so this is not a necessary part of the JDK tools. A text editor is a program, rather like a word processor, that allows you to type in source code (e.g. Java language commands), save them to a disk file, print them out, and change them to correct problems or add extra commands. The standard text editor for PCs running a variant of windows is the notepad program. To start-up notepad, click on the Start button at the bottom-left hand corner - Page 1223 - Java for Web Page Production of the desktop, click on the Programs menu, then the Accessories menu to the right, and finally click on the Notepad application. You may choose to use Notepad in your own development, as it is available on all PC Windows computers. However, in this course, we will be using the QuickCup IDE. Program javac java / jre appletviewer Description The Java compiler. Converts Java Source Code into bytecode. The Java interpreter. Takes bytecode (stored in .class files) and executes it in a language that the computer understands. As java, but takes a HTML file and runs an Applet as it would appear in a browser. Java ARchiver program. Creates JAR files, which are libraries of multiple Java Classes and resources, packaged up into a single compressed file. Great for distributing an application, for example, via the internet. Java source code documentation generator program. Creates HTML documentation based on the source code, and the comments within the source code. jar javadoc There are several other applications within the JDK tools, but these are for advanced use - e.g. relating to security, testing server-based Java applications (servlets), Remote Method Invocation, Debugger etc. Creating your first Applet     Click on the Start menu on your Windows desktop Click on the Programs menu Click on QuickCup v1.0 Click on QuickCup This should launch the QuickCup IDE, and automatically load the sample project, TextBurst. This application demonstrates a simple Applet to show some text whizzing towards and away from you periodically, changing colour gradually as it moves. It could, for example, be used as an eye-catching heading on a web page. The main QuickCup screen is shown below as a sample:- - Page 1323 - Java for Web Page Production To look at the JAVA source code that gives the instructions for how to do this, click on the TextBurst.java tab. The source code should be as follows:- Java Source Code /* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** TextBurst sample applet by (c) Copyright 2001 Simon Huggins For demonstration purposes only. You may use this applet on your web site, but it cannot be sold in either its original or altered state. This original notice must be included in all versions of the applet distributed, even if altered. The author accepts no liability for any difficulties or loss arising from use of this applet. It is primarily intended for demonstration purposes. Change History ~~~~~~~~~~~~~~ 17-Sep-2001 v1.0 Release version - Page 1423 - Java for Web Page Production */ /* ** Import section - tells the compiler where to look for different classes ** used within this file */ import java.awt.event.*; import javax.swing.*; import java.awt.*; /* ** Defines a class called TextBurst which takes the basic JApplet ** class as a template, and adds to it to create our Applet. ** It also implements something called ActionListener which is an ** Interface for the purposes of checking when an event has occurred. */ public class TextBurst extends JApplet implements ActionListener { static int maxChangeAmount = 20; // Constant value to define the // max. speed of colour change Timer timer; // Used to update the display ever 50ms JLabel theLabel; // The label that shows the text int fontSize = 2; // Initial font size (in points) int fontDirection = -1; //How much the font size will shrink (minus) or grow by int maxFontSize; // Maximum font size int redAmount = maxChangeAmount; int redDirection = - Math.round((float)(Math.random() * maxChangeAmount + 1)); int greenAmount = maxChangeAmount; int greenDirection = - Math.round((float)(Math.random() * maxChangeAmount + 1)); int blueAmount = maxChangeAmount; int blueDirection = - Math.round((float)(Math.random() * maxChangeAmount + 1)); Color appletBgColor; //background color for the applet /* ** Initialize the applet - i.e. set up any values before processing begins */ public void init() { String burstText = getParameter("burstText"); // get the text parameter from the HTML page timer = new Timer(80, this); // Define a timer so actionPerformed gets called every 50ms String fontSizeString = getParameter("maxfont"); // get font size as a string from HTML if (fontSizeString != null) // check if the parameter was used maxFontSize = Integer.parseInt(fontSizeString); // if so, convert it to an integer else maxFontSize = 20; // if not, use 20 as a default. String appletColorStr = getParameter("bgcolor"); // get color as a string from HTML if (appletColorStr != null) { // check if parameter used - Page 1523 - Java for Web Page Production appletBgColor = new Color(Integer.decode(appletColorStr).intValue()); //decode hex } else appletBgColor = Color.lightGray; // if not, use light grey. theLabel = new JLabel(burstText,SwingConstants.CENTER); // Define a centred label theLabel.setForeground(new Color(redAmount,greenAmount,blueAmount)); // Set its colour theLabel.setFont(new Font("Helvetica",Font.BOLD,fontSize)); // and its font type getContentPane().setBackground(appletBgColor); // Set the Applet's background color getContentPane().add(theLabel); // and add it to the applet } /* ** Defines what should happen when the applet starts - e.g. after return to page */ public void start() { if (!timer.isRunning()) timer.start(); // start the timer running } /* **Defines what should happen when the applet stops - e.g. when leave the page */ public void stop() { if (timer.isRunning()) timer.stop(); // and stop it again } /* ** ActionListener Interface method called by the Timer every 50ms */ public void actionPerformed(ActionEvent e) { /* If the font size reaches 20 or 2, reverse the direction of shrinking / growing */ if ((fontSize==maxFontSize) || (fontSize==2)) fontDirection = fontDirection; fontSize += fontDirection; // shrink or grow the fontSize by this amount theLabel.setFont(new Font("Helvetica",Font.BOLD,fontSize)); // change the font size /* These sections change the three colours in a similar way to the font size */ redAmount += redDirection; if ((redAmount<=10) || (redAmount>=250)) { redDirection = -redDirection; redAmount += redDirection; } greenAmount += greenDirection; if ((greenAmount<=10) || (greenAmount>=250)) { greenDirection = -greenDirection; greenAmount += greenDirection; } blueAmount += blueDirection; if ((blueAmount<=10) || (blueAmount>=250)) { blueDirection = -blueDirection; blueAmount += blueDirection; } theLabel.setForeground(new Color(redAmount,greenAmount,blueAmount)); // set the colour - Page 1623 - Java for Web Page Production } /* ** Define information about the applet - in Appletviewer, see Applet | Info menu */ public String getAppletInfo() { return "Title: TextBurst\nAuthor: Simon Huggins\nDisplays a text burst effect"; } } If you click on the TextBurst.htm tab, this shows a sample web page that contains this applet, and should be as follows:- HTML Page to launch above applet (works with MicrosoftTM Internet Explorer) TextBurst 1.0

Following will work on a web page run from Internet Explorer:-

No Java 2 SDK, Standard Edition v 1.3 support for APPLET!!


The source. The QuickCup toolbar - Page 1723 - Java for Web Page Production If you hover your mouse over the buttons on the toolbar, you will see that each has a name - the first (should be greyed) is Save (disk ), and on its own. This saves any changes to the project and/or source files within the project. The remaining buttons are grouped together, as they act on the source files within this project. They are (from left to right): Compile (icon: lightning) - Check the Main Java File and report any errors. If OK, convert the source code into bytecode (to the file TextBurst.class) which is the file used by the JVM (Java Virtual Machine) for use within your web pages. Launch HTML Page (icon: globe) - View the main HTML file and any applet within it using the default Internet Browser (usually Internet Explorer). Launch Applet Viewer (icon: eye) - If you do not have a browser installed, or wish to test the applet's functioning without using a web page, you can use this utility. Launch Java Application (icon: cup) - If your Java program is designed as an application rather than an Applet (i.e. designed to work outside the browser environment), then you can launch / test the application using this button. We will not be looking any further at this in this course.    Compile the Applet To compile the applet - i.e. check the source contains the correct language (syntax) for the instructions to be understood, and convert those instructions to Java Bytecode click on the Compile ( ) button. This will show the Console window, which shows any messages from the compilation process. No messages means no errors. Note that you can execute these commands outside of the QuickCup IDE using the command-line. If you are unfamiliar with application development in this way, then it is best not to attempt this. However, you can see the JDK tools that are being executed to perform the tasks in the console window. A successful output is shown below:- - Page 1823 - Java for Web Page Production Test the HTML web page Now that the bytecode has been generated by the compiler, you will be able to use it from the sample web page:    Click back on a grey part of the main QuickCup window or press Alt+Tab to put the console window into the background. Click on the Launch HTML Page icon ( ) to launch the default HTML browser Watch the results! Close the browser window, or Alt+Tab back to QuickCup when you have finished watching. Change the parameters from the web page We are now going to change one of the parameters (information going in) to the applet from the web page. Specifically, we will change the text that is displayed in the applet:  Click on the TextBurst.htm tab from the main QuickCup window. This should show the HTML web page (starts with ) that launches the applet. - Page 1923 - Java for Web Page Production       Look about 2/3 down the page. There's a list of lines that start
Related docs
History of Java
Views: 411  |  Downloads: 19
A Brief History of the United States
Views: 15  |  Downloads: 0
A BRIEF HISTORY OF JAVA TECHNOLOGY
Views: 1  |  Downloads: 0
A BRIEF HISTORY OF GROOVY
Views: 13  |  Downloads: 1
A- Brief- History-of- India
Views: 18  |  Downloads: 6
A Brief Introduction to Java
Views: 61  |  Downloads: 21
Brief History of C++
Views: 42  |  Downloads: 4
Java Head
Views: 12  |  Downloads: 2
Introduction to java
Views: 20  |  Downloads: 8
Learning Java
Views: 28  |  Downloads: 12
java network security
Views: 1335  |  Downloads: 40
JAVA
Views: 69  |  Downloads: 0
premium docs
Other docs by Beunaventura L...
Laws Against Abortion
Views: 1662  |  Downloads: 17
Insurance Claims Investigations
Views: 1155  |  Downloads: 16
Injury Compensation Claims
Views: 788  |  Downloads: 16
Handling Claims
Views: 1075  |  Downloads: 15
From Insurance Claim
Views: 1051  |  Downloads: 12
Compensation Claim
Views: 775  |  Downloads: 4
Class Action Claim
Views: 646  |  Downloads: 0
Claims for Injury
Views: 510  |  Downloads: 3
Automobile Insurance Claims
Views: 848  |  Downloads: 12
Auto Insurance Claim Settlement
Views: 1038  |  Downloads: 8
Auto Accident Lawsuit
Views: 777  |  Downloads: 2
Free Living Will Forms
Views: 2963  |  Downloads: 51
7th Amendment
Views: 2375  |  Downloads: 3
Safe Drinking Water Act
Views: 451  |  Downloads: 8
Constitutional Amendment
Views: 97  |  Downloads: 0