Java GUI’s Using the Swing API 4

GUI Construction:- A Java technology GUI can be created using either of the following technique: Programming construction This technique uses code to create the GUI. This technique is useful for learning GUI construction. However, it is very laborious for use in production environments. Construction using a GUI builder tool This technique uses a GUI builder tool to create the GUI. The GUI developer uses a visual approach to drag and drop containers and components to a work area. The tool permits the positioning and resizing of containers and components using a pointer device…Read more

Java GUI’s Using the Swing API 3

Layout Manager:- A layout manager does determine the size and position of the components within a container. The alternative to using layout managers is absolute positioning by pixel coordinates. Absolute positioning is achieved through setting a containers layout property to null. Absolute positioning is not platform portable. Issues such as a size of fonts and screens ensure that a layout that is correct based on coordinates can potentially be unusable on other platforms. Unlike absolute positioning, layout managers have mechanisms to cope with the following situations: The resizing of the GUI by the…Read more

Java GUI’s Using the Swing API 2

Swing Packages:- The Swing API has a rich and convenient set of packages that makes it powerful and flexible. The given below lists each package name and the purpose of each package. 1.     javax.swing:- Provides a set of light weight components such as, JFrame, JButton, JCheckBox and much more. 2.     javax.swing.border:- Provides classes and interfaces for drawing specialized border such as line, etched, bevel, matte and more. 3.     javax.swing .event:- Provides support for events fired by Swing components. 4.     javax.swing.undo:- Allows developers to provide support for undo/redo in applications such as text editor.…Read more

Java GUI’s Using the Swing API 1

What are the Java Foundation Classes (JFC)? JFC, or Java Foundation Classes, is a set of Graphical User Interface (GUI) support packages that are available as part of the java SE platform and which became core application program interfaces (APIs) in JDK 1.2. As a result of this, some of the boundaries between JFC and core JDK have become blurred, but in this, JFC includes the following features: The Swing component set: - The Swing is an enhanced component set that provides replacement components for those in the original AWT and a number…Read more

Console I/O in Java 2

Files and File I/O:- The Java technology includes a rich set of I/O streams which are described in the previous section. In this it examines several simple technologies for reading and writing to files with a focus on the character data, including: Creating File Objects Manipulating File Objects Reading and Writing to file streams Creating a New File Object:- The File class provides several utilities for handling files and obtaining information about them. In java technology, a directory is just another file. We can create a File object that represents a directory and…Read more

Readers-Writers & Dinning philosophers Problem

The Readers-Writers Problem Suppose that a database is to be shared among several concurrently running processes. Some of these processes may want to only read the database, whereas others may want to update (that is, to read and write) the database. We distinguish between these two types of processes by referring to the former as readers and to the latter as writers. Obviously, if two readers access the shared data simultaneously no adverse effects on the result. If a writer and some other process (either a reader or a writer) access the database…Read more

Console I/O in Java

Console I/O:- Most application must interact with the user. Such interaction is sometimes accomplished with text input and output to the console (using the keyboard as the standard input and using the terminal window as the standard output). Java JDK supports console I/O with three public static variables on the java.lang.System class: The variable System.out is a PrintStream object that refers (initially) to the terminal window that launched the Java technology application. The variable is an InputStream object that refers (initially) to the user’s keyboard. The variable System.err is a PrintStream object…Read more

Ordering Collections in JAVA 2

Last time we have discussed the Comparable interface and now we are going to see how the Comparator interface works. Comparator interface:- The Comparator interface provides greater flexibility with ordering. For example, if you consider the Student class described previously, the sorting of Students was restricted to sorting on GPA’s. It was not possible to sort the student based on first name or some other criteria. So now we are going to see how sorting flexibility can be enhanced using the Comparator interface. The Comparator interface is a java.util package member. It is…Read more

Ordering Collections in JAVA : Part 1

Ordering Collections:- • The comparable interface and comparator interface are the interfaces which are used for the Ordering Collection. • The Comparable interface imparts natural ordering to the classes which implement it. • The Comparator interface is used to specify the order relation. It can also be used to override the natural ordering. • Both the interfaces, Comparable interface and Comparator interface are useful to sorting elements in a collection. The Comparable interface:- • The Comparable interface is a member of a java.lang package. • A class which implements a Comparable interface having…Read more

Input-Output Fundamentals in JAVA 5

Serialization:- Saving the object to some type of permanent storage is called as persistence. An object is said to be persistent capable when you can store that object on a disk or a tape or send it to another machine to be stored in memory or on disk. The non persisted object exists only as long as the Java Virtual Machine is running. The Serialization is a mechanism for saving the objects as a sequence of bytes and later, when needed, rebuilding the byte sequence back into a copy of the object. For…Read more