Java

Using Program Parameters in Java Part-1

Fadıl

Introduction

Every programmer will encounter a situation where a choice must be made between various alternative solutions. Should tabular data be sorted in one way or another? What exactly is the graphical layout of your HTML pages? How often should you poll a queue? Most often you’ll know the path to take based on the requirements specifications, a design manual or some other kind of documentation, but now and then you’ll have to choose without help. Instead of just selecting one solution and hoping the customer will like it when he or she starts using your code, you could make it a “program parameter” or “option”.

Introduction to Java :Components Part-2

Fadıl

Lists

You will recall that in the SELECT widget in HTML programming, you could select how many choices were visible at any one time using the SIZE attribute. Well, since the Choice widget does not have such an attribute, you need to use a different component if you want that functionality. In the JDK, the List component is used for such circumstances.

import java.awt.*;

public class ListExample
  {
  public static void main(String[] args)
    {
    Frame baseFrame = new Frame();
    baseFrame.reshape(10,10,200,200);
    baseFrame.setTitle("List Example");
    List list = new List(3, true);
    list.addItem("Selena");
    list.addItem("Eric");
    list.addItem("Mark");
    list.addItem("Bob Frog");
    baseFrame.add(list);
    baseFrame.show();
    }
  }

Menus allow you to organize many related functions in your application in one centralized, easy-to-use interface object. Although Menus come in many forms, the most common menu types are “menu bars.”

Introduction to Java :Components Part-1

Fadıl

Static Text with Label

The Label class gives you the ability to draw a single line of text in your application. There is not much to it, consider the following example:

In all of the following examples, we will use the add() method to add components to a Frame object in order to show them on the monitor. Frame and add() will be discussed in the next section. So don’t worry about the specifics of baseFrame or add() for now. Instead, watch how the components are used within it!

Introduction to Java : Using the AWT To Build User Interfaces

Fadıl

Using the AWT To Build User Interfaces

Now we will make a big jump: we need to go from a simple application to a more serious one that will be representative of the kinds of applications you will build in real life. To do so, we will take advantage of the AWT class package that is distributed with the JDK.

As stated in the pre-requisite article “Web Programming 101,” one of the big benefits of using Java is the ability it gives you to create web-based graphical user interfaces (GUIs).

Introduction to Java : Constructing .Jar Files

Fadıl

Building a Jar File

After you have created your ZIP and CAB archives, you can then create a JAR (Java ARchive) file that will contain your compressed and archived Applet for use with users who have the most recent versions of Netscape Navigator and HotJava.

Building JAR files is very similar to building TAR files, something with which most UNIX developers are already familiar. Unfortunately, though, as with CABARC, there is only a command line interface, so you need to build your JAR files in the DOS shell using the JAR program provided with the JDK1.1.