Thursday, 31 May 2012

Using the JComboBox to make GUI programs

The given illustration is an example of ho we can make use of the the various swing tools in Netbeans to make any program out of our ease.The program I have made can be used for E learning.Its a small scale example of this thing.One can make out more tremendous programs for the same purpose.The program is also using Timer to generate an animation of the +R resonance effect which uses various pictures one after the other to seem as animation....

The database navigator using Connectivity

The following illustration is an example of a database navigator using the swing tools in Netbeans.It has made use of the connectivity with MySQL at the back end and a very interactive front end which has used hot keys or mnemonics to ease the accessibility.

Wednesday, 16 May 2012

Configuring Tomcat for developing php in Netbeans.


Top 10 NetBeans IDE Keyboard Shortcuts

Initially for exploration of the features working with mouse may feel fancy but as you continue using the tool for project development and want to concentrate more on task in hand you start finding ways to do things faster. NetBeans IDE 6.1 provides many keyboard shortcuts if used judiciously they can save a lot of developers time. I use certain shortcut keys more often than other keys. This is a list of the keyboard shortcuts for NetBeans IDE which I use in my day to day development tasks. 1. CTRL+F12 Navigate to Member When my class becomes big and there are many methods in the class navigating to a specific method becomes easy with this dialog box.
As soon as I start typing the name of the desired method the dialog contents are filtered for me to select from matching method names starting from what I have typed.
2. SHIFT+ESC Toggle Editor Maximize / Minimize I like working in the fully maximized editor window. SHIFT+ESC maximize the editor window for me and I can work with full concentration. When I need to see other windows I can again press SHIFT+ESC and I get the normal layout of windows back.
3. CTRL+7 Activate Navigator Window When I am in maximized editor mode and I need to navigate to some method, either I choose the method 1 as described above or sometimes I use CTRL+7 to activate the navigator window. The windows other than editor in NetBeans follow a specific pattern, you can type characters and a quick search window appears which selects the most appropriate item from the window according to what is typed in this quick search window.
4. CTRL+/ Toggle Comment For quick commenting of some lines I select those lines and press CTRL+/ to comment all those selected lines. The same lines can be uncommented again by following the same process. 5. ALT+SHIFT+F Format Code This key combination formats my code to the standard Java Code Formatting template. 6. CTRL+0 Activate the Editor When I am in the Navigator window through the shortcut CTRL+7 and I want to navigate back to the editor i press CTRL+0. I do not need mouse to do this navigation and save a lot of time in navigating between windows. 7. CTRL+# Activate different windows These shortcuts are handy for navigating between the different windows. They become very important when I work in maximized editor mode. CTRL+1 - Project Window CTRL+2 - Files Window CTRL+3 - Favorite Window CTRL+4 - Output Window CTRL+5 - Services window CTRL+6 - Tasks Window 8. ALT+INSERT Generate Code When I need to generate getter setters or constructors this key combination brings the Code Generation menu
9. ALT+F7 Find Usages Many a times I want to track all the occurrences of a particular method call. Who is calling my method. This Find Usages dialog comes handy in such times.
10. CTRL+F4 Close Editor Window and CTRL+SHIFT+F4 Close All Editor Windows I use these keys often to close my editor windows and save many mouse clicks.

Android Application Development in Netbeans

Develop Anroid Applications using Netbeans!!
Practice the tutorial now!!

Netbeans Mobile Development Module for Blackberry

A part of the problem of mobile development is that there are so many platforms. Do you want to develop for BlackBerry, Android, Apple products like iPhone or iPad, or Windows Mobile? Pinpointing the best plugin for Java mobile apps depends on your platform, but as you can imagine, there are really only a few good options. One, for Android, I personally do not recommend. Another is for BlackBerry

Thursday, 10 May 2012

Tutorial for VFSJFileChooser


VFSJFileChooser is a Java Swing Component which allows you to browse both remote(FTP, SFTP, WEBDAV, etc.) and local filesystems. It is based on Apache Commons VFS library. VFSJFileChooser is distributed under Apache License 2.0.
VFSJFileChooser was first started to be a plugin of XPontus XML Editor. Later, it was decided to create a library which wouldn't be tied to XPontus API.
VFSJFileChooser supports all the file systems available in Commons VFS.
You can think of VFSJFileChooser as a javax.swing.JFileChooser with the ability to browse remote locations such as FTP, SFTP, etc. VFSJFileChooser has not been designed as a file transfer tool, however it can be easily implemented (2 VFSJFileChooser components and some buttons calling commons-vfs API methods, a queue for file operations, etc.).


C-JDBC is a free open source database cluster middleware that allows any Java application (standalone application, servlet or EJB container, ...) to transparently access a cluster of databases through JDBC(tm). The database is distributed and replicated among several nodes and C-JDBC balances the queries among these nodes. C-JDBC handles node failures and provides support for checkpointing and hot recovery.


