Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

R.C.P.I.T.

,Shirpur

CHAPTER 7 CODING

7.1 Java development kit


The Java Development Kit (JDK) is a Sun Microsystems product aimed at Java developers. Since the introduction of Java, it has been by far the most widely used Java SDK. On 17 November 2006, Sun announced that it would be released under the GNU General Public License (GPL), thus making it free software. ThiS happened in large part on 8 May 2007[3] ; Sun contributed the source code to the OpenJDK. JDK contents The JDK has as its primary components a collection of programming tools, including: java the loader for Java applications. This tool is an interpreter and can interpret the class files generated by the javac compiler. Now a single launcher is used for both development and deployment. The old deployment launcher, jre, no longer comes with Sun JDK. javac the compiler, which converts source code into Java bytecode appletviewer this tool can be used to run and debug Java applets without a web browser apt the annotation-processing tool [4] extcheck a utility which can detect JAR-file conflicts idlj the IDL-to-Java compiler. This utility generates Java bindings from a given Java IDL file. javadoc the documentation generator, which automatically generates documentation from source code comments

Optical Mark Recognition

26

R.C.P.I.T.,Shirpur

jar the archiver, which packages related class libraries into a single JAR file. This tool also helps manage JAR files. javah the C header and stub generator, used to write native methods javap the class file disassembler javaws the Java Web Start launcher for JNLP applications jconsole Java Monitoring and Management Console Java Development Kit 2 jdb the debugger jhat Java Heap Analysis Tool (experimental) jinfo This utility gets configuration information from a running Java process or crash dump. (experimental) jmap This utility outputs the memory map for Java and can print shared object memory maps or heap memory details of a given process or core dump. (experimental) jps Java Virtual Machine Process Status Tool lists the instrumented HotSpot Java Virtual Machines (JVMs) on Experimental tools may not be available in future versions of the JDK.The JDK also comes with a complete Java Runtime Environment, usually called a private runtime. It consists of aJava Virtual Machine and all of the class libraries present in the production environment, as well as additional libraries only useful to developers, such as the internationalization libraries and the IDL libraries. Copies of the JDK also include a wide selection of example programs demonstrating the use of almost all portions ofthe Java API.

7.2 NetBeans Introduction:


NetBeans refers to both a platform framework for Java desktop applications, and an integrated development environment (IDE) for developing with Java,
Optical Mark Recognition 27

R.C.P.I.T.,Shirpur

JavaScript, PHP, Python, Ruby, Groovy, C, C++, Scala, Clojure, and others. The NetBeans IDE is written in Java and can run anywhere a JVM is installed, including Windows, Mac OS, Linux, and Solaris. A JDK is required for Java development functionality, but is not required for development in other programming languages. The NetBeans platform allows applications to be developed from a set of modular software components called modules. Applications based on the NetBeans platform (including the NetBeans IDE) can be extended by third party developers.[3]

7.2.1 NetBeans Platform


The NetBeans Platform is a reusable framework for simplifying the development of Java Swing desktop applications. The NetBeans IDE bundle for Java SE contains what is needed to start developing NetBeans plugins and NetBeans Platform based applications; no additional SDK is required. Applications can install modules dynamically. Any application can include the Update Center module to allow users of the application to download digitally-signed upgrades and new features directly into the running application. Reinstalling an upgrade or a new release does not force users to download the entire application again. The platform offers reusable services common to desktop applications, allowing developers to focus on the logic specific to their application. Among the features of the platform are: User interface management (e.g. menus and toolbars) User settings management Storage management (saving and loading any kind of data) Window management Wizard framework (supports step-by-step dialogs) NetBeans Visual Library Integrated Development Tools
Optical Mark Recognition 28

R.C.P.I.T.,Shirpur

