project viii

Upload: vishalaroraccna

Post on 29-May-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Project VIII

    1/42

    A Project Synopsis on gameof chess

    Submitted By:

    Shiva Chauhan

    Pankaj Kumar Pal

    Rahul Kumar Surendra Singh

  • 8/9/2019 Project VIII

    2/42

  • 8/9/2019 Project VIII

    3/42

    TABLE OF CONTENTS PAGESy DE CLARATION IIy CE RTIFICAT E IIIy ACKNOW E LDGEME NTS y ABSTRACT Vy LIST OF FI GU R E S VIy LIST OF ABBR E VIATIONS VIIy CHAPT E R 1

    Setup of game 5 M oves 6 Special moves 10 Histroy 12 M athematics and Computers 14

    y CHAPT E R 2

    G eneral Specifications 15 Technical Specifications 16

    y CHAPT E R 3

    Abstract Window Toolkit 17 Swing 20 Snapshots of the Project 31 Hardware Requirements 34 Software Requirements 34

    Platform for the Project 35 D ata Flow D iagram 36

    y R E FE R E NC E S 38

  • 8/9/2019 Project VIII

    4/42

    II

    DECLARATION

    We hereby declare that this project on the game of chess is our own work andthat to the best part of my knowledge and belief , it contains no material

    previously published or written by another person nor material which to asubstantial content have been approved forward of any degree of this or any other university .

    Name : Shiva Chauhan

    Pankaj Kumar Pal

    Rahul Kumar

    Surendra Singh

    D ate :07-05-2010

  • 8/9/2019 Project VIII

    5/42

  • 8/9/2019 Project VIII

    6/42

    IV

    ACKNOWLEDGEMENT

    We are indebted to M iss. Anita Arya , Senior Lecturer. in Information

    Technology department , who had faith in this project & our technical

    ability , whispered the words of encouragement and made helpful

    suggestions from time to time .

    We hope every student gets a mentor who is as cooperative , knowledgeable

    and supportive as M iss. Anita Arya.

    D uring the course of development of this project many people helped in

    executing programs , spotting bugs and other developments.

    I trust with our collective acumen , all programs would run correctly in all

    Situations.

    We thank our other faculty members for their constant support not only

    during development of this project but throughout our engineering

    Carrier.

    And finally my heartfelt gratitude to our parents and our friends for

    encouraging us in every step of our life .

  • 8/9/2019 Project VIII

    7/42

    V

    ABSTRACT

    This project is on the G ame of Chess . Chess a very popular game throughout

    the world and this project presents the software for playing the game on the

    computer . The game is essentially designed for only 2 players at a time in

    accordance to the rule of the game . Platform for the development of the project

    is JAVA . Since main necessity for the development of this project was a easy to

    use and effective GU I , and JAVA provides an excellent GU I through AWT and

    Swing . Therefore , JAVA proved to be the perfect platform for the development

    of this project .

    Since JAVA is a platform independent language , it add another marvelous feature

    to this software that it may run on any operating system .

    Regarding the coding for the software , as described earlier all coding is done in

    JAVA . There are 15 different modules in the project and all are linked to each

    other through predefined and self - defined packages .

  • 8/9/2019 Project VIII

    8/42

    VI

    List of Figures

    Setup of the game M oves :

    o M oves of king

    o M

    oves of rook o M oves of bishopo M oves of queeno M oves of knighto M oves of pawn

    Castling Special Pawn moves Snapshots of the project D ata Flow D iagrams

  • 8/9/2019 Project VIII

    9/42

    VII

    LIST OF ABBREVIATIONS

    AWT Abstract Window Toolkit API Application Program Interface GU I G raphical U ser Interface JFC Java Foundation Classes RA M Random Access M emory M B M ega Bytes JD K Java D evelopers Kit D FD D ata Flow D iagram

  • 8/9/2019 Project VIII

    10/42

    1

    DEVELOPERS INFORMATION

    Project Title GAME OF CHESS

    D evelopers Name Shiva Chauhan, Pankaj Kumar Pal,

    Rahul Kumar, Surendra Singh

    College Address G.P. Kashipur

    Du ration : 1 Semesters

    D evelopment Platform : JAVA

  • 8/9/2019 Project VIII

    11/42

    4

    GAME OF CHESSChe ss is a recreational and competitive game played between two players. Thecurrent form of the game emerged in Southern E urope during the second half of the 15th century after evolving from similar, much older games of Indian andPersian origin. Today, chess is one of the world's most popular games, played bymillions of people worldwide at home, in clubs, online, by correspondence, and intournaments.

    The game is played on a square chequered chessboard with 64 squares arranged inan eight-by-eight grid. At the start, each player (one controlling the white pieces,the other controlling the black pieces) controls sixteen pieces: one king, onequeen, two rooks, two knights, two bishops, and eight pawns. The object of thegame is to checkmate the opponent's king, whereby the king is under immediateattack (in "check") and there is no way to remove it from attack on the next move.

    The tradition of organized competitive chess started in the 16th century and hasdeveloped extensively. Chess today is a recognized sport of the InternationalOlympic Committee. The first official World Chess Champion, Wilhelm Steinitz,claimed his title in 1886; Viswanathan Anand is the current World Champion.Theoreticians have developed extensive chess strategies and tactics since thegame's inception. Aspects of art are found in chess composition.

    One of the goals of early computer scientists was to create a chess-playingmachine. Today's chess is deeply influenced by the abilities of current chess

    programs and the ability to play against others online. In 1997, D eep Blue becamethe first computer to beat the reigning World Champion in a match when itdefeated G arry Kasparov.

  • 8/9/2019 Project VIII

    12/42

    5

    Setup of game

    Initial position: first row: rook, knight, bishop, queen, king, bishop, knight, and rook; secondrow: pawns

    Chess is played on a square board of eight rows (called ranks and denoted with numbers 1 to 8)and eight columns (called files and denoted with letters a to h) of squares. The colors of the

    sixty-four squares alternate and are referred to as "light squares" and "dark squares". Thechessboard is placed with a light square at the right hand end of the rank nearest to each player,and the pieces are set out as shown in the diagram, with each queen on its own color.

    The pieces are divided, by convention, into white and black sets. The players are referred to as"White" and "Black", and each begins the game with sixteen pieces of the specified color. Theseconsist of one king, one queen, two rooks, two bishops, two knights and eight pawns.

  • 8/9/2019 Project VIII

    13/42

    White always moves first. The players alternate moving one piece at a time (with the exceptionof castling, when two pieces are moved simultaneously). Pieces are moved to either anunoccupied square, or one occupied by an opponent's piece, capturing it and removing it from

    6

    play. With one exception ( en passant ), all pieces capture opponent's pieces by moving to thesquare that the opponent's piece occupies.

    When a king is under immediate attack by one or two of the opponent's pieces, it is said to be incheck . The only permissible responses to a check are to capture the checking piece, interpose a

    piece between the checking piece and the king, or move the king to a square where it is notunder attack. Castling is not a permissible response to a check. A move that would place themoving player's king in check is illegal. The object of the game is to checkmate the opponent;this occurs when the opponent's king is in check, and there is no way to remove it from a tt ack.

    MOVESE ach chess piece has its own style of moving. The Xs mark the squares where the piece canmove if no other pieces (including one's own piece) are on the Xs between the piece's initial

    position and its destination. If there is an opponent's piece at the destination square, then themoving piece can capture the opponent's piece. The only exception is the pawn which can onlycapture pieces d iagonally forwar d .

    Mov es of a king

  • 8/9/2019 Project VIII

    14/42

    7

    Mov es of a roo k

    M oves of a bishop

  • 8/9/2019 Project VIII

    15/42

  • 8/9/2019 Project VIII

    16/42

    9

    M oves of a pawn

    Special moves

    Castling

  • 8/9/2019 Project VIII

    17/42

  • 8/9/2019 Project VIII

    18/42

    The p a wn on c7 ca n pr omo te . If Black' s la st m ove w a s ... f 7-f 5, White 's e-p awn m a y ca pture the B lack pa wn en passant .

    10

    11

    Promotion

    When a pawn advances to its eighth rank, it is exchanged for the player's choice of a queen,rook, bishop, or knight of the same color. U sually, the pawn is chosen to be promoted to aqueen, but in some cases another piece is chosen, called underpromotion. In the diagram on theright, the pawn on c7 can choose to advance to the eighth rank to promote to a better piece.

    E nd of t he gam e

    Chess games do not have to end in checkmate either player may resign if the situation lookshopeless. If it is a timed game a player may run out of time and lose, even with a much superior

    position. G ames also may end in a draw (tie). A draw can occur in several situations, includingdraw by agreement, stalemate, threefold repetition of a position, the fifty-move rule, or a draw

    by impossibility of checkmate (usually because of insufficient material to checkmate).

  • 8/9/2019 Project VIII

    19/42

    12

    H istory

    P r e d ece ssors

    Chess originated in India during the G upta empire, where its early form in the 6th century wasknown as catura ga , which translates as "four divisions [of the military]" infantry, cavalry,elephants, and chariotry, represented by the pieces that would evolve into the modern pawn,knight, bishop, and rook, respectively. Both the Persians and Arabs attribute the game of chessto the Indians. [17] In Sassanid Persia around 600 the name became shatranj and the rules weredeveloped further. Shatranj was taken up by the M uslim world after the Islamic conquest of Persia, with the pieces largely retaining their Persian names. In Spanish "shatranj" was renderedas aje d rez, in Portuguese as xad rez, and in G reek as zatrikion , but in the rest of E urope it wasreplaced by versions of the Persian sh h ("king"), which was familiar as an exclamation and

    became our words "check and chess". M urray theorized that this change happened from M uslimtraders coming to E uropean seaports with ornamental chess kings as curios before they broughtthe game of chess.

    The game reached Western E urope and Russia by at least three routes, the earliest being in the9th century. By the year 1000 it had spread throughout E urope.Introduced into the Iberian

  • 8/9/2019 Project VIII

    20/42

  • 8/9/2019 Project VIII

    21/42

    the World Chess Federation (FI DE ), founded in 1924 in Paris. In 1927, Women's World ChessChampionship was established; the first to hold it was Czech- E nglish master Vera M enchik. [38]

    14

    Mathematics and computersThe game structure and nature of chess is related to several branches of mathematics. M anycombinatorical and topological problems connected to chess were known of for hundreds of years. In 1913, E rnst Zermelo used it as a basis for his theory of game strategies, which isconsidered as one of the predecessors of game theory.

    The number of legal positions in chess is estimated to be between 10 43 and 10 50, with a game-tree complexity of approximately 10 123 . The game-tree complexity of chess was first calculated

    by Claude Shannon as 10 120 , a number known as the Shannon number. Typically an average position has thirty to forty possible moves, but there may be as few as zero (in the case of checkmate or stalemate) or as many as 218.

    The most important mathematical challenge of chess is the development of algorithms whichcan play chess. The idea of creating a chess playing machine dates to the 18th century; around1769, the chess playing automaton called The Turk became famous before being exposed as ahoax. Serious trials based on automatons, such as E l Ajedrecista, were too complex and limitedto be useful.

  • 8/9/2019 Project VIII

    22/42

    Since the advent of the digital computer in the 1950s, chess enthusiasts and computer engineershave built, with increasing degrees of seriousness and success, chess-playing machines andcomputer programs. The groundbreaking paper on computer chess, "Programming a Computer for Playing Chess", was published in 1950 by Shannon.He wrote:

    15

    About the pr oject

    Gener a l Spe cif ica tio ns

    The g a me of chess ca n be p la yed between 2 p la yers . The g a me ca n be p la yed on a ny oper a ting system . There is n o pr ov isio n fo r sing le p la yer g a me in the g a me . There a ppe a rs err o r mess a ge fo r e very i lleg a l / wr ong step . There is n o pr ov isio n fo r a und o to cre a te a mo re re a listic experien ce .

    A congr a tesmess a ge isdisp la yed when a

    pla yer win .

  • 8/9/2019 Project VIII

    23/42

    16

    Te chni ca l Spe cif ica tio ns

    Project is P la tfo rm Independent . Project is bui ld up using JDK 1 .5.1.

    GUI comp onents of the pr oject a re pr ov ide by AWT , Swings . To run the pr oje ct there must be JDK inst a lled . Steps fo r running the pr oject :-

    I. Open comm a nd interpreterII. Spe cif y the p a th fo r the Chess

    folderIII. Type ja vac chess . ja va IV. Type ja va chess

  • 8/9/2019 Project VIII

    24/42

    17

    Abstract Window ToolkitThe Abstra c t Window Toolkit (AWT) is Java's original platform-independent windowing,graphics, and user-interface widget toolkit. The AWT is now part of the Java FoundationClasses (JFC) the standard API for providing a graphical user interface ( GU I) for a Java

    program.

    AWT is also the GU I toolkit for a number of Java ME profiles. For example, Connected D eviceConfiguration profiles require Java runtimes on mobile telephones to support AWT.

    .

    Architecture

    The AWT provides two levels of APIs:

  • 8/9/2019 Project VIII

    25/42

    y A gener a l inter f ac e between J a va a nd the n a tive system , used fo r wind owing , events , la youtma na gers . This API is a t the core of Java GUI progra mming a nd is a lso used by Swing and J a va 2D. It cont a ins:

    o The inter f ac e between the n a tive wind owing system a nd the J a va a pp lica tion;o The core of the GUI e vent subsystem;o Sever a l layout m ana gers;

    18

    o The inter f ac e t o input de vices su ch a s m ouse a nd keyb oa rd; a ndo A java.awt.datatransfer packa ge fo r use with the C lipb oa rd a nd Dr a g a nd Dr op .

    y A ba sic set of GUI widgets su ch a s butt ons , text b oxes , a nd menus . It a lso pr ov ides the AWTNa tive Inter f ac e , whi ch en a bles rendering libr a ries compi led t o na tive code t o dr a w dire ct ly to

    a n AWT C anvas ob ject dr a wing sur f ac e .

    AWT also provide some miscellaneous useful utilities, that can also be used by Swing, such as:

    y Access t o the system tr a y on supp orting systems; a ndy The a bility t o la un ch some des ktop a pp lica tions su ch a s web br owsers a nd em a il clients f rom a

    Java a pp lica tion .

    Neither AWT nor Swing are inherently thread safe. Therefore, code that updates the GU I or processes events should execute on the E vent dispatching thread. Failure to do so may result ina deadlock or race condition. To address this problem, a utility class called S wingWorker allows

    applications to perform time-consuming tasks following user-interaction events in the eventdispatching thread.

    Mixing AWT and Swing c ompon e nts

    Prior to Java 6 U pdate 12, mixing Swing components and AWT basic widgets has often resultedin undesired side effects, with AWT widgets going on top of the Swing widgets regardless of their defined priorities. This problem was due to the fact that the rendering architecture of the

    two widgets toolkit was very different, despite Swing borrowing heavyweight top containersfrom AWT.

    Since Java 6 U pdate 12, it is now possible to mix Swing and AWT widgets without having priorities problems

  • 8/9/2019 Project VIII

    26/42

    Window Fundamentals

    The AWT defines windows according to a class hierarchy that adds functionality andspecificity with each level. The two most common windows are those derived fromPanel , which is used by applets , and those derived from Frame , which creates astandard window. Much of the functionality of these windows is derived from their parent classes. Thus , a description of the class hierarchies relating to these two classes

    19

    is fundamental to their understanding.

    Component

    At the top of the AWT hierarchy is the Co mp o nent class. Co mp o nent is an abstractclass that encapsulates all of the attributes of a visual component. All user interface

    elements that are displayed on the screen and that interact with the user are subclassesof Co mp o nent . It defines over a hundred public methods that are responsible for managing events , such as mouse and keyboard input , positioning and sizing thewindow , and repainting. A Co mp o nent object is responsible for rememberingthe current foreground and background colors and the currently selected text font.

    Container

    The Co ntainer class is a subclass of Co mp o nent . It has additional methods that allowother Co mp onent objects to be nested within it. Other Co ntainer objects can be storedinside of a Co ntainer (since they are themselves instances of Co mp onent ). This makesfor a multileveled containment system.

    PanelThe Panel class is a concrete subclass of Co ntainer . It doesnt add any new methods; itsimply implements Co ntainer . A Panel may be thought of as a recursively nestable , concrete screen component. Panel is the superclass for Applet . When screen output isdirected to an applet , it is on the surface of a Panel object. In essence , a Panel isa window that does not contain a title bar , menu bar , or border. This is why you dontsee these items when an applet is run inside a browser. When you run an applet using

    an applet viewer , the applet viewer provides the title and border.Other components can be added to a Panel object by its add( ) method (inheritedfrom Co ntainer ). Once these components have been added , you can position and resizethem manually using the setL oc ati o n( ), setSize( ), or setB ou nds( ) methods defined by component.

    WindowThe Wind ow class creates a top-level window. A top-level window is not containedwithin any other object; it sits directly on the desktop.

    Frame

    Frame encapsulates what is commonly thought of as a window. It is a subclass of

  • 8/9/2019 Project VIII

    27/42

    Wind ow and has a title bar , menu bar , borders , and resizing corners. If you create aFrame object from within an applet , it will contain a warning message , such as Java

    Applet Window , to the user that an applet window has been created. This messagewarns users that the window they see was started by an applet and not by softwarerunning on their computer. (An applet that could masquerade as a host-basedapplication could be used to obtain passwords and other sensitive information withoutthe users knowledge.) When a Frame window is created by a program rather than an

    applet , a normal window is created.

    20

    S wing Swing is a widget toolkit for Java. It is part of Sun M icrosystems' Java Foundation Classes(JFC) an API for providing a graphical user interface ( GU I) for Java programs,

    Swing was developed to provide a more sophisticated set of GU I components than the earlier Abstract Window Toolkit. Swing provides a native look and feel that emulates the look and feelof several platforms, and also supports a pluggable look and feel that allows applications tohave a look and feel unrelated to the underlying .

    Architecture

    Swing is a platform-independent, M od el-View-Controller GU I framework for Java. It follows asingle-threaded programming model, and possesses the following traits:

    Foundations

    Platform independence

    Swing is platform independent both in terms of its expression (Java) and its implementation(non-native universal rendering of widgets).

    Extensibility

    Swing is a highly partitioned architecture, which allows for the "plugging" of various customimplementations of specified framework interfaces: U sers can provide their own customimplementation(s) of these components to override the default implementations. In general,Swing users can extend the framework by extending existing (framework) classes and/or

    providing alternative implementations of core components.

  • 8/9/2019 Project VIII

    28/42

    C omponent Oriented

    Swing is a component-based framework. The distinction between objects and components is afairly subtle point: concisely, a component is a well-behaved object with a known/specifiedcharacteristic pattern of behaviour. Swing objects asynchronously fire events, have "bound"

    properties, and respond to a well-known set of commands (specific to the component.)Specifically, Swing components are Java Beans components, compliant with the Java BeansComponent Architecture specifications.

    21

    Cu stomizable

    G iven the programmatic rendering model of the Swing framework, fine control over the detailsof rendering of a component is possible in Swing. As a general pattern, the visual representationof a Swing component is a composition of a standard set of elements, such as a "border","inset", decorations, etc. Typically, users will programmatically customize a standard Swingcomponent (such as a JTable) by assigning specific Borders, Colors, Backgrounds, opacities,etc., as the properties of that component. The core component will then use these property(settings) to determine the appropriate renderers to use in painting its various aspects. However,it is also completely possible to create unique GU I controls with highly customized visualrepresentation.

    C onfig u rable

    Swing's heavy reliance on runtime mechanisms and indirect composition patterns allows it torespond at runtime to fundamental changes in its settings. For example, a Swing-basedapplication can change its look and feel at runtime. Further, users can provide their own look and feel implementation, which allows for uniform changes in the look and feel of existingSwing applications without any programmatic change to the application code.

    The JComponent Class

    With the exception of top-level containers, all Swing components whose names begin with "J"descend from the JC omponent class. For example, JP anel , JSc roll P ane , JBu tton , and JT able all inherit from JC omponent . However, JF rame and JD ialog don't because they implement top-level containers.

    The JC omponent class extends the C ontainer class, which itself extends C omponent . TheC omponent class includes everything from providing layout hints to supporting painting andevents. The C ontainer class has support for adding components to the container and laying

  • 8/9/2019 Project VIII

    29/42

    them out. This section's API tables summarize the most often used methods of C omponent andC ontainer , as well as of JC omponent .

    22

    JComponent Features

    The JC omponent class provides the following functionality to its descendants:

    y Tool tipsy Painting and bordersy Application-wide pluggable look and feely Custom propertiesy Support for layouty Support for accessibilityy Support for drag and dropy D ouble bufferingy Key bindings

    The JComponent API

    The JC omponent class provides many new methods and inherits many methods fromC omponent and C ontainer . The following tables summarize the methods we use the most.

    y Customizing Component Appearancey Setting and G etting Component Statey Handling E ventsy Painting Componentsy D ealing with the Containment Hierarchyy Laying Out Componentsy G etting Size and Position Informationy Specifying Absolute Size and Position

  • 8/9/2019 Project VIII

    30/42

    23

    Swings Methods & There Purpose

    Customizing Component Appearance

    M ethod Purpose

    void setBorder(Border)Border getBorder()

    Set or get the border of the component. See How to U se Borders for details.

    voidsetForeground(Color)voidsetBackground(Color)

    Set the foreground or background color for the component. Theforeground is generally the color used to draw the text in a component.The background is (not surprisingly) the color of the background areasof the component, assuming that the component is opaque.

    Color getForeground()Color getBackground()

    G et the foreground or background color for the component.

    voidsetOpaque(boolean)

    boolean isOpaque()

    Set or get whether the component is opaque. An opaque componentfills its background with its background color.

    void setFont(Font)

    Font getFont()

    Set or get the component's font. If a font has not been set for the

    component, the font of its parent is returned.void setCursor(Cursor)Cursor getCursor()

    Set or get the cursor displayed over the component and all componentsit contains (except for children that have their own cursor set).

  • 8/9/2019 Project VIII

    31/42

    24

    Setting and G etting Component State

    M ethod Purpose

    voidsetComponentPopup M enu(String)

    Sets the JP op u pMen u for this JC omponent . The U I isresponsible for registering bindings and adding the necessarylisteners such that the JP op u pMen u will be shown at theappropriate time. When the JP op u pMen u is shown dependsupon the look and feel: some may show it on a mouse event,some may enable a key binding.

    void setToolTipText(String) Set the text to display in a tool tip. See How to U se Tool Tipsfor more information.

    void setName(String)String getName()

    Set or get the name of the component.

    boolean isShowing() D etermine whether the component is showing on screen. Thismeans that the component must be visible, and it must be in acontainer that is visible and showing.

    void set E nabled(boolean) boolean is E nabled()

    Set or get whether the component is enabled. An enabledcomponent can respond to user input and generate events.

    void setVisible(boolean) boolean isVisible()

    Set or get whether the component is visible. Components areinitially visible, with the exception of top-level components.

  • 8/9/2019 Project VIII

    32/42

    25

    Handling E vents

    M ethod Purpose

    void addHierarchyListener(hierarchyListener l)void removeHierarchyListener(hierarchyListener l)

    Adds or removes the specified hierarchylistener to receive hierarchy changedevents from this component when thehierarchy to which this container belongschanges. If listener l is null, no exceptionis thrown and no action is performed.

    void add M ouseListener( M ouseListener)void remove M ouseListener( M ouseListener)

    Add or remove a mouse listener to or from the component. M ouse listeners arenotified when the user uses the mouse to

    interact with the listened-to component.voidadd M ouse M otionListener( M ouse M otionListener)voidremove M ouse M otionListener( M ouse M otionListener)

    Add or remove a mouse motion listener to or from the component. M ouse motionlisteners are notified when the user movesthe mouse within the listened-tocomponent's bounds.

    void addKeyListener(KeyListener)void removeKeyListener(KeyListener)

    Add or remove a key listener to or fromthe component. Key listeners are notifiedwhen the user types at the keyboard andthe listened-to component has the

    keyboard focus.void addComponentListener(ComponentListener)void removeComponentListener(ComponentListener)

    Add or remove a component listener to or from the component. Componentlisteners are notified when the listened-tocomponent is hidden, shown, moved, or resized.

    boolean contains(int, int) D etermine whether the specified point is

  • 8/9/2019 Project VIII

    33/42

    boolean contains(Point) within the component. The argument

    should be specified in terms of thecomponent's coordinate .

    Component getComponentAt(int, int)Component getComponentAt(Point)

    Return the component that contains thespecified x, y position. The top-most childcomponent is returned in the case wherecomponents overlap.

    26

    Painting Components

    M ethod Purpose

    void repaint()void repaint(int, int, int, int)

    Request that all or part of the component be repainted. The four int arguments specify the bounds ( x, y, width, height, in thatorder) of the rectangle to be painted.

    void repaint(Rectangle) Request that the specified area within the component be repainted.

    void revalidate() Request that the component and its affected containers be laid outagain. You should not generally need to invoke this method unlessyou explicitly change a component's size/alignment hints after it'svisible or change a containment hierarchy after it is visible.

    void paintComponent( G raphics)

    Paint the component. Override this method to implement paintingfor custom components.

  • 8/9/2019 Project VIII

    34/42

    27

    D ealing with the Containment Hierarchy

    M ethod Purpose

    Component add(Component)Component add(Component, int)void add(Component, Object)

    Add the specified component to thiscontainer. The one-argument versionof this method adds the component to

    the end of the container.

    void remove(int)void remove(Component)void removeAll()

    Remove one of or all of thecomponents from this container.When present, the int argumentindicates the position within thecontainer of the component toremove.

    JRootPane getRootPane() G et the root pane that contains thecomponent.

    Container getTopLevelAncestor() G et the topmost container for thecomponent a Window , Applet , or null if the component has not beenadded to any container.

    Container getParent() G et the component's immediatecontainer.

    int getComponentCount() G et the number of components in this

  • 8/9/2019 Project VIII

    35/42

    container.

    Component getComponent(int)Component[] getComponents()

    G et the one of or all of thecomponents in this container. The int argument indicates the position of thecomponent to get.

    Component getComponentZOrder(int)Component[] getComponentZOrder()

    Returns the z-order index of thecomponent inside the container. Thehigher a component is in the z-order hierarchy, the lower its index.

    28

    Laying Out Components

    M ethod Purpose

    void setPreferredSize( D imension)void set M aximumSize( D imension)void set M inimumSize( D imension)

    Set the component's preferred,maximum, or minimum size,measured in pixels. The preferredsize indicates the best size for thecomponent.

    D imension getPreferredSize()D imension get M aximumSize()

    D imension get M inimumSize()

    G et the preferred, maximum, or minimum size of the component,

    measured in pixels.void setAlignmentX(float)void setAlignmentY(float)

    Set the alignment along the x- or y- axis. These values indicate how thecomponent would like to be alignedrelative to other components. Thevalue should be a number between 0and 1 where 0 represents alignmentalong the origin .

    float getAlignmentX()float getAlignmentY()

    G et the alignment of the componentalong the x- or y- axis. For non-JC omponent subclasses, which donot have the corresponding setter methods, you can set a component'salignment by creating a subclass andoverriding these methods.

    void setLayout(Layout M anager)Layout M anager getLayout()

    Set or get the component's layoutmanager. The layout manager isresponsible for sizing and positioning

  • 8/9/2019 Project VIII

    36/42

    the components within a container.

    voidapplyComponentOrientation(ComponentOrientation)void setComponentOrientation(ComponentOrientation)

    Set the C omponentOrientation property of this container and all thecomponents contained within it. SeeSetting the Container's Orientationfor more information.

    29 G etting Size and Position Information

    M ethod Purpose

    int getWidth()int getHeight()

    G et the current width or height of the component measured in pixels.

    int getX()int getY()

    G et the current x or y coordinate of the component's origin relative tothe parent's upper left corner measured in pixels.

    Rectangle getBounds()RectanglegetBounds(Rectangle)

    Get the bounds of the component measured in pixels. The boundsspecify the component's width, height, and origin relative to its

    parent. When using the one-argument version of this method, thecaller is responsible for creating the R e c tangle instance in which theresult is returned.

    Point getLocation()Point getLocation(Point)

    G ets the current location of the component relative to the parent'supper left corner measured in pixels. When using the one-argumentversion of getLo c ation method, the caller is responsible for creatingthe P oint instance in which the result is returned.

    PointgetLocationOnScreen()

    Returns the position relative to the upper left corner of the screen.

    Insets getInsets() G et the size of the component's border.

  • 8/9/2019 Project VIII

    37/42

    30

    Relationship to AWT

    Since early versions of Java, a portion of the Abstract Window Toolkit (AWT) has provided platform-independent APIs for user interface components. In AWT, each component is renderedand controlled by a native peer component specific to the underlying windowing system.

    By contrast, Swing components are often described as lightweight because they do not requireallocation of native resources in the operating system's windowing toolkit. The AWTcomponents are referred to as heavyweight co m ponents .

    Much of the Swing API is generally a complementary extension of the AWT rather than a directreplacement. In fact, every Swing lightweight interface ultimately exists within an AWT

    heavyweight component because all of the top-level components in Swing ( J Applet , JD ialog ,JF rame , and J Window ) extend an AWT top-level container.

  • 8/9/2019 Project VIII

    38/42

    Hardware Requirements

    Pentium Processor II or higher with min. 800 Mhz.

    Min. 128 MB of RAM.

    700 MB free space in hard disk.

    Software Requirement

    Java Development Kit ( JDK )

  • 8/9/2019 Project VIII

    39/42

    Platform for the project

    The system has been developed using JAVA which is platform independent. Thisallows the system to be independent of the platform being used to run the system.Hence , whether a windows operating system is used or a Mac , or Linux operatingsystem is used the same performance of the system can ba availed of by the user.

    Fundamentals of Java

    Java developed by Sun

    Sun describes Java as:

    Simple , Object-oriented , Distributed , Interpreted , Robust , Secure , Architecture neutral , Portable , High-performance , Multithreaded , andDynamic Language

    Tools Available for Java Programming

    Java Developers Kit (JDK)

    JDK from J avaSoft a division of Sun Microsystems Inc.

    Contains the basic tools and libraries necessary for creating , testing , documenting and executing Java programs

    There are seven main programs in JDK

    j avac the Java Compiler j ava the Java Interpreter j avadoc generates documentation in HTML

  • 8/9/2019 Project VIII

    40/42

    appletviewer the Java Interpreter to execute Java applets j db the Java Debugger to find and fix bugs in Java programs j avap the Java Disassembler to displays the accessible functions

    and data in a compiled class; it also displays the meaning of bytecodes

    j avah to create interface between Java and C routines

    Data Flow Diagram

  • 8/9/2019 Project VIII

    41/42

  • 8/9/2019 Project VIII

    42/42

    REFERENCES

    Herbert Schildt , The Complete Referencs JAVA Seventh E dition

    Khalid A . M ughal , Rolf W . Rasmussen

    SU Ns JAVA tutorial

    Kathy Sierra & Bert Bates , Head First JAVA 2 ND E dition

    ka