Sunday, 6 May 2012

Web Srevices in Java Netbeans


Web services are distributed application components that are externally available. You can use them to integrate computer applications that are written in different languages and run on different platforms. Web services are language and platform independent because vendors have agreed on common web service standards.
Web service applications are deployed to a Java EE application server, such as GlassFish / Sun Java System Application Server.
This page provides links to some of the NetBeans documents and resources that can help you learn how to develop web service applications with NetBeans IDE.

Saturday, 5 May 2012

Netbeans Database Connectivity with MySQL.


Molecular Biology Research on NetBeans

I am a Canadian government research scientist working on the molecular biology of somatic embryogenesis in conifers. During my early work on gene expression analysis, I developed the ability to conduct quantitative real time polymerase chain reaction (qPCR) using sigmoidal mathematics, which led to the derivation of two novel functions that evolved into a data processing method I called "Linear regression of efficiency" (LRE). Unfortunately, LRE analysis proved to be too labour intensive when conducted manually using Excel, which was the platform upon which LRE analysis was developed. It was also apparent that without an automated capability, acceptance of LRE as an alternative to current qPCR methods would most certainly be limited, at least in the short term, but this is another story.
After several failed attempts over about 18 months to establish a partner for programming LRE analysis, it occurred to me that it might be possible to do the coding myself, based on the extensive online resources for learning Java, and of course, the availability of the NetBeans IDE. This lead to development of a small Java program, which was released as a supplement to my first publication introducing LRE.
After some failed attempts to develop a full fledged desktop program based purely on Java Swing, it became obvious that the NetBeans Platform could provide the required infrastructure, despite the intimidating prospect of learning how to use it, particularly in view of my limited expertise. Due in part to the resources that have been provided, I was sufficiently successful to produce LRE Analyzer, an open source program that we now routinely use for all of our qPCR work:

As might be expected, many aspects of the program are crudely implemented, but in view of the technical complexity involved, it is a testament to the power of the NetBeans Platform to provide capabilities that allow even a novice to be (reasonably) successful.
Anyway, all of this would not have been possible without these online resources, and I am are thus very grateful for the efforts of the NetBeans team, along with Sun's decision to provide free access to both Java and NetBeans, and of course, to Oracle's decision to continue support for these resources.

Key to the Java EE 6 Platform: NetBeans IDE 7.1

This article provides a tour of the main Java EE 6 specifications and shows how the the NetBeans IDE provides the tools, templates, and code generators to support Java EE 6.

Published March 2012
Download: NetBeans IDE (Java EE distribution)


When you begin to grasp the breadth and ambition of the Java EE 6 Platform, which covers  everything from the model (JPA and Bean Validation), to the controller (EJB and Servlets), to the view (JavaServer Faces), a simple entry point is difficult to find.
Enter NetBeans IDE 7.1, which is Oracle’s IDE for the Java Platform, created by the same group of developers who created the Java EE 6 Platform. Here you find tools, templates, and code generators intended to be used in combination with the set of specifications that the Java EE 6 Platform encompasses.
Let’s take a tour through the main Java EE 6 specifications and see how NetBeans supports them, through a set of short explanatory texts and screenshots.

JPA 2.0 and Bean Validation 1.0

The Java Persistence specification defines how relational data is mapped to Java objects, standardizing Object/Relational mapping. In the IDE, a wizard is provided that connects to a registered database (which can also be viewed and changed in a database exploration tool in the IDE), lets you select tables, and then generates Java objects from them.
Each generated Java object is annotated as an entity following JPA 2.0 standards, a persistence.xml file defining the database connection is created, and named queries (such as "Customer.findAll", which maps to an SQL query) are optionally inserted into the Java objects.

As a result, your database is accessible from cleanly generated Java POJOs in a matter of seconds. Either you can now inspect the generated entities and extend them for your own applications (for example, code completion is available to help you get started with the new Criteria API) or you can use the generated entities as a learning device while you become comfortable with the JPA specification.
More generally, to integrate persistence solutions into your application, the IDE offers a number of different code generating mechanisms:

The Bean Validation specification is very closely related to the JPA specification. It defines an API for JavaBean validation based on annotations, such as @NotNull and @Size. Aside from the annotations generated into the entities via the above-mentioned tools, the Bean Validation API is supported via additional wizards that let you generate constraint classes, together with their related configuration files:

EJB 3.1

Earlier releases of the Enterprise JavaBeans specification were complicated and verbose. In contrast, EJB 3.1 is remarkably lightweight, requiring very little coding. Now, EJBs simply help you create a thin and powerful business layer. Think "C" in "MVC" and you've got the idea. In the IDE, when you build them, EJBs are included in the application's WAR file, instead of being archived in separate EAR files, which is one of the great enhancements in EJB 3.1.

