Thursday, 9 February 2012

Applets

Applet
An applet is a Java program that runs in a Web browser.

An applet is a Java class that extends the java.applet.Applet class.
A main() method is not invoked on an applet, and an applet class will not define main().
Applets are designed to be embedded within an HTML page.

An APPLET usually consists of two sections:
 init() 
 paint()

 init() is short for initialization, and it is used to take care of anything that needs to be set up as an applet first runs. The paint() block is used to display anything that should be displayed.

Here is a simple example of Applet:


import java.applet.*;
import java.awt.*;
/*
<applet code="HelloWorldApplet" width="500" height="400"></applet>
*/

public class HelloWorldApplet extends Applet{
   public void paint (Graphics g)
   {
      g.drawString ("Hello World", 25, 50);
   }
}


HOW TO COMPILE AND RUN AN APPLET:

Save as:          HelloWorldApplet.java
Compile as:    javac HelloWorldApplet.java
Run as:           appletviewer HelloWorldApplet.java

NOTE:    The class must be declared   public.

Components that can be used with Applet:
Button
TextField
Label
TextArea
Choice
List
Frame


Using Listeners with Applets:

Here is an example to show the response to a button click.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="ActionListenerApplet" width="500" height="400"></applet>
*/

public class ActionListenerApplet extends Applet implements ActionListener{
String str="Hello";
Button b;public void start()
{
b = new Button("CLICK");b.addActionListener(this);
add(b);
}
public void actionPerformed(ActionEvent ae)
{
str="hiiiiii";
repaint();
}

   public void paint (Graphics g)
   {
      g.drawString (str, 25, 50);
   }
}

:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Another example to show the use of event listeners:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="ActionListenerApplet2" width="500" height="400"></applet>
*/

public class ActionListenerApplet2 extends Applet implements ActionListener{
int i=1;
String str="Hello   "+i;
Button b;public void start()
{
b = new Button("CLICK");b.addActionListener(this);
add(b);
}
public void actionPerformed(ActionEvent ae)
{
i++;
str="hiiiiii    "+i;
repaint();
}

   public void paint (Graphics g)
   {
      g.drawString (str, 25, 50);
   }
}

// Here,  'i'  increments with every button click.

Saturday, 7 January 2012

Bluetooth

Bluetooth is a wireless LAN technology designed to connect devices of different functions such as telephones, notebooks, computers, cameras, printers, coffee makers, and so on, in a small area such as a room.

Bluetooth is an implementation protocol defined by the IEEE 802.15 standard. The standard defines a wireless Personal Area Network (PAN) operable in a small area. The bluetooth standard specifies wireless operation in the 2.45 GHz radio band and supports data rates upto 720 kbps. A complete Bluetooth system requires following elements:
  • An RF position for receiving and transmitting data
  • A module with a baseband microprocessor
  • Memory
  • An interface to the host device (such as a mobile phone)

Thursday, 17 November 2011

Customized Status-Bar

Normally, when you hover your cursor over a link, the status bar tells you a link's URL destination.
However, this thing can be changed according to our need. In other words, the message that appears in the status bar at the bottom of the page can be customized. This can be done by the following HTML code:

<a href="http://qsrealm.blogspot.com" onMouseOver="window.status='This message appears on the status bar!'; return true" onMouseOut="window.status=''">link</a>

Wednesday, 9 November 2011

Dual Core Processor




A dual core processor is a CPU with two separate cores on the same die, each with its own cache. It's the equivalent of getting two microprocessors in one.

In a dual core processor, each core handles incoming data strings simultaneously to improve efficiency. We know two hands are better than one. Now when one is executing the other can be accessing the system bus or executing its own code.
Example: Intel Core Duo

Why Dual Core?
A dual-core processor has two cores on the same die.

This means that signals between different CPUs travel shorter distances, and therefore those signals degrade less. These higher-quality signals allow more data to be sent in a given time period, since individual signals can be shorter and do not need to be repeated as often.
A dual-core processor uses slightly less power than two coupled single-core processors, principally because of the decreased power required to drive signals external to the chip


Friday, 4 November 2011

'this' keyword

'this' keyword holds the reference of object of the current class.
So, 'this' can be used to do all the work that an object can do.
Similarly, this( ) can be used to call the constructor of the current class.
Example:
class ThisDemo {
int i ;
ThisDemo( ) { }
void callingFunction( int i) {
this( );                                    // calls the constructor
this.i = i;                                // the value of argument ' i ' is passed to the variable ' i ' of class
}
}

Tuesday, 1 November 2011

Viewers' Question

What are the classes in java.sql package ?

Answer: The  java.sql  package includes only one class, that is, DriverManager.
              All others are interfaces in  java.sql  package.

If something is unclear, draw a picture

Creating an image of what one learns or percieves helps one to retain it for a longer time. So, keep asking questions and keep drawing your concepts!

JAVA Project Specifications Lecture Notes: SE OS JAVA

X