7.2.2NetBeans IDE
The NetBeans IDE is an open-source integrated development environment. NetBeans IDE supports development of all Java application types (Java SE including JavaFX, (Java ME, web, EJB and mobile applications) out of the box. Among other features are an Ant-based project system, Maven support, refactorings, version control (supporting CVS, Subversion, Mercurial and Clearcase). Modularity: All the functions of the IDE are provided by modules. Each module provides a well defined function, such as support for the Java language, editing, or support for the CVS versioning system, and SVN. NetBeans contains all the modules needed for Java development in a single download, allowing the user to start working immediately. Modules also allow NetBeans to be extended. New features, such as support for other programming languages, can be added by installing additional modules. For instance, Sun Studio, Sun Java Studio Enterprise, and Sun Java Studio Creator from Sun Microsystems are all based on the NetBeans IDE. License: From July 2006 through 2007, NetBeans IDE was licensed under Sun's Common Development and Distribution License (CDDL), a license based on the Mozilla Public License (MPL). In October 2007, Sun announced that NetBeans would henceforth be offered under a dual license of the CDDL and the GPL version 2 licenses, with the GPL linking exception for GNU Classpath[8]

7.3 Package omr Pack


7.3.1 Class Summary
About AnswerSheetGenerator ChangePassword Help
Optical Mark Recognition 29

R.C.P.I.T.,Shirpur

Login MainMenu MessageBox MyFile PrintUtilities ProcessSheets ScanSheets ViewResults

WebcamTest

7.3.2 Class Details


Answer sheet generator Constructor Detail AnswerSheetGenerator public AnswerSheetGenerator(MainMenu parent) Creates new form MainMenu Method Detail setParameters public void setParameters() setParameters2 public void setParameters2() autoSave public void autoSave() Scan Sheets : Field Detail thumbImage2
Optical Mark Recognition 30

R.C.P.I.T.,Shirpur

public java.awt.image.BufferedImage thumbImage2 graphics2D2 public java.awt.Graphics2D graphics2D2 running public boolean running m public JMyron.JMyron m cw public int cw ch public int ch ww public int ww hh public int hh frameRate public int frameRate jLabelFeed public javax.swing.JLabel jLabelFeed ScanSheets public ScanSheets(MainMenu parent Method Detail updateImage public void updateImage() Process sheet Field Detail runningScan
Optical Mark Recognition 31

R.C.P.I.T.,Shirpur

public boolean runningScan processSingle public boolean processSingle processWhat public java.lang.String processWhat currTh public int currTh jCheckNegative public javax.swing.JCheckBox jCheckNegative jComboBucket public javax.swing.JComboBox jComboBucket jComboCorrect public javax.swing.JComboBox jComboCorrect jComboIncorrect public javax.swing.JComboBox jComboIncorrect jLabelCurrent public javax.swing.JLabel jLabelCurrent jProgressBar public javax.swing.JProgressBar jProgressBar jTextID public javax.swing.JTextField jTextID ProcessSheets public ProcessSheets(MainMenu parent) Creates new form MainMenu Method Detail addText
Optical Mark Recognition 32

R.C.P.I.T.,Shirpur

public void addText(java.lang.String str) setText public void setText(java.lang.String str) View Result Constructor Detail public ViewResults(MainMenu parent) Creates new form MainMenu Method Detail loadResult public void loadResult() addText public void addText(java.lang.String str) setText public void setText(java.lang.String str) 7.4

Java Swing Package


What Is Swing? If you poke around the Java , you'll find Swing described as a set of

customizable graphical components whose look-and-feel (L&F) can be dictated at runtime. In reality, however, Swing is much more than this. Swing is the nextgeneration GUI toolkit that Sun Microsystems created to enable enterprise development in Java. By enterprise development, we mean that programmers can use Swing to create large-scale Java applications with a wide array of powerful components. In addition, you can easily extend or modify these components to control their appearance and behavior.
Optical Mark Recognition 33

R.C.P.I.T.,Shirpur

Swing is not an acronym. The name represents the collaborative choice of its designers when the project was kicked off in late 1996. Swing is actually part of a larger family of Java products known as the Java Foundation Classes ( JFC), which incorporate many of the features of Netscape's Internet Foundation Classes (IFC) as well as design aspects from IBM's Taligent division and Lighthouse Design. Swing has been in active development since the beta period of the Java Development Kit ( JDK) 1.1, circa spring of 1997. The Swing APIs entered beta in the latter half of 1997 and were initially released in March 1998. When released, the Swing 1.0 libraries contained nearly 250 classes and 80 interfaces. Growth has continued since then: at press time, Swing 1.4 contains 85 public interfaces and 451 public classes. Although Swing was developed separately from the core Java Development Kit, it does require at least JDK 1.1.5 to run. Swing builds on the event model introduced in the 1.1 series of JDKs; you cannot use the Swing libraries with the older JDK 1.0.2. In addition, you must have a Java 1.1-enabled browser to support Swing applets. The Java 2 SDK 1.4 release includes many updated Swing classes and a few new features. Swing is fully integrated into both the developer's kit and the runtime environment of all Java 2 releases (SDK 1.2 and higher), including the Java Plug-In. AWT The Abstract Window Toolkit is the basic GUI toolkit shipped with all versions of the Java Development Kit. While Swing does not reuse any of the older AWT components, it does build on the lightweight component facilities introduced in Accessibility The accessibility package provides assistance to users who have trouble with traditional user interfaces. Accessibility tools can be used in conjunction with devices
Optical Mark Recognition 34

R.C.P.I.T.,Shirpur

such as audible text readers or braille keyboards to allow direct access to the Swing components. Accessibility is split into two parts: the Accessibility API, which is shipped with the Swing distribution, and the Accessibility Utilities API, which is distributed separately. All Swing components support accessibility, so this book dedicates an entire chapter to accessibility design and use. 2D API The 2D API contains classes for implementing various painting styles, complex shapes, fonts, and colors. This Java package is loosely based on APIs that were licensed from IBM's Taligent division. The 2D API classes are not part of Swing, so they are not covered in this book. Drag and Drop Drag and Drop (DnD) is one of the more common metaphors used in graphical interfaces today. The user is allowed to click and "hold" a GUI object, moving it to another window or frame in the desktop with predictable results. The DnD API allows users to implement droppable elements that transfer information between Java applications and native applications. Although DnD is not part of Swing, it is crucial to a commercial-quality application.

7.4.1

Swing Packages and Classes

Here is a short description of each package in the Swing libraries: javax.accessibility Contains classes and interfaces that can be used to allow assistive technologies to interact with Swing components. Assistive technologies cover a broad range of items, from audible text readers to screen magnification. Although the accessibility classes are technically not part of Swing, they are used extensively throughout the Swing components..
Optical Mark Recognition 35

R.C.P.I.T.,Shirpur

javax.swing Contains the core Swing components, including most of the model interfaces and support classes. javax.swing.border Contains the definitions for the abstract border class as well as eight predefined borders. Borders are not components; instead, they are special graphical elements that Swing treats as properties and places around components in place of their insets. If you wish to create your own border, you can subclass one of the existing borders in this package, or you can code a new one from scratch. javax.swing.colorchooser Contains support for the JColorChooser component. javax.swing.event Defines several new listeners and events that Swing components use to communicate asynchronous information between classes. To create your own events, you can subclass various events in this package or write your own event class. javax.swing.filechooser Contains support for the JFileChooser component. javax.swing.plaf Defines the unique elements that make up the pluggable L&F for each Swing component. Its various subpackages are devoted to rendering the individual L&Fs for
Optical Mark Recognition 36

R.C.P.I.T.,Shirpur

each component on a platform-by-platform basis. (Concrete implementations of the Windows and Motif L&Fs are in subpackages of com.sun.java.swing.plaf, and the Mac OS L&F is under com.apple.mrj.swing.) javax.swing.table Provides models and views for the table component, which allows you to arrange various information in a grid format with an appearance similar to a spreadsheet. Using the lower-level classes, you can manipulate how tables are viewed and selected, as well as how they display their information in each cell. javax.swing.text Provides scores of text-based classes and interfaces supporting a common design known as document/view. The text classes are among the more advanced Swing classes to learn. javax.swing.text.html Used specifically for reading and formatting HTML text through an ancillary editor kit. javax.swing.text.html.parser Contains support for parsing HTML. javax.swing.text.rtf Used specifically for reading and formatting Rich Text Format (RTF) text through an ancillary editor kit.

Optical Mark Recognition

37

R.C.P.I.T.,Shirpur

javax.swing.tree Defines models and views for a hierarchal tree component, which may represent a file structure or a series of properties. javax.swing.undo Contains the necessary functionality for implementing undoable functions. By far the most widely used package is javax.swing. In fact, almost all the Swing components, as well as several utility classes, are located inside this package. The only exceptions are borders and support classes for the trees, tables, and text-based components. Because the latter components are much more extensible and often have many more classes to work with, these classes have been divided into separate packages.

7.5 AWT Package


7.5.1 Abstract Window Toolkit
Windows form with some AWT examples The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and userinterface widget toolkit. The AWT is now part of the Java Foundation Classes (JFC) the standard API for providing a graphical user interface (GUI) for a Java program. AWT is also the GUI toolkit for a number of Java ME profiles. For example, Connected Device Configuration profiles require Java runtimes on mobile telephones to support AWT.

7.5.2 Architecture
The AWT provides two levels of APIs:
Optical Mark Recognition 38

R.C.P.I.T.,Shirpur

A general interface between Java and the native system, used for windowing, events, and layout managers. This API is at the core of Java GUI programming and is also used by Swing and Java 2D. It contains: The interface between the native windowing system and the Java application; The core of the GUI event subsystem; Several layout managers; The interface to input devices such as mouse and keyboard; and A java.awt.datatransfer package for use with the Clipboard and Drag and Drop. A basic set of GUI widgets such as buttons, text boxes, and menus. It also provides the AWT Native Interface, which enables rendering libraries compiled to native code to draw directly to an AWT Canvas object drawing surface.

7.5.3 Abstract Window Toolkit 2


AWT also makes some higher level functionality available to applications, such as: Access to the system tray on supporting systems; and The ability to launch some desktop applications such as web browsers and email clients from a Java application. Neither AWT nor Swing are inherently thread safe. Therefore, code that updates the GUI or processes events should execute on the Event dispatching thread. Failure to do so may result in a deadlock or race condition. To address this problem, a utility class called SwingWorker allows applications to perform time-consuming tasks following user-interaction events in the event dispatching thread.

Optical Mark Recognition

39

You might also like