Templates are provided by the IDE for creating new beans of various kinds: session bean, timer session bean, message-driven bean, as well as session beans generated from entity classes.

Using the IDE, you quickly see that EJBs are no longer defined by the interfaces they implement. Instead, a session bean is a simple POJO with annotations such as @Stateless and @LocalBean. When Alt-Insert is pressed inside the Java Editor, code snippets can be created, such as code for injecting the persistence.xml file via the @PersistenceContext annotation and referring to it via the JPA EntityManager class.

Further help is provided via code generators, including a wizard for creating new business methods in an EJB, invoked from "Add Business Method" above.
Finally, for each EJB in your application, a new node is added to the application structure in the Projects window, so that you can easily see the artifacts made available by the application.

Especially when the application becomes larger, and manageability concerns become more prominent, such global views into the project structure become more important.

JSF 2.0

Instead of using JSPs, you can now use XHTML files, defined by Facelets, which are now part of the JavaServer Faces (JSF) specification. One benefit is that you can now use CSS to style your view layer. Another advantage is that Facelets supports templating. In the IDE, you can use a wizard to create a Facelets Template file, after which you can use another wizard to create a client of the generated template file.

When working within these files, tools exist in the IDE for extracting a set of tags into a JSF Composite Component, which is a separate XHTML file that can be reused across multiple Facelets files.

In this way, component-based development is supported by JSF 2.0, supported by the IDE. A separate wizard is also provided in the IDE for creating new JSF composite components.
Moreover, JSF pages can be generated from entity classes. When the "JSF Pages from Entity Classes" wizard is selected, you can choose one or more entity classes, and then the IDE will generate four XHTML files for each selected class. Within the generated files, JSF tags are added, enabling common CRUD operations to be performed on the underlying entity classes.

Servlets 3.0

By default, following the Java Servlets 3.0 specification, the IDE does not register a newly created servlet into the application's web.xml file. Instead, the @WebServlet annotation is added to the top of the Servlet class, with the "urlPatterns" attribute defining the URL pattern. That means you don't need to switch between the web.xml editor and the Java Editor. Modifying the URL pattern can be done very easily by changing the annotation on the class. Should a web.xml still be needed, a template exists for creating one.
Within the servlet, press Alt-Insert and then you can, as always, generate code. However, there are some powerful new additions in this code generator. Notably, a wizard can be started for selecting session beans:

Code for injecting the selected session beans is inserted into the file, providing a new @EJB annotation in the place where the above code generator was invoked.

CDI 1.0

The new Context and Dependency Injection specification lets you bind the lifecycle and interactions of stateful components to well-defined but extensible lifecycle contexts. In addition, it lets you inject components into an application in a typesafe way, including the ability to choose at deployment time which implementation of a particular interface to inject.
Since an application that uses CDI must have a file named beans.xml, the IDE provides templates for creating this file. If the file does not exist and you annotate EJBs with @Named, for example, which exposes it for injection via expression language into JSF files, the IDE automatically creates a beans.xml file in the META-INF folder for you. In a JSF Facelets file, when you use expression language to refer to your named EJB, the IDE offers code completion for the class names, as well as the methods within the class. In this way, you can very easily connect your view layer (provided by JSF Facelets files) with your business layer (provided by EJBs).
Furthermore, wizards are provided by the IDE for generating new qualifiers, stereotypes, interceptor binding types, and scope types.

These files conform to the deeper aspects of the CDI specification, helping you to get started with them quickly and avoid discouraging errors early in your learning process.

JAX-RS 1.1

The Java API for RESTful Web Services 1.1 lets you quickly build lightweight web services that conform to the Representational State Transfer (REST) style of software architecture. JAX-RS is a standardized API for building RESTful web services in Java. In REST, you deal with resources, each of which can be referred to with a global identifier, that is, a URI.
These can be created very easily in the IDE. In a session bean, add an @Path annotation, which denotes in JAX-RS 1.1 that the artifact should be exposed as a RESTful resource, and the IDE will immediately pop up a dialog that lets you configure the REST libraries and related resources.

Also, a library of wizards is provided for generating RESTful web services from a number of different sources: entity classes, patterns, and databases.

Once the RESTful web services have been created, another wizard can be used for generating the client that consumes the web service's payload.
Moreover, for SOAP-based web services, additional wizards are available for very specific use cases, such as for generating secure token services, logical handlers, and message handlers.


While code generators and tools such as those described here are great to help you get your feet wet, a danger is that a lot of code is generated that you don't understand and that you therefore do not know how to debug and maintain. The good news is that far less code needs to be generated in Java EE 6 than before, making it far easier to understand and maintain.
Nevertheless, it is advisable to use tools of this kind intelligently. Start small, focusing on specific APIs. Get to know them via the generated code and then slowly extend the application as you become more familiar with the Java EE 6 Platform. Once you are comfortable with the spec, the tools aim to help you become more productive: combining the leanness of the Java EE 6 Platform with the tools in the IDE, you'll be rapidly creating the core of your application.

