Sun Java Solaris Communities My SDN Account Join SDN
 
Java Technology Fundamentals Newsletter Index

Generics for Beginners, the Numbers class, GUI Building, Using JDBC in Web Applications, and Adding Functionality to Buttons

 
In This Issue

Welcome to the Java Technology Fundamentals Newsletter

This monthly newsletter provides a way for you to learn the basics of the Java programming language, discover new resources, and keep up-to-date on the latest additions to Sun Developer Network's New to Java Center.

Note: For the code in this issue of Fundamentals to compile, you need to use the JDK 6 software.

Basic Java Technology Programming
Making Sense of the Java Classes & Tools
Desktop Java Platform Development
Server-Side Java Platform Development
What's New on the Sun Java Studio Creator IDE
Tutorials & Tips From NetBeans.org
Free Developer Tools
Java Technology: Self-Paced, Virtual, and Instructor-Led Courses
For More Information

 
Basic Java Technology Programming

Lesson: Generics (For Beginners)

Generics are a built-in language feature that will make your software more reliable. This lesson discusses the following topics:

Introduction

This section explains some common shortcomings associated with nongeneric code. Specifically, it shows how certain kinds of bugs will crash an application at runtime, since they are not detectable by the compiler.

Generic Types

This section explains generic type declarations, type variables, type parameters, and type arguments. It also describes the naming conventions that are specific to generics.

Generic Methods and Constructors

This section shows how type parameters can be used to define generic methods and constructors.

Bounded Type Parameters

This section describes how type parameters can specify an upper bound that limits the kind of types that can be passed in.

Subtyping

This section describes how generic subtyping differs from nongeneric subtyping.

Wildcards

This section continues the discussion of subtyping by describing bounded and unbounded wildcards.

Type Erasure

This section describes type erasure, raw types, and unchecked warnings.

Read the rest of this tutorial

Making Sense of the Java Classes & Tools

Numbers

This section begins with a discussion of the Number class in the java.lang package, its subclasses, and the situations in which you would use instantiations of these classes rather than the primitive number types.

This section also presents the PrintStream and DecimalFormat classes, which provide methods for writing formatted numerical output.

Finally, the Math class in java.lang is discussed. It contains mathematical functions to complement the operators built into the language. This class has methods for the trigonometric functions, exponential functions, and so forth.

Read the rest of this tutorial
 

Desktop Java Platform Development

GUI Building in NetBeans IDE 5.5

Last month, you read an introduction to the NetBeans IDE. This month, you get familiar with building a graphical user interface (GUI) in NetBeans IDE 5.5. A GUI is what the user will see and interact with. Behind the scenes is functionality code, which you'll learn to incorporate later.

The JDK 6 download comes with demo applications that future issues of this newsletter will discuss in greater detail. You'll have the sample code, run it, and learn about why it was coded the way it was. For now, see how easy it is to build user interfaces for desktop applications in the following article, GUI Building in NetBeans IDE 5.5.

This tutorial guides you through the process of creating the GUI for an application called ContactEditor using the NetBeans IDE GUI Builder, also known by the code name Matisse. In the process, you will lay out a GUI front end that enables you to view and edit contact information of individuals included in an employee database.

In this tutorial, you will learn how to do the following:

  • Use the GUI Builder interface
  • Create a GUI container
  • Add components
  • Resize components
  • Align components
  • Adjust component anchoring
  • Set component auto-resizing behavior
  • Edit component properties

This tutorial takes about 30 minutes to complete.

Read this tutorial
 

Server-Side Java Platform Development

NetBeans IDE 5.5 Tutorial for Web Applications

Each month, this section will highlight articles to get you familiar with the Java technologies involved in server-side development and the tools you can use to create various types of web applications.

Each month, this section will highlight articles to get you familiar with the Java technologies involved in server-side development and the tools you can use to create various types of web applications.

Last month, you learned about the Java technologies that go into building web applications. Now, you are going to learn about one of the free tools you can use to build web applications quickly and easily in the article below, Exploring Java Technology and the NetBeans IDE.

The Midnight Cookie Company application that you will build in this tutorial will show you how to do the following:

  • Create a web project from existing sources
  • Create a front controller servlet
  • Create methods to process requests and create cookies
  • Create the JSP page that receives the requests
  • Use JSTL to internationalize the application
  • Use the IDE's HTTP Monitor to analyze your deployed application

