Category: Java Programming

AWT Event Classes
Java Programming

AWT Event Classes

The Event classes represent the events that are generated when an end user interacts with the AWT components. the EventObject class is the superclass for handling all events. the class exists in the package, java. util. The AWTEvent class is the subclass of the EventObject class and all AWT events originate from the AWTEvent class. […]

Rekha Setia 
Changing Font and Color in Java Applet
Java Programming

Changing Font and Color in Java Applet

To display text(write the text), you must first select a font. A font is specified by its names, such as “Arial”,  the style(plain, bold, italic, or bold italics), and the point size. A font is an object in Java, so we need to create it via a call to new before we can use it. […]

Rekha Setia 
Daemon Thread in Java
Java Programming

Daemon Thread in Java

Daemon Thread There are two types of threads The threads created by the user(create a thread in the program ) are called user threads. The threads that work in the background providing service to others are called Daemon Threads. The two methods used only  in the daemon thread, not in the user thread are: Example […]

Rekha Setia 
Finally, Block in Java
Java Programming

Finally, Block in Java

Finally blocks(finally{}) are executed once the try block(try{}) exits. This block executes even after unexpected exceptions(errors) have occurred. Irrespective of the try block, the expression in finally block(finally{})  is always executed. This block(finally{}) is in-built with the capability of recovering lost and preventing the leak of resources. On closing and recovery of a file, the […]

Rekha Setia 
Add Border to JPanel
Java Programming

Add  Border to  JPanel

Borders are basically margined around the edges of a Swing component. Borders are useful for providing titles and empty spaces around components. The setBorder() is used to put a border around a component. Borders in JPanel Example import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.awt.event.*; public class VariousBorders extends JPanel { Border border; JButton butn; […]

Rekha Setia 
Border Layout in Java
Java Programming

Border Layout in Java

BorderLayout  divides the container into five parts (directions),east,west,north,south,centre. By using this Layout we can place AWT components in each part (different location). BORDER LAYOUT IN JAVA EXAMPLE import java.awt.*; import java.applet.*; public class bordr extends Applet { Button b1,b2,b3,b4,b5; public void init() { b1=new Button(“east”); b1.setBackground(Color.RED); b2=new Button(“west”); b2.setBackground(Color.GREEN); b3=new Button(“south”); b3.setBackground(Color.BLACK); b4=new Button(“north”); b4.setBackground(Color.BLUE); […]

Rekha Setia 
Java Program Structure
Java Programming

Java Program Structure

In Java Program Structure, the java system may contain numerous classes of which one and only class characterize the main technique. Classes contain information members and techniques that work on the information members from the class. Strategies may contain information sort revelation and executable articulations. To compose a Java program, we first characterize classes and […]

Rekha Setia 
Java Abstract Window ToolKit(AWT)
Java Programming

Java Abstract Window ToolKit(AWT)

Awt package is used for components and awt. event package is used for action performed. If we want to select only one option we use checkboxes.CheckboxGroup is a set of checkboxes in which we can select only one option(checkbox) . The checkboxes which are set in CheckboxGroup are called “radio buttons”. AWT Example import java.awt.*; […]

Rekha Setia