Hierarchical Web Service Development with NetBeans IDE

The Client also has a Servlet which can be accessed by browser clients. These browser clients use the Web services of the client to access the Web Services of the Server and thus multiple client customers can transact in the online retail store concurrently. There can be multiple instances of the Web Client, each of which can serve multiple customers concurrently, all accessing the same Retail Application Server.

We refer to this as 1st Level Client Web Services.

This model can easily be extended in a similar fashion to another level of clients, 2nd Level Clients, who publish their services based on the 1st level client web services. Both these scenarios are depicted in the diagrams below.

    Fig 1. Ist Level Client with Web Services based on Web Services of Retail Application Server

    Fig 2. 2nd Level Client with Web Services based on Web Services of 1st Level Client

This solution is hierarchical and flexible and scalable. At the same time, it preserves consistency in concurrent client access of a retail database at the Retail Application server.

Download link for Netbeans 7.1

A program illustrating the use of Random Function

NetBeans IDE Java Quick Start Tutorial



Setting Up the Project

To create an IDE project:
  1. Start NetBeans IDE.
  2. In the IDE, choose File > New Project (Ctrl-Shift-N), as shown in the figure below.
    NetBeans IDE with the File > New Project menu item selected.
  3. In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Then click Next.
    NetBeans IDE, New Project wizard, Choose Project page.
  4. In the Name and Location page of the wizard, do the following (as shown in the figure below):
    • In the Project Name field, type HelloWorldApp.
    • Leave the Use Dedicated Folder for Storing Libraries checkbox unselected.
    • In the Create Main Class field, type helloworldapp.HelloWorldApp.
    • Leave the Set as Main Project checkbox selected.
    NetBeans IDE, New Project wizard, Name and Location page.
  5. Click Finish.
The project is created and opened in the IDE. You should see the following components:
  • The Projects window, which contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.
  • The Source Editor window with a file called HelloWorldApp open.
  • The Navigator window, which you can use to quickly navigate between elements within the selected class.
  • The Tasks window, which lists compilation errors as well other tasks that are marked with keywords such as XXX and TODO.
NetBeans IDE with the HelloWorldApp project open.

Adding Code to the Generated Source File

Because you have left the Create Main Class checkbox selected in the New Project wizard, the IDE has created a skeleton main class for you. You can add the "Hello World!" message to the skeleton code by replacing the line:
            // TODO code application logic here
with the line:
            System.out.println("Hello World!");
Save the change by choosing File > Save.
The file should look something like the following code sample.
 * To change this template, choose Tools | Templates
 * and open the template in the editor.

package helloworldapp;

 * @author <your name>
public class HelloWorldApp {

     * @param args the command line arguments
    public static void main(String[] args) {
            System.out.println("Hello World!");



Compiling and Running the Program

Because of the IDE's Compile on Save feature, you do not have to manually compile your project in order to run it in the IDE. When you save a Java source file, the IDE automatically compiles it.
The Compile on Save feature can be turned off in the Project Properties window. Right-click your project, select Properties. In the Properties window, choose the Compiling tab. The Compile on Save checkbox is right at the top. Note that in the Project Properties window you can configure numerous settings for your project: project libraries, packaging, building, running, etc.
To run the program:
  • Choose Run > Run Main Project (F6).
The next figure shows what you should now see.
The program prints Hello World! to the Output window (along with other output from the build script).
Congratulations! Your program works!
If there are compilation errors, they are marked with red glyphs in the left and right margins of the Source Editor. The glyphs in the left margin indicate errors for the corresponding lines. The glyphs in the right margin show all of the areas of the file that have errors, including errors in lines that are not visible. You can mouse over an error mark to get a description of the error. You can click a glyph in the right margin to jump to the line with the error.

Building and Deploying the Application

Once you have written and test run your application, you can use the Clean and Build command to build your application for deployment. When you use the Clean and Build command, the IDE runs a build script that performs the following tasks:
  • Deletes any previously compiled files and other build outputs.
  • Recompiles the application and builds a JAR file containing the compiled files.
To build your application:
  • Choose Run > Clean and Build Main Project (Shift-F11)
You can view the build outputs by opening the Files window and expanding the HelloWorldApp node. The compiled bytecode file HelloWorldApp.class is within the build/classes/helloworldapp subnode. A deployable JAR file that contains the HelloWorldApp.class is within the dist node.
Image showing the Files window with the nodes for the HelloWorldApp expanded to show the contents of the build and dist subnodes.

Follow Me on Facebook...
This is a simple login form created by using the Swing Controls ..

Visit The Java Netbeans Project on "Vienna Chemicals"