Professional Documents
Culture Documents
The main aim of this project is to propose a possible new technique for
watermarking on images.
Digital Watermarking is a robust and efficient digital image water marking algorithm
using the Fast Hadamard Transform is proposed for the copyright protection of digital
images. This algorithm can embed or hide an entire image or pattern as a watermark
such as a company’s logo or trademark into the original image. The performance of
the proposed algorithm is evaluated using the Stirmark, which consists of 90 different
types of image attacks. Results show that the proposed algorithm is very robust and
can survive most of the stirmark attacks.
Organizational Profile
INTRODUCTION
Overview of The Project
PRESENT SYSTEM: -
The Hadamard transform has more useful middle and high frequency
bands than several high gain transforms, such as DCT.When compared with the
DCT, it found to be more robust against various attacks .It also offers a significant
advantage in term of a shorter processing time and the ease of hardware
implementation than many common transformation techniques.
Requirement Specifications: -
HARDWARE REQUIREMENTS: -
SOFTWARE REQUIREMENTS
One of the most difficult tasks is that, the selection of the software, once
system requirement is known is determining whether a particular software package
fits the requirements. This section first summarizes the application requirement
question and then suggests more detailed comparisons.
• Operating System -------- Windows 2000 or later
0
0
0
0
0
0
0
0
0
0
DESIGN PRINCIPLES & EXPLANATION: -
With the advent of the Internet, the online purchasing and distribution of
digital images can now be performed relatively easily.However, there exists one
major problem associated with the distribution of any digital images is the important
issue of copyright protection and the proof of rightful ownership.Over the past few
years, the technology of digital watermarking has gained prominence and emerged as
a leading candidate that could solve the fundamental problems of legal ownership and
content authentications for digital multimedia data(e.g. audio,image,and video).
[V]= Hn [U] Hn
N
1.1 Digital Watermarking
• Imperceptibility:
• Robustness:
• Inseparability:
After the digital content is embedded with watermark, separating the content from
the watermark to retrieve the original content is not possible.
• Security:
The digital watermarking techniques prevent unauthorized users from detecting and
modifying the watermark embedded in the cover signal. Watermark keys ensure that
only authorized users are able to detect/modify the watermark.
Requirements of watermarks
• Copyright Protection:
Digital watermarks can be used to identify and protect copyright ownership. Digital
content can be embedded with watermarks depicting metadata identifying the
copyright owners.
• Copy Protection:
Digital content can be watermarked to indicate that the content cannot be illegally
replicated. Devices capable of replication can then detect such watermarks and
prevent unauthorized replication of the content.
• Tracking:
Digital watermarks can be used to track the usage of digital content. Each copy of
digital content can be uniquely watermarked with metadata specifying the authorized
users of the content. Such watermarks can be used to detect illegal replication of
content by identifying the users who replicated the content illegally. The
watermarking technique used for tracking is called as fingerprinting.
Tamper Proofing:
Digital watermarks, which are fragile in nature, can be used for tamper proofing.
Digital content can be embedded with fragile watermarks that get destroyed whenever
any sort of modification is made to the content. Such watermarks can be used to
authenticate the content.
• Broadcast Monitoring:
Digital watermarks can be used to monitor broadcasted content like television and
broadcast radio signals. Advertising companies can use systems that can detect the
broadcast of advertisements for billing purposes by identifying the watermarks
broadcast along with the content.
• Concealed Communication:
Visible watermarks are ones which are embedded in visual content in such a way that
they are visible when the content is viewed. Transparent watermarks are
imperceptible and they cannot be detected by just viewing the digital content.
In public watermarking, users of the content are authorized to detect the watermark
while in private watermarking the users are not authorized to detect the watermark.
Steganographic watermarking is the technique where content users are unaware of the
presence of a watermark. In non-steganographic watermarking, the users are aware of
the presence of a watermark.
Steganographic watermarking is used in fingerprinting applications while non
steganographic watermarking techniques can be used to deter piracy
The watermarks that are constructed using spatial domain approach are called spatial
watermarks. And they are embedded directly into an image's pixel data. Spectral (or
transform-based) watermarks are incorporated into an image's transform coefficients
(DCT, Wavelet).
The image-adaptive watermarks are based on the robustness of the basic spread-
spectrum technique
The work in image-adaptive watermarking shows that using visual models in the
embedding scheme can produce an even more robust watermark than the standard
spread-spectrum technique. Specifically, visual models allow the user to raise or
lower the amplitude of the watermark according to the image content (hence the
name, image-adaptive). These visual models provide thresholds for how much a
given transform coefficient can change, before such changes are noticeable under
standard viewing conditions. Below Figure shows the procedure for image-adaptive
watermarking
Figure 2.1 Image adaptive watermarking
This approach can embed more information bits and is relatively robust to attacks.
DCT and wavelet transforms are examples of Frequency Domain Approach. The
Discrete Cosine Transform (DCT) helps separate the image into parts (or spectral
sub-bands) of differing importance (with respect to the image's visual quality). The
DCT is similar to the discrete Fourier transform: it transforms a signal or image from
the spatial domain to the frequency domain.
It is also called as Private Watermarking. In this scheme the original cover signal is
required during the detection process. For example the integer value 10 could be
added to the integer value of the blue channel on every pixel to represent a ‘1’ and
perhaps 5 added for a ‘0’ value. Watermark extraction would be a simple matter of
subtracting the original image’s blue channel from the watermarked image’s blue
channel, and then it produces the watermark. The main issue is the requirement of the
original image at the detection/decoding stage.
2.2.4 Blind Digital watermarking
It is also called as Public Watermarking. In this scheme, the cover signal (the original
signal) is not needed during the detection process to detect the mark. Solely the key,
which is typically used to generate some random sequence used during the
embedding process, is required. This scheme can be used easily in mass-market
electronic equipment or software.
The key for embedding and detection of the watermark are identical. The detector
must know the required private key for extracting the watermark from the digital data.
The above Fig. depicts a general blind symmetric watermarking scheme. The term
blind”
indicates that the host signal (Original data) is not known at the watermark detector.
The watermark information is embedded into the host signal dependent on a private
key. With the same private key the watermark is detected from watermarked data.
2.2.6 Asymmetric Digital watermarking
One particular problem, even with state-of-the-art watermarking schemes, is that they
are Symmetric. This means that the keys necessary for watermark embedding and
detection are identical. Thus, the watermark detector knows all critical parameter of
the watermarking scheme that also allows efficient removal of the embedded
watermark.
Data
The above Fig. depicts a general asymmetric watermarking scheme. With aid of a
private
and a public key, the watermark is embedded into the host signal(Original data) . The
significant difference to the symmetric scheme is that all entities, embedding, attack
and detection, have access to the public key necessary for watermark detection.
Obviously, an attacker can try to use the knowledge of the public key to destroy the
embedded watermark information. Here, public key and private key is used to embed
the watermark. Public key is used to detect and attack the watermark. So, without
knowledge of private key it is not possible to completely eliminate the embedded
watermark.
A fragile mark is designed to detect slight changes to the watermarked image with
high probability.
A fragile watermark is a mark that is readily altered or destroyed when the host image
is modified through a linear or nonlinear transformation. Fragile marks are not suited
for enforcing copyright ownership of digital images; an attacker would attempt to
destroy the embedded mark and fragile marks are, by definition, easily destroyed. The
sensitivity of fragile marks to modification leads to their use in image authentication.
That is, it may be of interest for parties to verify that an image has not been edited,
damaged, or altered since it was marked.
• Detect tampering.
• Perceptual Transparency.
• Detection should not require the original image.
• Detector should be able to locate and characterize alterations made to a
marked image.
Mallory may know that the data he has stolen contains a watermark, but he may try to
erase the watermark or try other means for claiming false ownership. The
watermarking system should protect Alice from various forms of Mallory’s malicious
attacks:
Bit Attacks :
The simplest malicious attack attempts to destroy the watermark by updating some
bits. Clearly, if Mallory can change all the bits, he can easily destroy the watermark.
However, he has also made his data completely useless. The effectiveness of an
attack should therefore consider the relationship between the numbers of bits that
Mallory and Alice change, since each change can be considered an error. Having
more errors clearly makes the data less useful.
Rounding Attack Mallory may try to lose the marks contained in a numeric attribute
by rounding all the values of the attribute. This attack is not any better than the bit
attacks discussed above. Mallory has to correctly guess how many bit positions are
involved in the watermarking. If he underestimates it, his attack may not succeed. If
he overestimates it, he has degraded the quality of his data more than necessary. Even
if his guess is correct, his data will not be competitive against Alice’s data because his
data values are less precise.
A related attack will be one in which the numeric values are uniformly translated. For
example, Mallory may translate using units of measurement (e.g., imperial units to
metric units). Alice simply needs to convert the values back to the original system in
order to recover the marks. In general, Mallory can apply arbitrary translations to
numeric values. In this case, Mallory would also need to inform potential users of the
conversion used which could also be applied by Alice before detecting her
watermark. The unnecessary conversion would also raise suspicion among users.
Subset Attack Mallory may take a subset of the tuples or attributes of a watermarked
relation and hope that the watermark is lost.
Mix and Match Attack Mallory may create his relation by taking disjoint tuples from
multiple relations containing similar information.
Additive Attack Mallory may simply add his watermark to Alice’s watermarked
relation and claim ownership.
Invertibility Attack Mallory may launch an invertibility attack [7] to claim ownership
if he can successfully discover a fictitious watermark. Mallory’s claimed watermark
is in fact a random occurrence.
Subset Addition
Mallory adds a set of tuples to the original data. This addition is not to significantly
alter the useful (from Mallory’s perspective) properties of the initial set versus the
resulting set.
Subset Alteration
Altering a subset of the items in the original data set such that there is still value
associated with the resulting set. In the categorical data framework, subset alteration
is intuitively quite expensive from a data-value preservation perspective. One has also
to take into account semantic consistency issues that become immediately visible
because of the discrete nature of the data.
Watermarking an image involves two steps to provide the original authentication and
the steps are
a) Embedding a watermark
b) Extracting a watermark
a) Embedding a watermark: -
FHT is a robust and efficient digital image watermarking algorithm for copy right
protection of digital images. This algorithm can embed or hide entire image or pattern
as a watermark such as company’s logo or trademark directly into the original image.
Fast Hadamard transform (FHT) based watermarking approach that embeds grayscale
image as a watermark. The watermark grayscale image as a watermark. The
watermark grayscale image is decomposed into Hadamard coefficients for
embedding. To increase the invisibility of the watermark, a visual model based on the
original image characteristics, such as edges and textures are incorporated to
determine the watermarking strength factor.
This factor is used to scale the watermark coefficients to a similar range to the
coefficients from the Hadamard coefficients of the sub-blocks of the container image.
The FHT embedding algorithm was found to provide a robust and efficient approach
to perform digital watermarking of digital image data for copyright protection and
proof of rightful ownership. The simplicity of FHT offers a significant advantage in
shorter processing time and ease of hardware implementation than most orthogonal
transform techniques such as DCT and DWT.
Let [U] represents the original image and [V] the transformed image, the 2D-
Hadamard transform is given by
[V]= Hn [U] Hn
N
The advantages of Hadamard transform are that the elements of the transform
matrix Hn are simple: they are binary, real numbers and the rows or columns of H n are
orthogonal. Hence the Hadamard transform matrix has the following property:
Hn=Hn*=HT=H-1
H-1=Hn/N
[U]=Hn-1[V]Hn*=Hn[V]Hn/N
Hn = Hn-1 H1
Or
H H n −1
H n = n −1
H n −1 − H n −1
In our algorithm, the processing is performed based on 8x8 sub-blocks of the
whole image, the third order Hadamard transform matrix H3 is used.
1 1 1 1 1 1 1 1
1 −1 1 −1 1 −1 1 −1
1 1 −1 −1 1 1 −1 −1
1 −1 −1 1 1 −1 −1 1
Hn =
1 1 1 1 −1 −1 −1 −1
1 −1 1 −1 −1 1 −1 1
1 1 −1 −1 −1 −1 1 1
1 −1 −1 1 −1 1 1 −1
The original image, f(x,y) is also decomposed into a set of non-overlapped blocks of
hxh,denoted by fk(x’,y’),k=0,1,……..K-1,where the subscript k denotes the index of
blocks and K denotes total number of blocks. In our experiment, a test image of size
256x256and sub-block size of 8x8 is used.The algorithm pseudo-randomly selects the
sub-blocks for watermark insertion using an m-sequence random number generator.
The seed of this m-sequence and initial state are also stored in the key file. After that,
a FHT is performed on each selected sub-blocks of original image. Since the sub-
block size is 8x8 a Hadamard transform of matrix size H3 is used. For each 8x8 sub-
block, 64 Hadamard transform coefficients are obtained.
Xi*=Bmi
Image Image
+LOGO
The watermark FHT coefficients are extracted from all the sub-blocks of
original image. Along with the DC component stored in the key file, the AC
coefficients are rearranged into a 64x64 FHT coefficients matrix. The extracted
watermark image, w’(x, y), is obtained by IFHT of the 64x64 Hadamard coefficients
matrix using equation (3).
The canny edge algorithm was selected because of its ability in detecting
weak edges by using two different thresholds. it is applied to each selected sub-blocks
of the original image used for watermarking. Counting the number of edge points in
each sub-block, we obtain another visual mask, mask2 (j, k).This mask is used to
determine the coarse texture or outstanding edge in the image block. Large values in
this mask indicate that the corresponding block is highly textured. Smaller values
indicate that the block contains outstanding edges .The two mask values are
multiplied and scaled to a specific range. The water mark strength factor B is
obtained as follows:
3.5 Advantages
• FHT watermarking algorithm does not require the original information at the
watermark identification stage. This is blind or public digital watermarking.
• Shorter processing time and the easy of hardware implementation than many
common transform techniques.
FEASIBILITY ANALYSIS
Economic Feasibility
Operational Feasibility
Technical Feasibility
It refers to whether the software that is available in the market fully supports
the present application. It studies the pros and cons of using particular software for
the development and its feasibility. It also studies the additional training needed to be
given to the people to make the application work.
7. SOFTWARE REQUIREMENT SPECIFICATION
What is SRS?
1) Problem/Requirement Analysis:
The process is order and more nebulous of the two, deals with understand the
problem, the goal and constraints.
2) Requirement Specification:
Here, the focus is on specifying what has been found giving analysis such as
representation, specification languages and tools, and checking the specifications are
addressed during this activity.
The Requirement phase terminates with the production of the validate SRS document.
Producing the SRS document is the basic goal of this phase.
Role of Srs:
The purpose of this document is to describe all external requirements for the
JDBC Editor. It also describes the interfaces for the system.
SCOPE:
This document is the only one that describes the requirements of the system. It
is meant for the use by the developers, and will also by the basis for validating the
final delivered system. Any changes made to the requirements in the future will have
to go through a formal change approval process. The developer is responsible for
asking for clarifications, where necessary, and will not make any alterations without
the permission of the client.
DIAGRAMS
CLASS DIAGRAMS :-
1) FHTDigitalWatermarking.java
2) ImageBuilt.java
OBJECT DIAGRAMS:-
:FHTDigitalWatermarking
fname : String
ib:ImageBuild
img : Image
img2 : Image
USECASE DIAGRAMS:-
performFHT
OnWatermar
performFHTO
k nOriginal
O
r
i
g
i
n
a
l
randomNumb
erGeneration
Watermark
Insertion
Insert
Watermark
PerformIFht
OnOriginal
check
loading
paint
performFHT
OnOriginal
Watermark
Extraction
PerformIFHT
OnWatermar
k
Close
SEQUENCE DIAGRAMS:-
performFHTOnOriginal()
randomGeneration()
check()
false
k++ true
k<100
writeInt(wm[i])
0>wm[i]>-99999 & count>10
i<256
opixel[]+iwm[j]%100
-opixel[]-iwm[j]%100
iwm[j]!=0
j>10 j<10
performIFHTOnOriginal()
loading()
2)Extraction Sequence Diagram:-
ib:ImageBu rev:int i6:int int:i2 opixels: count1 :i nt count2:int rseq:int[10 wm2:int[25 i:int in:File keyfil e.dat display
ilt int[65536] 0] 6] InputSt...
performFHTOnOriginal()
wm2[i] readInt()
wm2 [i ]=0
i6=0 opixels[i2]
i6=(i6+opixels[i2])*100
i > 256 count1++ count2++ rseq[count2]
count1< 3
count1>2
i6=i6%100
rev=0
rev=rev*100+i6
i6!=0 i6=i6/100
i6=0
rev =rev *-1
wm2[i]=rev
i++
i > 256
performIFHTOnWatermark( )
paint( )
TECHNOLOGIES
One of the most difficult tasks is that, the selection of the software, once
system requirement is known is determining whether a particular software package
fits the requirements. After initial selection further security is needed to determine the
desirability of particular software compared with other candidates. This section first
summarizes the application requirement question and then suggests more detailed
comparisons.
Java,
AWT,
SWINGS.
JAVA
Architecture
Simple
neutral
Object
Portable
oriented
Distributed High performance
Interpreted Multithreaded
Robust Dynamic
Secure
You can think of Java bytecodes as the machine code instructions for
the Java Virtual Machine (Java VM). Every Java interpreter, whether
it's a development tool or a Web browser that can run applets, is an
implementation of the Java VM.
Java bytecodes help make "write once, run anywhere" possible. You
can compile your program into bytecodes on any platform that has a
Java compiler. The bytecodes can then be run on any implementation
of the Java VM. That means that as long as a computer has a Java VM,
the same program written in the Java programming language can run
on Windows 2000, a Solaris workstation, or on an iMac.
You've already been introduced to the Java VM. It's the base for the
Java platform and is ported onto various hardware-based platforms.
Native code is code that after you compile it, the compiled code runs
on a specific hardware platform. As a platform-independent
environment, the Java platform can be a bit slower than native code.
However, smart compilers, well-tuned interpreters, and just-in-time
bytecode compilers can bring performance close to that of native code
without threatening portability.
Creation of Java:
Java is developed in year 1990 by “Sun micro system” to develop special soft
wear that is used to manipulate censurer electronic drivers. In year 1992 “Green
project team” win micro system, demonstrated the application of their new language
to control list of home application (or) appliances to handle device with any they
touch screen. In year 1993 www(world wide web) appeared on the internet and
transformed the text – based internet in to graphical –rich environment. The green
project team come up with the idea of developing web applets, using the new
language. In year 1994 the “green project team” developed a web browser called “Hot
Java” demonstrated the power of the new language. In year 1996, java established it
self-not only as a leader for Internet programming, but also as general purpose, object
– oriented programming language.
JAVA FEATURES
The invents of java wanted to design language which could offeg solution to
the problems encovntcged in modern programming “win micro systems” officially
describes java with the following categories
Object-Oriented:
Java is a true object – language, every thing in java is an Object. 411 program
code and data resides within object and classes. The object model in java is simple
and easy to extend.
Distributed:
Java is a small and simple language. Many features of C & C++ that are either
redundant or sources of unreliable code or not part of java. For example, java dose
not use pointers, preprocessor header files, goto statement and many others. It also
eliminates operator overloading and multiple inheritance. For more detailed
comparison of java with C & C++, refer to section 2,3.
Java Overview:
Java builds on the strength of C++. It has taken the best features of C+
+ and discarded the more problematic and error prone parts. To this lean core, it has
added garbage collection (automatic memory management), multithreading (the
capacity for on program to do more than one thing at a time), security capabilities.
The result is simple, elegant, powerful and easy to use.
Java is actually a platform consisting of three components:
1. Java programming Language.
2. Java Library of Classes and Interfaces.
3. Java Virtual Machine.
Java is Portable:
In summary, these means that with the JDBC API extending Java, a
programmer writing Java code can access all the major relational databases on any
plat form that supports the Java virtual machine.
Garbage Collection:
Simplicity:
Makes Java easier to learn and use correctly. Java keep it simple by
having just one way to do something instead of having just one way to do something
instead of having several alternatives, as in some languages. Java also stays lean by
not including multiple inheritance, which eliminate the errors and ambiguity that arise
when you create a subclass that inherits from two or more classes.
To use an interface, and then implements all the methods in that interface as
part of the class. These methods are implemented in a way that is appropriate for the
class in which the methods are being used. Interfaces let one add functionality to a
class and give a great deal of flexibility in doing it. In other words interfaces provide
most of the advantages of multiple inheritance without its disadvantages.
Java.io---- Classes that manage reading data from input streams and writing
data to the output streams.
Java.applet---- The Applet class, which provides the ability to write applets,
this package also, includes several interfaces that connect an applet to its documents
and to its document and to recourses for playing audio.
Java.sql---- The JDBC API, classes and interfaces that access databases and
send SQL Statements. The first three packages listed, Java.lang, Java.io and Java.util
form the Foundation, they are basic classes and interfaces for general purposes
programming, Java development kit version 1.2 added some new packages, with
JDBC being one of them. Other new packages include such thing as Remote Method
Invocation, Security and Java Beans the new API for creating resizable components.
A big plus for Java is the fact it can be extended. It was purposely
written to be lean with the emphasis on doing what it does very well; instead of trying
to do everything from the beginning, it was return so that extending it is very easy.
Programmers can modify existing classes for write their own new classes or they can
write a whole new package. The JDBC API, the Java.sql package, is one example of
a foundation upon which extensions are being built. Other extensions are being
added or worked on in area such as multimedia, Internet Commerce, conferencing,
and telephony. In addition to extensions there are also main tools being developed to
make existing capabilities easier to use. For example, there is already a tool that
greatly simplifies creating and laying out Graphical User Interfaces such as menus,
Dialog boxes and buttons.
Java Is Secure:
The way classes are loaded. The Java byte code loader, another part of the
virtual machine, whether classes loaded during program execution are local or from
across a Network. Imported classes cannot substitute for built in classes, and built in
classes cannot accidentally reference classes bring in over a network.
The way access is restricted for untested code: The Java security
manager allows user to restrict untested Java applets so that they cannot access the
local network, files and other resources.
For situations that require unusually high performance, byte codes can
be translated on the fly, generating the final machine code for the particular CPU on
which the application is running at run time. High levels interpreted scripting
language generally offer great portability and fast prototyping but poor performance.
Low level compiled language like C and C++ offer great performance but
require large amounts of time for writing and debugging Code because of problems
with areas such as memory management, pointers and multiple inheritance. Java
offers good performance, with the advantages of high level Languages but without
the disadvantages of C and C++. In the world of design trade-off, you can think of
Java as providing a very attractive middle ground.
Java Is Robust:
However, it also checks your code at run time. In fact, many hard to track
down bugs that often turn up in hard to reproduce runtime situations are simply
impossible to create in Java. Knowing that what you have written will behave in a
predictable way under diverse conditions is a key feature of Java to understand how
Java robust, consider two main reasons for program failure: Memory management
mistakes and mishandled exceptional conditions (run time errors).
Exception Handling:
Exception-Handling Fundamentals:
Java exception handling is managed via five keywords: try, catch, throw,
throws and finally.
Program statements that you want to monitor for exceptions are contained
within a try block. If an exception occurs within, the try block, it is thrown. Your
code can catch this exception (using catch) and handle it in some rational manner.
System-generated exceptions are automatically thrown by the Java run-time system.
To manually throw an exception, use the keyboard throw. Any exception that is
thrown out of a method must be specified as such by a throws clause. Any code that
absolutely must be executed before a method returns is put in a finally block.
Exception Types:
All exception types are subclasses of the built-in class Throwable. Throwable
is at the top of the exception class hierarchy. Throwable are two subclasses that
partition exceptions into two distinct branches. One branch is headed by Exception.
Throw:
There are two ways you can obtain a Throwable object: using a parameter into a
catch, or creating one with the new operator.
The flow of execution stops immediately after the throw statement, any subsequent
statements are not executed.
Throws:
A Throws clause lists the types of exceptions that a method might throw. This
is necessary for all exceptions, except those of type Error of Runtime Exception, or
any of their subclasses.
Finally:
The finally clause is optional. However, each try statement requires at least
one catch or a finally clause.
Exception Meaning
String Index Out Of Bound Attempt to index outside the bounds of a string.
Class not Found Exception Class not found.
The Exception class does not define any methods of its own.
Using Exception:
An introduction to Java that will help Java newbies to become Java developers:
This is where Java gets its platform independence. The bytecode format is the same
on all platforms because it runs in the same abstract machine -- the JVM. As long as
there is a JVM on any given platform, you can run Java on it. There's an old saying in
computer programming, "You can solve any problem with another level of
indirection." The JVM and bytecode together is another level of indirection.
That's about it on the JVM for now. If you want to know more, check out Sun's JVM
specification in the Resources section below.
The first thing you need is the Java 2 Software Development Kit or SDK (formerly
known as the Java Development Kit, or JDK). This is a set of software and software
tools supplied by Sun that includes all of the basic components needed to build Java
programs. If you don't have this, you'll need to download the Java 2 SDK from Sun
(see Resources below). Here's a brief description of what you need to do to install
version 1.2.x for the Windows platform:
* For Windows, the download will be a self-extracting archive, and the file name
follows the form: jdk<version>-win.exe. For example, for version 1.2.2, the file is
named jdk1_2_2-win.exe.
A Java program is a class with a main method in it. The main method is a special
method that is the starting point for every Java application. It has to be declared
exactly as above, and it has to appear within a class, as the above example also
shows. System.out.println is the magic incantation you use to get things sent to the
console.
This code example is for a standalone, nongraphical Java program that prints the
string Eureka, I can put Java on my resume. to the console. Your salary can double
now, so if you want, you can stop here. Those that want to learn more can keep going.
Type the above program into a file named MyProgram.java. It's a good idea to put it
in its own directory just to keep things organized. Use your favorite text editor for
this, or check out the Resources section for some of my favorites. Once you've done
that, go to a command line that is open to the location your file is in.
Type in the following code to compile the file. (This generates the .class
file from the .java file):
javac MyProgram.java
Once it compiles without errors, do a directory listing to see that you've generated a
MyProgram.class file. (Hey -- that's the bytecode.)
Now type the following to run the program:
java MyProgram
This executes the JVM, and makes it run the bytecode in the MyProgram.class file.
You should see the following output on your screen:
There are a couple of things you should notice. The Java compiler (javac) requires
that you include the .java extension for the files you're compiling. It's just a program,
and that's what it expects you to give it. The JVM (java) does not expect you to
include the .class extension. Try typing java MyProgram.class, and you'll get an error
message because it will look for a file called MyProgram.class.class. Note also that
things are set up in such a way that you have to do everything from one directory.
Object-oriented programming (OOP)
You might see object described elsewhere using different terminology, but don't
worry too much about that. Grasping the concepts is the important thing.
Let's further explore the notion of type. We're almost always dealing with many
different objects, and the natural inclination is to classify or label them in some way.
A type is the way to classify objects, and it's also the blueprint that defines the
behavior and properties for objects of a certain type.
Here are some real-world examples of different types from different areas:
Every object has a type associated with it, and possibly more than one type. Creating
types and classifying your objects is one of the arts of OOP, and there is no single
"correct" way to do this.
Let's examine the alarm clock type. We'll take a crack at determining its behavior and
properties.
We've made a bit of a distinction here between general behavior, and behavior that is
just related to getting and setting properties. We'll talk more about this later when we
delve into the best way to actually program a type.
How do we use this type? Easy. We buy an alarm clock and bring it home. We set the
current time and the alarm time. When it rings, we hit the snooze button (repeat five
to six times), and we finally turn the alarm off and get out of bed.
The system depicted in this example is the core of OOP. We have types that represent
the different kinds of things in our system, (the alarm clock type), and we have
objects that are instances or examples of the types (we bought a particular alarm
clock). Objects interact through their behaviors, sometimes resulting in changes in
their properties, and ultimately (hopefully) do useful work. C'mon, you already knew
this, otherwise you wouldn't be able to use your alarm clock, and you'd never get to
work on time. Rewrite your resume -- you're an object-oriented programmer.
We've been talking abstractly until now about OOP. Let's shift back and see how
OOP is done in Java. A class is used to define a new type in Java, and classes are
central to the language. Everything happens within classes. All executable code exists
in classes (generally in methods), and all data appears within a class (in variables
within a class, and in variables in methods).
Classes are defined in a class definition. Here's a (simple and incomplete) definition
for an AlarmClock class.
It's time to create your first class, albeit one that doesn't do much yet. It will soon,
though. Create a file called AlarmClock.java, and put in the code for the class
definition above. Compile it using javac.
javac AlarmClock.java
Note that when a class definition starts with the keyword public, Java requires you to
put the class definition (the Java source) into a file that starts with the name of the
class. Hence, we name our file AlarmClock.java because the class name is
AlarmClock.
new AlarmClock();
This creates an alarm clock off the heap. There's still a problem here, however.
Unlike cookies we can just pick up and put on a cookie sheet (and then pick up and
eat), objects float around in a computer's memory, and we need to have a way to get
to them. Java uses special variables called object references to refer to objects. You
can initialize a reference to refer to a given object, and then use the reference to
interact with that object. Here's what this looks like:
The first AlarmClock declares the type of the variable; aClock is the name of the
variable; and new AlarmClock() creates a new alarm clock that is then used to
initialize aClock.
Just for fun, let's add a little behavior to our alarm clock. You add behavior in
methods. We'll add the snooze method, which will just print a message to the console
as our first program did. Methods go inside classes, and here's what one looks like:
Let's create another program called AlarmClockTest. This just means we'll create a
class AlarmClockTest with a main method in it. We'll create an instance of
AlarmClock in this program.
Last, but not least, we want to do work with this alarm clock. The way you tell an
object to do something is by calling, or, invoking, one of its methods. You generally
do this through the variable that refers to it, and you use the dot operator for this. All
we can do is snooze with this clock, but hey, that's everybody's favorite action with an
alarm clock anyway. Here's what the code looks like:
Ready? Create AlarmClockTest.java, and type in the code above. Compile it (javac
AlarmClockTest.java) as well as AlarmClock.java. You're ready to run your new
program. The main method is in AlarmClockTest class, so this is how you run the
program:
java AlarmClockTest
JFC(swings):
In 1995, Java technology shook the World Wide Web with a network-centric, object-
oriented language that provided client side processing for otherwise static pages.
Many Web developers used Java technology to animate sites and loved it. Java
platform's graphical user interface library, the Abstract Window Toolkit (AWT),
fulfilled a key role in the creation of dynamic Web pages.
Java technology has evolved quickly and now transcends the browser, its initial
runtime environment. Today, businesses worldwide are standardizing on Java as their
primary development and deployment platform. The Java Virtual Machine* (JVM) is
rapidly being incorporated into operating systems and hardware devices to provide a
common meta-platform for applications.
The Java Development Kit (JDK) software release 1.1 introduces the first installation
of the most significant cross-platform graphical user interface technology since the
advent of windowing systems: the Java Foundation Classes (JFC).
Java Foundation Classes extends the original AWT by adding a comprehensive set of
graphical user interface class libraries that is completely portable and delivered as
part of the Java platform. In addition, JFC will also include many of the key features
found in Netscape's Internet Foundation Classes. Since the JFC is core to the Java
platform, it eliminates the need to download special classes at runtime and is
compatible with all AWT-based applications.JFC's continually evolving new features
include a rich suite of high-level components and services that are fully and uniquely
cross-platform compatible, and offer significant performance improvements. With the
JFC, developers can create and deploy large scale, mission-critical intranet , Internet
and Crossware applications. And because Java is an open, standard technology, a
broad complement of third party tools and components are available to enhance
application development.
The JFC raises the bar for GUI functionality in the Java language and delivers a rich
API with a growing set of components and services to develop commercial-grade
applications.
The Java Foundation Classes includes many new, easy-to-use and sophisticated
features that are designed together to offer the following key advantages over other
frameworks:
* JFC is core to the Java platform and reduces the need for bundled classes.
* All new JFC components are JavaBeansTM architecture-based.
* No framework lock-in. Developers can easily bring in other third party components
to enhance their JFC applications.
* Components are cross-platform.
* Enhanced services promote development of feature rich applications.
* JFC subclasses are fully customizable and fully extendible.
The Abstract Window Toolkit (AWT) provided developers with a rudimentary library
for building applications and applets. Applets are Java applications that are executed
from inside a browser instead of being launched and run from the native operating
system. Designed for simple, web-centric tasks, developers encountered limitations
with the AWT when attempting to create modern, sophisticated client applications.
Although the AWT was limited in scope, it did offer two important features for all
applets and applications:
The AWT delivered on the promise of a standards-based platform that adapted to the
user desktop. It also provided a good starting point for graphical Java development
with room for improvements, some evolutionary and some revolutionary.
There are many different approaches to implementing a portable GUI class library or
environment. A common approach is to layer an API or class library on top of the
native toolkit. Alternatively, other portable GUI environments contain a single toolkit
and then emulate the native look and feel on each platform. The first approach has the
desired look and feel, but applications often do not work consistently across
platforms. The later approach enables applications to work consistently but their
emulation never fully captures the correct look and feel on all platforms.
The AWT uses the layered toolkit model where each Java component creates a native
component. The JDK refers to this as the "peer" model. Each Java component class
"wraps" the peer or native implementation. This can increase complexity because
many native components maintain their own state. More challenges arise at the toolkit
level. Each native toolkit has a completely different event model and contains a
distinct set of native components.
For users, differences in native appearance can have a radical and negative effect on
the look and behavior of an application. Problems can arise when applications
designed and developed for one platform are deployed on a different windowing
system. Components such as the scrollbar can exhibit inconsistent behavior across
platforms. Changes to minimum sizes, shading and colors, and fonts can result in
unusable user interfaces for applications that are otherwise healthy. Since cross
platform capabilities are one of the compelling reasons for developing with Java, the
cross platform capabilities of the GUI had to be improved.
AWT 1.0 had several strengths and weaknesses. It's biggest strength was that with it,
an application/applet could be written once and run anywhere-a single set of source
code, 100% portability. No other toolkit or language has been able to match AWT's
breadth of deployment platforms while supporting native look and feel.
Many seasoned GUI developers have complained that the AWT's peer model was too
restrictive in rendering and event handling, and that because of this, it was difficult to
extend or override different aspects of the component. It was also prone to problems
if the idiosyncrasies of a platform were not implemented properly. Generally
speaking, the peer model was viewed as unacceptable if Java was to truly act as a
metaplatform that would guarantee cross platform support.
Nevertheless, the peer model played an important role in the acceptance of the AWT.
It enabled Java's AWT to be brought to market quickly and provided true native look
and feel. In fact, browsers are moving users toward a more universal look and feel on
all platforms and soon, users will expect this uniformity. However, in 1995 the
market was much more dogmatic about the appearance of applications and would
have almost certainly rejected the AWT if it had not provided native look and feel.
In retrospect, AWT 1.0 was a good initial step that enabled applet development. It
provided the initial foundation upon which further releases of the AWT could build
and eventually improved. The API was simple and clean, and enabled developers to
come up to speed quickly. The AWT shielded developers from each platform's
idiosyncrasies and yet was 100% portable with a native look and feel. Finally, the
AWT enabled the early Java adopters to deliver applets and applications on any Java
enabled platform with one set of source code and no "porting".
As a result, Sun, Netscape, and IBM joined force to create Java Foundation Classes
which provides a single GUI component and services solution. Java Foundation
Classes builds on top of the existing AWT by integrating the best of new Sun
technologies and Netscape's Internet Foundation Classes.
The JFC released in JDK 1.1 provides a wide range of new features that enable Java
developers to be more productive while delivering applications that are fully
integrated into the desktop environment. The JFC contains a powerful, mature
delegation event model, printing, clipboard support, a lightweight UI framework and
is 100% JavaBeans compliant. The new capabilities of JFC make Java a platform that
will support the most sophisticated enterprise applications. Development of
commercial applications using Java is now both possible and attractive.
Java and the AWT freed developers from being tied to a specific or proprietary
platform for GUI application development and deployment. Today, the JFC provides
the core set of classes and services enabling applications to scale from the desktop to
the enterprise and across multiple platforms. Java developers will find the additions
and improvements to the toolkit greatly enhance their ability to deliver 100% Java
applications quickly and provide reliability and cross-platform consistency.
The release of JFC with JDK 1.1 is only a starting point. JFC will be extended to
encompass an even wider range of components and services which will support the
development of even richer Java applications. The JFC strategic roadmap intends to
build on this solid foundation with new functionality that will continue to deliver a
new generation of applications to a new era of computing.
Current JFC Features
JavaBeans has played an important role in the JFC. The JavaBeans specification
defines a standard component architecture for visual and non-visual components. All
JFC components in JDK release 1.1 are JavaBeans architecture compliant, which
means they have a consistent API and a standard event handling mechanism. This
standard property and event model lends itself well to component reuse and
interoperability. JavaBeans also ensures easy integration of standard components and
frameworks with RAD tools and GUI builders.
As described earlier, the peer model has certain limitations. While native look and
feel is still important, a universal look and feel is also becoming increasingly more
desirable. The Lightweight UI Framework enables components to be peerless, or
lightweight, and completely written in Java. This new framework will enable
component developers to create and deliver a wide range of third party components
that will work consistently across platforms while remaining completely portable.
The lightweight UI also enables Java developers to easily create stunning user
interfaces.
The new event model is especially well suited to visual development environments
and development of distributed and multicast applications. The new delegation event
model in the JFC extends the previous single method implementation of the AWT.
Before large conditional statements were required to determine an event's type or
origin. Now, events are class specific and can be "sent to" or "delegated" directly to
the object that can handle the request. This provides a large degree of flexibility when
handling the many different types of events generated by a GUI application.
Operating system vendors are currently integrating Java's Virtual Machine directly
into the OS which will shift deployment from webcentric browsers to applications,
provide a common metaplatform from IBM MVS to Microsoft Windows, and provide
a more consistent, flexible, and reliable operating environment than a browser. Once
this is accomplished and applications based on release 1.1 are in operation, users will
no longer have to view the future of the desktop windowing environment through a
single vendor's eyes. Innovation will expand as the time-to-market for application
decreases.
"100% Pure Java" means the application is written completely in Java and does not
rely on any external class libraries or native code. Third party technologies can be
used but their technology must be part of the application or applet download in order
for the software to be "100% Pure Java." This works well for third party components
that are typically small in size with few classes. It becomes a problem with large third
party frameworks.
Although there is a growing third party market for additions to the Java platform, an
obvious need arose in the Java development community. Initially, AWT was intended
to support only a limited set of GUI components. It was expected that the market
would provide the higher-level components. The Java development community has
overwhelmingly asked for the additional components to be delivered as part of the
JDK. Why? So applications can more easily be "100% Pure Java." Java developers do
not want to deliver these additional components along with their applets and
applications. With JFC, much of this additional functionality has been incorporated
into the Java platform, thus improving overall performance and appeal of Java
applications and applets.
Java Technology -- A Commitment To Open Standards
Recently, other companies have announced or delivered specifications and class
libraries to the Java development community. Although their apparent enthusiasm for
the Java platform is certainly understandable, such offerings can cause confusion in
the marketplace. Sun has endeavored to cultivate relationships with other technology
providers in order to provide an open standard for all Java developers. This
collaboration is evident in many of the specifications now available for review. JFC
represents the demands of Java stakeholders and is a high quality development
environment that makes high performance, network-centric applications a reality.
It is important to remember that all specifications from Sun have been made available
to the larger Java development community for comment and do not reflect the views
or position of a single vendor. Once these specifications have been implemented the
technology will become part of the JDK and will exist on every Java platform. This is
why it is important for Java applications and applets remain "100% Pure Java."
Additions to the Java Foundation Classes will soon incorporate several features that
further enhance a developer's ability to deliver scalable, commercial-grade
applications. These new features will be made available to developers as they are
completed over the next few months and then rolled into the next release of the JDK.
New features will include:
The Drag and Drop specification is available in the JDK 1.1 documentation and will
soon be released as an update to the JFC. Drag and Drop (D&D) functionality as part
of the core JFC class library means it will be available on all Java platforms in a
consistent and supported fashion. It will significantly improve application
interoperability by enabling D&D between Java applications and non-Java
applications.
Working closely with Netscape and IBM, Sun will soon release an expanded set of
components written in 100% Pure Java that will enable applications to be more fully
integrated into the native environments. These new high-level components will be
available on all platforms as part of the standard Java platform, thereby eliminating
the need to download extra classes. In addition, new JFC components will carry two
important attributes: all components will be both lightweight and peerless, thus
facilitating a customizable look and feel without relying on native windowing
systems or adding system overhead, and improving the deployment of applications
will be simplified.
This comprehensive set of new high-level components will allow developers to create
sophisticated professional-quality applets and applications using core JDK 1.1
functionality. The following components will be included with JFC:
* Tree View
* List View
* Table View
* Toolbar
* Pane Splitter
* Tabbed Folder
* List
* Multi-column
* Supports Images
* Progress Bar
* Slider
* Styled Text
* Support import/export of HTML and Rich Text Format
* Font Chooser
* Color Chooser
* File Chooser
* Custom Cursors
* Tool Tips
* Generic Button and MenuItem
* Support Images, Check marks
* StatusBar
* SpinBox
* ComboBox
* Drop down ComboBox
* Drop down ListBox
* Composable Button
* Multimedia Controls
* MovieSlider
* AudioController
* MovieController
* Properties
* AudioGauge
* MidiPanel
Native look and feel was once the mantra of cross-platform developers. Since all
applications on a platform had a common look, all new applications were assumed to
require that user interface. Or so it seemed until World Wide Web came along. Now,
users are familiar with and excited by the rich and unique user interfaces delivered
through browsers. The rigor with which user interfaces were designed in the past has
been replaced with the requirement for effective and reliable clients.
Pluggable look and feel will increase the reliability and consistency of applications
and applets deployed across platforms. The "pluggable" look and feel will provide an
easy yet powerful mechanism for individualizing an application's visual personality
without having to subclass the entire component set. This will increase user
acceptance of network computer (NC) replacement of PCs as users will select an
operating environment they are comfortable with.
To further enhance a user's visual experience, an entire application's GUI will be able
to switch from one look and feel to a different one at runtime. This feature will give
users the ability to switch without restarting the application. This is significant since
users will want to work in a GUI that is familiar to them, even if they are using a
network computer.
2D Graphics API
The existing graphic capabilities of Java will be extended with new classes. New
graphical capabilities will promote the development of visually rich applications. The
Java 2D API extends the JFC's strengths by enabling developers to incorporate high-
quality graphics into their applications and applets. The Java 2D API will extend the
java.awt and java.awt.image core class libraries. By extending the existing classes,
the Java 2D API maintains compatibility for existing programs and allows programs
to seamlessly integrate the features provided by JFC. This is one of many
evolutionary additions to the Java platform which ensures that existing code co-exists
and benefits from these new enhancements.
The Java 2D API provides a subclass of the AWT Graphics class, Graphics2D, with
additional features for specifying fancy paint styles, defining complex shapes, and
controlling the rendering process. The Java 2D API treats paths, text, and images
uniformly; they can all be rotated, scaled, skewed, and composited using the new
Graphics2D class.
The Java 2D API will:
This means better performing, more sophisticated visual applications for scientific,
engineering, and business users.
JFC introduces new capabilities to the Java platform that deliver benefits to end users.
Many physically challenged users are prevented from using applications because
developers did not integrate with the necessary accessibility functionality. The JFC
Accessibility API enables Java applications to scale to encompass the physically
challenged users. Two of the most important features are Screen Readers and Screen
Magnifiers.
The Screen Reader creates an off screen representation of the GUI components
enabling the information to be provided via a text to speech and/or a Braille terminal.
The user can then interact with the GUI through the alternate computer input and
output device.
The Screen Magnifier enables the user to adjust the magnification of the screen from
1 to 16 times the normal size. Event tracking and screen content knowledge enable
the user to more easily navigate the interface. Font smoothing and text highlighting
act in concert to create a clearer picture which renders the content more easily read
and understood.
Accessibility features will be easily integrated into existing Java applications and will
ensure an even broader audience for information in a networked age.
An In depth Look
JFC provides significant new capabilities for Java developers. With the JDK 1.1
release, JFC embraces the new JavaBeans component model, introduces a new high-
performance UI framework, improves event handling, enables printing support,
supports keyboard navigation, and introduces popup menu and scroll pane
components. JFC delivers a wish list of features that make Java the most compelling
development platform available.
JavaBeans is an architecture and platform neutral API for creating and using dynamic
Java components. JavaBeans enhances the Java platform by allowing richer, more
dynamic interaction. JavaBeans allow developers to define independent components
that can be used and re-used in a variety of combinations to compose new
applications. JavaBeans will be supported inside browsers and in standalone
applications.
Lightweight UI Framework
In AWT release 1.0, peer-based components (Button, Label, etc.) could not be easily
extended or have their look and feel overridden. Many developers created their own
components by deriving new ones from java.awt.Canvas and specialized containers
were derived from java.awt.Panel. The problem with this approach was that each
Canvas or Panel derived component was "heavy-weight", meaning it required a native
window which is rendered opaquely. Opaque windows can cause problems for those
wanting to layer components on top of each other, since they completely cover the
components behind them. Additional overhead occurs when developers create their
own classes-the applet or application must download additional classes to perform
what should be a standard task. JFC solves these problems by introducing a
lightweight framework that radically improves the performance and appearance of
Java applications.
The event model in AWT 1.0 was quite simple. All events were passed up the
inheritance hierarchy forcing objects to catch and process events by subclassing and
overriding either the handleEvent() or action() methods. Complex if-then-else
conditional logic was required in the top level object to determine which object
triggered an event. This was not scalable and was ill-suited to high-performance
distributed applications.
With JFC, the callback-style delegation event model is elegant yet powerful. Events
are identified by their class instead of their ID and are either propagated or delegated
from an event "Source" to and event "Listener." Only objects interested in a particular
event need deal with the event and no super-event handler is required. This is also a
better way of passing events to distributed objects.
The new event hierarchy is defined by the package java.awt.event. Each derived class
from java.util.EventObject is now unique because of the data it holds. There are no
longer public data fields, all event data is accessed through a standard set/get
JavaBeans compliant interface. However, some derived Event classes still contain an
ID to help objects distinguish between events within a specific group of events.
The real power behind the new model is the enabling of an object to delegate or "fire"
an event to a specific listener or set of listeners. When a source object wishes to
delegate a specific event type, it must first define a set of methods that enable the
listener object(s) to register with the source. These methods take the form of
set<EventType>Listener for single-cast and/or add<EventType>Listener for multi-
cast delegation.
Any object desiring to be a "Listener" of a specific event type must implement the
<EventType>Listener interface for that event type. The "Listener" interface is
typically defined by only a few methods, which makes it easy to implement the
interface. For example, a new Lightweight component may wish to send an
"ActionEvent" when the user clicks on the component. The creator of the component
would define an event registration method call addActionListener() which enables
any object implementing the ActionListener interface to register as a consumer of
ActionEvents.
Additionally, a new language feature called "Inner Classes" has been added in JDK
1.1 which makes creating listener objects much more convenient. With Inner Classes,
you can create a listener class on the fly within the body of another class.
The following example uses Inner classes to hook the action of pushing a button to
closing a Frame:
Printing
Until now Java applications have not been able to send text or graphics to a printer.
Native code could be used to print text but then the application/ applet was no longer
portable, which did not solve the problem of printing graphics. This limitation has
made it difficult for Java applications to be truly integrated into the native
environment. JFC eliminates these barriers by introducing printer support that can be
easily integrated into existing applications and makes the Java platform ready for a
wide range of commercial software applications.
JFC has made it simple to add printing to any Java application or applet. To send
content or graphics to the printer, a call is made to a Frame object's paint() method
with a new type of Graphics context. This special context is derived from the
Graphics class and implements the java.awt.PrintGraphics interface. It is obtained
from the newly implemented PrintJob class.
The PrintJob class encapsulates all the printing functionality. A call method call to
getPrintJob in the java.awt.Toolkit package displays a platform specific dialog,
allowing the user to enter typical printing information such as, print name, number of
pages, etc.
The returned PrintJob object contains the Graphics context which can be used to call
a component's paint() method. This sends all the rendering information to the printer.
The underlying JFC implementation takes care of translating those calls to the
appropriate print device. Sometimes it is necessary to print the entire GUI hierarchy;
this can be accomplished with a call to printAll().
Data Transfer/Clipboard
JDK release 1.1 now has full clipboard support. It enables dynamic data types to be
created, registered, and transferred from both within and across process space
boundaries. This means that any object can be transferred within an application and
also to other applications. It also supports data transfer between Java and non-Java
applications by enabling access to the "system clipboard." Java applications can now
be easily rolled out to end users with a high degree of interoperability with existing
applications. This increases the overall acceptance of the Java platform.
The new API is centered around the "transferable" objects. A transferable object must
be able to provide a list of formats, called "data flavors". It must also be able to return
the data (in the form of an Object reference) when requested in a particular flavor.
The data transfer architecture introduced in 1.1 is a key enabling technology for the
upcoming drag and drop functionality.
Desktop Colors
In previous releases of the AWT this was not possible. JFC in JDK release 1.1
introduced a new class java.awt.SystemColor to handle the dynamic changes in
desktop color scheme. The SystemColor class is derived from java.awt.Color and
defines "symbolic" colors for backgrounds highlights, shadows, etc. The following
code demonstrates how a lightweight component can use the symbolic colors to
render itself:
The JFC enhances the graphical capabilities available for creating truly high-
performance financial, business, and engineering vertical applications.
While certain problems did exist with graphics handling in AWT, these have been
corrected with the JFC. For example, in AWT 1.0 the graphics clipping area could
only be set to an ever decreasing area. Developers found themselves creating a
temporary graphics object, setting a clipping area, calling the drawing methods and
then disposing of the object. The JFC adds a new class "Shape" and several new
clipping methods, most important of which is setClip. It allows developers to set the
clipping area to any size and does not maintain a relationship to the previously set
clipping area.
The AWT 1.0 did not offer an easy way to render a subset of an image or a
mechanism for flipping the image horizontally or vertically, a typical requirement
when working with labels. JFC corrects this with addition of two new drawImage
methods. Each drawImage method requires a source and destination rectangle
definition and uses the pixels from the original unscaled image to draw into the
Graphics object. The following line of code demonstrates the scaling the 100x100
pixel area down to a 50x50 area:
Creating images on the fly is much more flexible and offers better performance than
retrieving images from files. In release 1.0 an image could be created from an array of
pixels. The pixels were converted into a screen representation and as long as the
image was drawn at the same scale it ignored any changes to the original array.
Several new methods have been added to the MemoryImageSource class giving the
developer a finer grain of control and easier animation capability.
The final area improved in the JFC with respect to image handling came directly from
the request of developers input. Several enhancements were made to the PixelGrabber
class. This class now enables developers to get the original ColorModel for the
image, retrieve the size of the buffer needed for the image, and start and stop grab
operations before the image is loaded.
Mouseless Operation
Two important aspects of a GUI are second nature to most users: keyboard navigation
and accelerators on menus. For data entry applications, keyboard traversal is a
requirement. It is common to use the "tab" key to move from component to
component in a standard user interface, and the "control" keys to perform accelerated
actions or short cuts, like <control> C to copy text. JFC based applications now take
advantage of keyboard traversal transparently.
Components can now be "tabbable", they can request and transfer focus, and can be
notified when they gain or lose focus. To better support menu short cuts a new class,
java.awt.MenuShortcut has been added. Additional methods and constructors have
been added to the MenuItem and MenuBar classes to handle the new class. The short
cut keys apply to the "command" key on the Macintosh and the <control> keys on
UNIX(r) and Microsoft Windows platforms.
* Ideally suited for data entry and operational applications typical of terminal-based
applications
* Ensures higher user acceptance of Java applications
* Supports power user navigation
Popup Menu
Popup menus (also known as "context menus") are now a very common UI element
in modern GUIs (Windows 95, CDE, etc.). The JFC introduces a new component that
makes it easy to enable the creation and display of popup menus.
Popup menus are created by simply allocating a new PopupMenu object and adding
MenuItem objects to it, much like you would create a MenuBar menu. When the
popup event is fired (right-button click on MS Windows, middle-button click on
UNIX) a single method is called to assign the popup menu to a component and
display it. This enables a single popup menu to be used by many different
components. Here is a simple one item popup menu:
ScrollPane Container
In the AWT 1.0, the task of implementing all scrolling behavior is left to the
developer. Only a basic Scrollbar class is provided which must be managed by the
application, meaning the application must catch the scrollbar events and then take the
appropriate action to update the contents being scrolled. This made applications slow
and unreliable across platforms. This was a problem for virtually any scrolling
function.
Not only is this a general burden to developers who are accustomed to better support
for this in toolkits, but it is also a serious performance problem, since there is a round
trip (native-> java-> native) for each individual scroll event that occurs, and the
application must respond to the event and move its contents using slower Java
draw/move operations. This is particularly noticeable during the event-intensive
scroll-drag operations. The result was slow applications prone to flickering and
unreliable actions.
To resolve this problem, a ScrollPane class has been added to the JFC. ScrollPane
provides a container that implements automatic scrolling for a single component child
and supports three modes for its scrollbars: "when needed", "always", and "never".
The introduction of the ScrollPane container greatly simplifies the task of displaying
information in a fixed area.
The Java Foundation Classes delivered with JDK 1.1 casts Java GUI development in
a new light. The JFC is a complete GUI toolkit that dramatically extends the original
AWT with a comprehensive set of classes
and services.
The JFC is a scalable, robust and open technology that enables developers to create
and deploy commercial-grade intranet and Internet applications. Even as components
and services grow, JFC promotes ease of use and facilitates rapid application
development. JFC is delivered as core Java technology, which means it is available
on all Java platforms. This results in faster application downloads, more reliable
applications, and simplified application deployment.
The JFC will continue to expand with plans in-process to include a rich complement
of high-level components that will enhance the user's visual experience and improve
productivity. New application services are slated for JFC that will further integrate
Java applications into the desktop environment.
The Java Foundation Classes empowers developers on all platforms, and brings the
future of portable GUI development here today, realizing Java technology's promise,
"Write Once, Run Anywhere."
Abstract Window Toolkit (AWT) - APIs that enable programs to integrate into the
native desktop window system, including APIs for Drag and Drop.
Java 2D - APIs to enable advanced 2D graphics, imaging, text and printing.
Swing GUI Components - APIs that extend the AWT to provide a rich, extensible
GUI component library with a pluggable look and feel.
Accessibility - APIs and assistive technologies are for ensuring an application is
accessible to users with disabilities and meets government requirements for
accessibility.
Internationalization - All JFC technologies include support for creating applications
that can interact with users around the world using the user's own language and
cultural conventions. This includes the Input Method Framework API.
These five technologies are designed to be used together to enable you to build fully
functional GUI client applications that run and integrate on any client machine that
supports the J2SE platform, including Microsoft Windows, Solaris, Linux, and Mac
OSX.
ocus is the mechanism that determines which of the components in a window will
receive keyboard input events. A focus manager looks for special keystrokes that
change the focus (usually the Tab and Shift-Tab keys), and then decides which
component will next get the focus. Often, you'll want to control how the focus moves
between components, especially if you're designing a complex form or dialog for
users to enter information.
Java has had a focus manager for AWT components since version 1.0 of the Java
Development Kit (JDK), and developers have howled about its inadequacies ever
since. Well, it's time to stop howling. The focus management services provided with
the Java Foundation Classes (JFC) should satisfy all of your needs for controlling
focus changes.
A bit of history
The only way to manage focus changes with JDK 1.0 is through a few methods in the
Component class. JDK 1.0 allows components to set the focus to themselves with
requestFocus and to change the focus to the next component with nextFocus. Other
than getting notification of focus changes with gotFocus and lostFocus, that's pretty
much all you can do.
JDK 1.1 deprecates nextFocus and replaces it with transferFocus, which provides
exactly the same functionality as nextFocus. Likewise, 1.1 deprecates gotFocus and
lostFocus and replaces them with the addFocusListener method to support focus
change notification using the 1.1 event model.
Neither JDK 1.0 nor 1.1 provide any means for applications to override the behavior
of the focus manager, or to change the algorithm used to determine focus traversal.
Swing provides some powerful new ways to manage focus changes at the component
level. Here's what you can do with focus management at that level:
And if this isn't enough to meet your focus control needs, Swing allows you to create
and use your own custom focus manager.
Let's take a quick look at the relationship between the AWT and Swing focus
managers. The following figure shows how JFC incorporates both the AWT and
Swing focus managers.
There are two JComponent methods that allow you to explicitly set the focus to a
given component: requestFocus and grabFocus. If you've worked with AWT
components, you're probably familiar with the requestFocus method. Swing overrides
this Component method with an implementation that allows you to call the new
setRequestFocusEnabled method. This method can enable or disable the component
from getting the focus via requestFocus.
Let's take a look at a bit of sample code written for components. This code will cause
a component to get the focus whenever the component is under the mouse:
if(!hasFocus()) {
// ensure requestFocus is enabled
if(!isRequestFocusEnabled()) { setRequestFocusEnabled(true); }
requestFocus();
}
And if you're writing a focus manager, you can use grabFocus:
if(!hasFocus()) { grabFocus(); }
Like AWT 1.1, Swing provides the means for a component to transfer the focus to the
next component with the transferFocus method.
This method can be useful for implementing components that automatically advance
the focus when the user has completed whatever task or purpose is served by the
component (like choosing from a group of radio buttons or items in a list).
transferFocus is not really useful for explicitly setting the focus -- you would have to
know which component has the focus just before the component that you actually
want to set the focus to.
Swing doesn't bring any changes to the operation of AWT 1.1's focus listener
implementation. I'll give a brief description of focus listeners for those readers that
aren't familiar with them; if you know this stuff you may want to skip on to the next
section. Focus listeners provide a means of notifying applications when components
gain or lose the focus. The adapter class for focus events, FocusAdapter, has two
methods: focusGained and focusLost. The addFocusListener and
removeFocusListener methods add and remove focus listeners for components.
Standard event-listener stuff -- nothing fancy here. Let's glance at a piece of code.
The following code fragment adds a focus listener that changes the background color
when a component gets the focus.
You can't always count on getting focusGained and focusLost events in matched
pairs, hence the need for the bFocusIndicated variable to keep up with whether we've
indicated focus on a component.
Up until this point, most of what I've covered is probably familiar to you if you have
much experience with AWT 1.1 components. Now we'll start getting into Swing's
new and improved features. Swing provides a mechanism for component-managed
focus traversal. This can be a powerful alternative to writing your own focus manager
and is a better solution for developing components that have their own particular
behavior when it comes to gaining and losing the focus. For example, say you want to
develop a text field component that won't surrender the focus until the user enters
valid data. If you've tried to implement such a component in AWT 1.1 by using the
focusLost notification to validate the data and then set the focus back to the text field,
you've probably experienced some frustration. One obvious solution to this problem
-- calling requestFocus while processing the focusLost event -- doesn't always have a
predictable outcome. With Swing components, you can override the
isManagingFocus method to return true and get Tab and Shift-Tab keystrokes sent to
the component's key listener. This allows the component to manage focus traversal
when the component has the focus. The following code implements a text field that
doesn't allow the focus to traverse to the next component until valid data is entered:
// Constructors
public MyTextField () {
super();
init();
}
public MyTextField (String text) {
super(text);
init();
}
In this example, any keystrokes other than Tab keystrokes are considered to be valid
data. If no valid data has been entered, the text field's key listener consumes Tab
keystrokes, preventing them from reaching the focus manager. Of course, if you were
implementing this technique in a real application, you would want to present a
message to the user and inform them as to why they are being prevented from tabbing
away from the text field. One limitation to managing focus traversal at the component
level is that you can't control focus changes initiated by mouse actions. In fact, you
can't even do this by writing your own custom focus manager. To control focus
changes initiated by mouse actions, you'll have to modify the low-level mouse
handling for all of your components.
Mixing AWT and Swing components
The Swing focus manager effectively sits on top of the AWT focus manager. It can
only manage focus for Swing components, so if you're mixing AWT and Swing
components, you should disable the Swing focus manager with the following line of
code.
FocusManager.disableSwingFocusManager();
The AWT focus manager will then manage focus for all of your components.
Unfortunately, you can't disable the focus manager on a per-window or per-container
basis -- when you disable it, it's disabled for your entire application.
Writing a custom focus manager
Swing provides the ability for applications to install and use their own custom focus
manager. If you can't get the focus traversal behavior you want by using requestFocus
and transferFocus, or by managing focus at the component level, you might want to
consider writing a custom focus manager. Although Swing does provide a complete,
clean structure for supporting custom focus managers, writing a robust focus manager
that works well with any arbitrary component hierarchy is no trivial task. Overriding
the behavior of the default focus manager (represented by the DefaultFocusManager
class) may look like a promising and cheap way to create a custom focus manager. I
don't recommend this approach. In my opinion, the default focus manager isn't really
designed to be extended. For example, you might think you can just override the
compareTabOrder method and implement any tabbing algorithm you like. That would
be nice, but it doesn't quite work that way -- the default focus manager makes certain
assumptions about the tabbing order before it even calls compareTabOrder. If you try
to customize the default focus manager, I guarantee you will spend a lot of time in the
sources trying to understand exactly how everything works.
* getCurrentManager
* setCurrentManager
* disableSwingFocusManager
* isFocusManagerEnabled
The remaining three methods in the class are abstract methods that focus managers
must implement:
* processKeyEvent
* focusNextComponent
* focusPreviousComponent
That's right -- there are only three methods you must implement to create a custom
focus manager. Two of the methods, focusNextComponent and
focusPreviousComponent, simply advance the focus to the next or previous
component. The other method, processKeyEvent, is a low-level handler for key
events. This method looks for focus-change keystrokes (normally Tab and Shift-Tab)
and then calls focusNextComponent or focusPreviousComponent to change the focus.
The static class methods getCurrentManager, setCurrentManager,
disableSwingFocusManager and isFocusManagerEnabled give you access to the
current focus manager and allow you to disable the Swing focus management services
as well as install your own focus manager. The abstract methods processKeyEvent,
focusNextComponent, and focusPreviousComponent are methods you must override
and implement if you are writing a focus manager.
Let's take a look at an example of a custom focus manager. This example application,
called "CustomFocusManagerExample," implements a focus manager that allows you
to specify the tab order of components, regardless of their screen position or the order
in which they were added to their container. The custom focus manager used in this
example determines focus changes by querying the currently-focused component for
the next or previous component to get the focus. Components managed by this focus
manager must implement methods for setting and getting the next and previous focus
recipients. There are four parts to this example:
The application creates six text fields identified by a number from one to six. Instead
of adding the text fields to their container in numerical order, it adds them in a
somewhat arbitrary order: one, six, three, five, two, four. The application then sets the
tab order such that focus traverses the text fields in numerical order: one, two, three,
four,
five, six. Here's a screen shot of the application when it's run as a standalone
application.
Now let's get into the implementation. We'll start with the interface that components
must implement to be managed by our custom focus manager.
interface CustomFocusManagerSupport {
public void setNextFocus(JComponent component);
public void setPreviousFocus(JComponent component);
public JComponent getNextFocus();
public JComponent getPreviousFocus();
}
The interface is pretty simple -- just a few methods to set and get focus-traversal
information. The MyTextField class implements this interface by adding two private
instance data members to store the next and previous components to get the focus.
class MyTextField extends JTextField implements CustomFocusManagerSupport {
private JComponent nextFocus = null;
private JComponent previousFocus = null;
// Constructors
...
Now let's look at the code for the custom focus manager. This example focus
manager is implemented in a class named CustomFocusManager, an extension of the
FocusManager class. Two of the abstract methods that focus managers must
implement are focusNextComponent and focusPreviousComponent. Here's how we
implement these methods in the CustomFocusManager class.
Nothing fancy here either -- we just check to see if the given component implements
the CustomFocusManagerSupport interface and call getPreviousFocus or
getNextFocus to get the component that should next get the focus. We then set the
focus to that component by calling its grabFocus method. Before I show you how the
focus manager processes keystrokes, let's stop for a moment and think about the
focusNextComponent and focusPreviousComponent methods. Remember, these are
abstract methods that all focus managers must implement. Does it seem odd that these
methods have a parameter specifying a component? When you tell the focus manager
to advance the focus, you must give it the component that should have the focus
before the component you want to advance it to. I know this seems convoluted, but it
makes sense when you understand that the focus manager doesn't keep track of which
component currently has the focus. Focus management is a cooperative effort
between components and the focus manager. The final part of the custom focus
manager code is the implementation of the processKeyEvent method. This is the part
of the focus manager that actually handles the special keystrokes that change the
focus.
The processKeyEvent method looks for Tab and Shift-Tab keystrokes and then calls
focusNextComponent and focusPreviousComponent to change the focus. It only
handles focus for components that implement the CustomFocusManagerSupport
interface. Note that focus changes occur only on the KEY_PRESSED event --
processKeyEvent consumes corresponding KEY_RELEASED and KEY_TYPED
events by calling the KeyEvent.consume method. The remaining piece of the puzzle
is how the application installs a custom focus manager. This is accomplished by
creating an instance of the custom focus manager and setting it as the current focus
manager by calling the FocusManager class method setCurrentManager.
platform they are on and should be easier to maintain (for Sun). As all graphical
components
are “lightweight”, their appearance is controlled purely by the Java code (without the
need for
platform dependent peers – as in JDK 1.0 and 1.1). In swing, a separate user interface
“view”
component performs the actual rendering of the component on the screen. This allows
different views to be plugged in. This in turn allows the idea of different “looks and
feels”. This
means that it should be possible for a Unix developer to select the Win95/NT look
and feel
and see what the interface would look like on that platform. It also means that it is
easier to
deploy the same software on different platforms, but with interfaces that match the
interface
manager on that particular platform. This separation of view form the actual
component is
based on a modified version of the Model-View-Controller architecture (described
later).
Swing also provides a greatly increased set of facilities for graphical user interfaces,
including
trees, icons on buttons, dockable menus bars, menus with icons, borders and
improved
So does this mean that the AWT (The Abstract Window Kit) of version 1.0 and 1.1 of
Java is
being thrown out of the window? Not exactly, the AWT will still be available and
systems can
be constructed using both the AWT and Swing (although there are some limitations).
However, as the AWT knows nothing about different “look and feels” and mixes both
lightweight (pure Java) and heavy weight (native) components, any AWT windows
may not be
consistent with the Swing windows. From the point of view of the developer, it makes
little
sense to continue to use the AWT when all of the AWT’s facilities (and more) are
replicated in
Swing. Indeed, much of what an AWT developer already knows will go a long way to
helping
core component of the JFC along with Java2D, Accessibility and Drag and Drop. It is
the
largest element of the JFC (as it stands now) and will therefore be taken by many to
equate to
the JFC. Indeed one insider has said that it is “spelt JFC but pronounced Swing”.
However, as
can be seem from the above list, this is not the case. As this column is about Swing
we will
not digress into Java2D, the Accessibility API or Drag and Drop, except to say that
each is a
significant development with Java2D being a major improvement over the basic
facilities in
previous version of the JDK.
So where does that leave the JDK 1.2? In many ways JDK 1.2 is the JFC plus various
enhancements which consolidate JDK 1.1. For example, JDK 1.2 includes numerous
collection classes for data structures that greatly improve on the basic set of facilities
provided
with JDK 1.0 and 1.1. Equally, the performance enhancements provided will be of
welcome,
however it is the Swing set of components that will grab the attention.
SCREENS :-
represents interesting anomaly for the software. During earlier definition and
tangible implementation.
The testing phase involves the testing of the developed system using various test
data. Preparation of the test data plays a vital role in the system testing. After
preparing the test data the system under study was tested using those test data. While
testing the system, errors were found and corrected by using the following testing
steps and corrections are also noted for future use. Thus, a series of testing is
performed for the proposed system, before the system was ready for the
implementation.
Testing is the process of detecting errors.Testing performs a very critical role for
quality assurance and for ensuring the reliability of software.The results of testing are
The aim of testing is often to demonstrate that a program works by showing that it has
no errors.The basic purpose of testing phase is to detect the errors that may be present
in the program.Hence one should not start testing with the intent of showing that a
Doesn’t work.
Testing Objectives:
The main objective of testing is to uncover a host of errors, systematically and
• A good test case is one that has a high probability of finding error, if it exists.
• The software more or less confirms to the quality and reliable standards.
Levels of testing
In order to uncover the errors present in different phases we have the concept of
Unit testing:
Unit testing focuses verification effort on the smallest unit of software i.e. the
module. Using the detailed design and the process specifications testing is done to
uncover errors within the boundary of the module. All modules must be successful in
the unit test before the start of the integration testing begins.
In this project ’Digital Water Marking on Multimedia Files’ the techniques FHT and
DCT
Unit testing focuses verification effort on the similar unit of software design the form.
This is known as form testing. Using the unit test plans, prepared in design phase of
the system development as a guide, important control paths are tested to uncover error
with in the boundary of the module. In this testing step, each module is found to be
Each module has been tested by giving different sets of inputs,when developing the
module as well as finishing the development so that each module works without any
Integration Testing:
After the unit testing we have to perform integration testing. The goal here is to see if
modules can be integrated properly, the emphasis being on testing interfaces between
modules. This testing activity can be considered as testing the design and hence the
In this project integrating all the modules forms the main system. When integrating
all the modules we have checked whether the integration effects working of any of
the services by giving different combinations of inputs with which the two services
structure while at the same time conducting tests to uncover errors associated with the
interface. All modules are combined in the testing step. Then the entire program is
tested as a whole.
Validation testing:
assembled as a package, interfacing errors have been uncovered and corrected and
SYSTEM TESTING
Here the entire software system is tested.The reference document for this process is
the requirements document, and the goal os to see if software meets its requirements.
Here entire project has been tested against requirements of project and it is checked
Output testing:
After performing validation testing, the next steps are output testing of the
proposed system, since no system could be useful if it does not produce the desired
output in the specified format. The output generated are displayed by the system
under consideration or tested by asking the user about the format required by them.
Here the output format is considered in two ways. One is on the screen and the other
Acceptance Test is performed with realistic data of the client to demonstrate that
software development. It is the process of finding errors and missing operations and
also a complete verification to determine whether the objectives are met and the user
User acceptance of a system is the key factor for the success of any system.
The system under consideration was tested for user acceptance by constantly keeping
in touch with the perspective system users at the time of developing and making
changes whenever required. This is done with regard to the following points.
This is a unit testing method where a unit will be taken at a time and tested
I tested step wise every piece of code, taking care that every statement in the code
is executed at least once. The white box testing is also called Glass Box Testing.
I have generated a list of test cases ,sample data.which is used to check all possible
This testing method considers a module as a single unit and checks the unit at
interface and communication with other modules rather getting into details at
statement level. Here the module will be treated as a block box that will take some
Input generate output. Output for a given set of input combinations are forwarded to
other module.
CONCLUSION
2.Van Schyndel, R.J., Trikel, A.Z., Osborne, A.F.,” A digital watermark,” Proc .
IEEE Int. Conf. Image Processing, vol . 2, 86-90, 1994.
3.Cox, I.J., Kilian, J., Leighton, F.T., Shamoon, T., “Secure spread spectrum
watermarking for multimedia,” IEEE Trans. Image Processing, vol. 6, 1673-
1687, Dec. 1997.
4.Hsu, C.T., Wu, J.L., “Hidden digital watermarks in images,” IEEE Trans. Image
Processing, vol.8, pp. 58-68, Jan. 1999.
5.Joseph, J.K., O’ Ruanaidh, Pun T., “Rotation, Scale and Translation Invarient .
Digital Image Watermarking”, Signal Processing, vol.66, No.3, 303-317, 1998.
6.Wei, Z.H., Qin, P., Fu, Y.Q.,”Perceptual digital watermark of image using
wavelet transform “, IEEE Trans. On Consumer Electronics, Vol. 44, No.4, 1267-
1272, Nov. 1998.
7.Dugad, R., Ratakonda, K., Ahuja, N, “A new wavelet – base for watermarking
image,” in Proc. Int . Conf. Image Processing, vol.45, 1097- 101, Aug. 1998.