Below are explanations of some of the terms used in this tutorial.

  • Composite View. A design pattern that is used to present information in JSP pages. This design pattern creates an aggregate view from component views. Component views might include dynamic and modular portions of the page. The Composite View design pattern pertains to web application design when you are creating a view from numerous subviews. Complex web pages frequently consist of content derived from various resources. The layout of the page is managed independently of the content of its subviews. For instance, a view might have subviews such as Navigation, Search, Feature Story, and Headline.

    When creating a composite view, you can include static content and dynamic content. Static content might consist of an HTML file. Dynamic content is a fragment of a JSP page. The specific content can be determined at either JSP translation time or at runtime.

  • Front controllers. Components that are responsible for routing incoming requests and enforcing navigation in web applications. For more information on the use of the Front Controller design pattern, see the J2EE Patterns catalog.

  • JSP Pages. Files that are used in web applications to present information to end users and to enable data from end users to flow back to the server. JSP pages must be placed within a web application in order for the JSP pages to be executable within the IDE.

  • Servlets. Java classes that execute within a servlet container, which is typically running within a web server. Servlets are used to do the following:
    • Generate dynamic content.
    • Extend the capabilities of web servers and web-enabled application servers.
    • Interact with web clients (typically a browser application such as Netscape or Internet Explorer) using a request-response paradigm.

This application uses the JavaServer Pages Standard Tag Library (JSTL) to fetch dynamic data and to internationalize the JSP pages used in this application.

As you build the Midnight Cookie Company application, this tutorial will walk you through the whole web development cycle in the IDE.

This tutorial should take approximately two hours to complete.

Read this journal
 

What's New on the Sun Java Studio Creator IDE

Using JDBC in Web Applications Built With Sun Java Studio Creator 2

When you develop web applications that use databases, the Sun Java Studio Creator 2 (and Update 1) IDE uses JDBC code to handle the SQL statements that access, retrieve, and update data in the database. Because the IDE generates the JDBC code for you, you do not typically see it or work with it, and thus, you may think that there is something special about using JDBC code in a web application.

In truth, it could not be easier for you to use JDBC from within a web application that you develop with Sun Java Studio Creator IDE. If you decide to write your own JDBC code for an application, get your connection to the data source first, and then you are ready to go.

This tech tip covers the following topics:

  • Deciding to Write Your Own JDBC Code
  • Establishing a JDBC Connection
  • Setting Connection Properties
  • Cleaning up a Connection
  • Using JDBC Data Sources
    • Automatically Configuring a Data Source
    • Manually Configuring a Data Source
    • Synchronizing a CachedRowSet with Manual JDBC Changes
  • Example of JDBC Code

Read the tutorial
 

Tutorials and Tips on NetBeans.org

Adding Functionality to Buttons: A Beginner's Guide, Contributed by Saleem Gul and Tomas Pavek, maintained by Ruth Kusterer

This tutorial teaches you how to build a simple GUI with back-end functionality. This tutorial is geared to the beginner and introduces the basic construction of a GUI with functionality. A basic understanding of the Java programming language is required.

This is a basic tutorial that takes the approach of teaching programming from the GUI development perspective.

  • The Matisse package is used to facilitate the GUI development.
  • Matisse is available in the NetBeans IDE 5.0.
  • You will learn how to develop a GUI and then add functionality to the buttons used.

This document takes you through the fundamental concepts of GUI creation and takes the approach taken in many self-learning books. You will work through the layout and design of a GUI and add a few buttons and text boxes. The text boxes will be used for receiving user input and also for displaying the program output. The button will initiate the functionality built into the front end. The application we create will be a simple but functional calculator.

Read the tutorial and do the exercises
 

Free Developer Tools

Sun is offering the award-winning Sun Java Studio Enterprise and Sun Java Studio Creator IDEs at no cost to all developers worldwide who join the Sun Developer Network (SDN).

Get your free tools

Java Technology Courses

Self-Paced, Virtual, and Instructor-Led Courses

Enhance your developer skills with cutting-edge technologies. Sun's comprehensive offerings enable rapid development of applications and web services. Get trained and certified in the Java platform APIs, learn to use the power of Java technology to create web services.

See the Course catalog
 

For More Information

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.