CS Keyboard Inputs

Tatlo yung in-email ni Sir Paolo. :O



//

import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;


/**
* Class Keyboard - write a description of the class here
*
* @author (your name)
* @version (a version number)
*/
public class Keyboard extends JApplet implements KeyListener, MouseListener, MouseMotionListener
{
int width=500, height=500;
int x, y;
String s = "";

public void mouseEntered( MouseEvent e ) { }
public void mouseExited( MouseEvent e ) { }
public void mousePressed( MouseEvent e ) { }
public void mouseReleased( MouseEvent e ) { }
public void mouseMoved( MouseEvent e ) { }
public void mouseDragged( MouseEvent e ) { }
public void mouseClicked( MouseEvent e ) {
x = e.getX();
y = e.getY();
s = "";
repaint();
}

public void keyPressed( KeyEvent e ) { }
public void keyReleased( KeyEvent e ) { }
public void keyTyped( KeyEvent e ) {
char c = e.getKeyChar();
s = s + c;
repaint();

}


/**
* Called by the browser or applet viewer to inform this JApplet that it
* has been loaded into the system. It is always called before the first
* time that the start method is called.
*/
public void init()
{
// this is a workaround for a security conflict with some browsers
// including some versions of Netscape & Internet Explorer which do
// not allow access to the AWT system event queue which JApplets do
// on startup to check access. May not be necessary with your browser.
JRootPane rootPane = this.getRootPane();
rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

// provide any initialisation necessary for your JApplet

addKeyListener( this );
addMouseListener( this );

}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
*/
public void start()
{
// provide any code requred to run each time
// web page is visited
}

/**
* Called by the browser or applet viewer to inform this JApplet that
* it should stop its execution. It is called when the Web page that
* contains this JApplet has been replaced by another page, and also
* just before the JApplet is to be destroyed.
*/
public void stop()
{
// provide any code that needs to be run when page
// is replaced by another page or before JApplet is destroyed
}

/**
* Paint method for applet.
*
* @param g the Graphics object for this applet
*/
public void paint(Graphics g)
{
g.setColor( Color.black );
g.drawLine( x, y, x, y-10 );
g.setColor( Color.blue );

//Font(name,style,size);
//Styles: Font.BOLD, PLAIN, ITALIC
g.setFont(new Font("Default",Font.BOLD,20));
g.drawString( s, x, y );

}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* is being reclaimed and that it should destroy any resources that it
* has allocated. The stop method will always be called before destroy.
*/
public void destroy()
{
// provide code to be run when JApplet is about to be destroyed.
}


/**
* Returns information about this applet.
* An applet should override this method to return a String containing
* information about the author, version, and copyright of the JApplet.
*
* @return a String representation of information about this JApplet
*/
public String getAppletInfo()
{
// provide information about the applet
return "Title: \nAuthor: \nA simple applet example description. ";
}


/**
* Returns parameter information about this JApplet.
* Returns information about the parameters than are understood by this JApplet.
* An applet should override this method to return an array of Strings
* describing these parameters.
* Each element of the array should be a set of three Strings containing
* the name, the type, and a description.
*
* @return a String[] representation of parameter information about this JApplet
*/
public String[][] getParameterInfo()
{
// provide parameter information about the applet
String paramInfo[][] = {
{"firstParameter", "1-10", "description of first parameter"},
{"status", "boolean", "description of second parameter"},
{"images", "url", "description of third parameter"}
};
return paramInfo;
}
}




import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;


/**
* Class Keyboard - write a description of the class here
*
* @author (your name
* @version (a version number)
*/
public class Keyboard2 extends JApplet implements KeyListener
{
int width=500, height=500;
int x=200, y=200;

public void keyPressed( KeyEvent e ) {
char c = e.getKeyChar();
if ( c == 'w') {
y--;
repaint();
} else if ( c == 'a') {
x--;
repaint();
} else if ( c == 'd') {
x++;
repaint();
} else if ( c == 's') {
y++;
repaint();
}
showStatus(x+","+y);
}
public void keyReleased( KeyEvent e ) { }
public void keyTyped( KeyEvent e ) { }


/**
* Called by the browser or applet viewer to inform this JApplet that it
* has been loaded into the system. It is always called before the first
* time that the start method is called.
*/
public void init()
{
// this is a workaround for a security conflict with some browsers
// including some versions of Netscape & Internet Explorer which do
// not allow access to the AWT system event queue which JApplets do
// on startup to check access. May not be necessary with your browser.
JRootPane rootPane = this.getRootPane();
rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

// provide any initialisation necessary for your JApplet

addKeyListener( this );

}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
*/
public void start()
{
// provide any code requred to run each time
// web page is visited
}

/**
* Called by the browser or applet viewer to inform this JApplet that
* it should stop its execution. It is called when the Web page that
* contains this JApplet has been replaced by another page, and also
* just before the JApplet is to be destroyed.
*/
public void stop()
{
// provide any code that needs to be run when page
// is replaced by another page or before JApplet is destroyed
}

/**
* Paint method for applet.
*
* @param g the Graphics object for this applet
*/
public void paint(Graphics g)
{
g.setColor( Color.white );
g.fillRect( 0, 0, 500,500 );

g.setColor( Color.blue );
g.fillRect( x, y, 50,50 );


}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* is being reclaimed and that it should destroy any resources that it
* has allocated. The stop method will always be called before destroy.
*/
public void destroy()
{
// provide code to be run when JApplet is about to be destroyed.
}


/**
* Returns information about this applet.
* An applet should override this method to return a String containing
* information about the author, version, and copyright of the JApplet.
*
* @return a String representation of information about this JApplet
*/
public String getAppletInfo()
{
// provide information about the applet
return "Title: \nAuthor: \nA simple applet example description. ";
}


/**
* Returns parameter information about this JApplet.
* Returns information about the parameters than are understood by this JApplet.
* An applet should override this method to return an array of Strings
* describing these parameters.
* Each element of the array should be a set of three Strings containing
* the name, the type, and a description.
*
* @return a String[] representation of parameter information about this JApplet
*/
public String[][] getParameterInfo()
{
// provide parameter information about the applet
String paramInfo[][] = {
{"firstParameter", "1-10", "description of first parameter"},
{"status", "boolean", "description of second parameter"},
{"images", "url", "description of third parameter"}
};
return paramInfo;
}
}
//


//
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Keyboard3 extends JApplet implements MouseListener, MouseMotionListener, KeyListener {
// instance variables - replace the example below with your own
int width=500, height=500;
int mx, my; // the mouse coordinates
boolean isButtonPressed = false,loaded = false;
Color theColor = new Color(0,0,0);
String s = "";

public void keyPressed( KeyEvent e ) { }
public void keyReleased( KeyEvent e ) { }
public void keyTyped( KeyEvent e ) {
char c = e.getKeyChar();
if ( c != KeyEvent.CHAR_UNDEFINED ) {
s = s + c;
repaint();
}
}

public void mouseEntered( MouseEvent e ) {
// called when the pointer enters the applet's rectangular area
}

public void mouseExited( MouseEvent e ) {
// called when the pointer leaves the applet's rectangular area
}

public void mouseClicked( MouseEvent e ) {
// called after a press and release of a mouse button
// with no motion in between
// (If the user presses, drags, and then releases, there will be
// no click event generated.)


repaint();
}

public void mousePressed( MouseEvent e ) { // called after a button is pressed down
isButtonPressed = true;
//setBackground( Color.gray );

if(mx > 50 && mx < 100 && my > 50 && my < 100){
theColor = Color.red;
}

if(mx > 50 && mx < 100 && my > 125 && my < 175){
theColor = Color.green;
}

if(mx > 50 && mx < 100 && my > 200 && my < 250){
theColor = Color.blue;
}

if(mx > 25 && mx < 125 && my > 400 && my < 450){
s = "";
}

repaint();
}

public void mouseReleased( MouseEvent e ) { // called after a button is released
isButtonPressed = false;
}

public void mouseMoved( MouseEvent e ) { // called during motion when no buttons are down
mx = e.getX();
my = e.getY();
showStatus( "Mouse at (" + mx + "," + my + ")" );
repaint();
}

public void mouseDragged( MouseEvent e ) { // called during motion with buttons down
mx = e.getX();
my = e.getY();
showStatus( "Mouse at (" + mx + "," + my + ")" );
repaint();
}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* has been loaded into the system. It is always called before the first
* time that the start method is called.
*/
public void init()
{
// this is a workaround for a security conflict with some browsers
// including some versions of Netscape & Internet Explorer which do
// not allow access to the AWT system event queue which JApplets do
// on startup to check access. May not be necessary with your browser.
JRootPane rootPane = this.getRootPane();
rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

mx = 0;
my = 0;

addMouseListener( this );
addMouseMotionListener( this );
addKeyListener( this );
}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
*/
public void start()
{
}

/**
* Called by the browser or applet viewer to inform this JApplet that
* it should stop its execution. It is called when the Web page that
* contains this JApplet has been replaced by another page, and also
* just before the JApplet is to be destroyed.
*/
public void stop()
{
// provide any code that needs to be run when page
// is replaced by another page or before JApplet is destroyed
}

/**
* Paint method for applet.
*
* @param g the Graphics object

* for this applet
*/
public void paint(Graphics g)
{
if(!loaded){
g.setColor(Color.gray);
g.fillRect(0,0,250,500);

g.setColor(Color.red);
g.fillRect(50,50,50,50);

g.setColor(Color.green);
g.fillRect(50,125,50,50);

g.setColor(Color.blue);
g.fillRect(50,200,50,50);

g.setColor( theColor );
g.fillRect(25,275,100,100);

g.setColor( Color.white );
g.fillRect(25,400,100,50);

g.setColor( Color.black );
g.drawRect(25,400,100,50);
g.drawString("Clear",55,425);

loaded = true;
}

if ( isButtonPressed && mx > width/2) {

g.setColor( theColor );
g.drawString(s,mx-5, my-5);

}
else if ( isButtonPressed && mx < width/2){
g.setColor( theColor );
g.fillRect(25,275,100,100);
}
}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* is being reclaimed and that it should destroy any resources that it
* has allocated. The stop method will always be called before destroy.
*/
public void destroy()
{
// provide code to be run when JApplet is about to be destroyed.
}


/**
* Returns information about this applet.
* An applet should override this method to return a String containing
* information about the author, version, and copyright of the JApplet.
*
* @return a String representation of information about this JApplet
*/
public String getAppletInfo()
{
// provide information about the applet
return "Title: \nAuthor: \nA simple applet example description. ";
}


/**
* Returns parameter information about this JApplet.
* Returns information about the parameters than are understood by this JApplet.
* An applet should override this method to return an array of Strings
* describing these parameters.
* Each element of the array should be a set of three Strings containing
* the name, the type, and a description.
*
* @return a String[] representation of parameter information about this JApplet
*/
public String[][] getParameterInfo()
{
// provide parameter information about the applet
String paramInfo[][] = {
{"firstParameter", "1-10", "description of first parameter"},
{"status", "boolean", "description of second parameter"},
{"images", "url", "description of third parameter"}
};
return paramInfo;
}
}
//


//
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

/**
* Class Animate - write a description of the class here
*
* @author (your name)
* @version (a version number)
*/
public class Animate2 extends JApplet implements Runnable,KeyListener
{
// instance variables - replace the example below with your own
int width, height;
int y = 0,x = 0;
String direction = "down";
Thread t = null;

public void keyPressed( KeyEvent e ) { }
public void keyReleased( KeyEvent e ) { }
public void keyTyped( KeyEvent e ) {
char c = e.getKeyChar();
if ( c == 'w') {
direction = "up";
} else if ( c == 'a') {
direction = "left";
} else if ( c == 'd') {
direction = "right";
} else if ( c == 's') {
direction = "down";
}
}


public void run() {
//runs simultaneously with the applet's methods
try {
while (true) {
if(direction == "up"){
y--;
} else if(direction == "down"){
y++;
} else if(direction == "left"){
x--;
} else if(direction == "right"){
x++;
}

if ( y == 11 ) {
y = 0;
}

if ( x == 11 ) {
x = 0;
}

if ( y == -1 ) {
y = 10;
}

if ( x == -1 ) {
x = 10;
}
showStatus("Moving " + direction);
repaint();
t.sleep( 100 ); // interval given in milliseconds
}
}
catch (Exception e) { }
}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* has been loaded into the system. It is always called before the first
* time that the start method is called.
*/
public void init()
{
// this is a workaround for a security conflict with some browsers
// including some versions of Netscape & Internet Explorer which do
// not allow access to the AWT system event queue which JApplets do
// on startup to check access. May not be necessary with your browser.
JRootPane rootPane = this.getRootPane();
rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

// provide any initialisation necessary for your JApplet

width = getSize().width;
height = getSize().height;
addKeyListener( this );
}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
*/
public void start()
{
// provide any code requred to run each time
// web page is visited'
t = new Thread( this );
t.start();
}

/**
* Called by the browser or applet viewer to inform this JApplet that
* it should stop its execution. It is called when the Web page that
* contains this JApplet has been replaced by another page, and also
* just before the JApplet is to be destroyed.
*/
public void stop()
{
// provide any code that needs to be run when page
// is replaced by another page or before JApplet is destroyed
}

/**
* Paint method for applet.
*
* @param g the Graphics object for this applet
*/
public void paint(Graphics g)
{
// simple text displayed on applet
g.setColor( Color.white );
g.fillRect( 0,0,width,height);
g.setColor( Color.blue );
g.fillRect( x * height / 10, y * height / 10, 50 , 50 );

}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* is being reclaimed and that it should destroy any resources that it
* has allocated. The stop method will always be called before destroy.
*/
public void destroy()
{
// provide code to be run when JApplet is about to be destroyed.
}


/**
* Returns information about this applet.
* An applet should override this method to return a String containing
* information about the author, version, and copyright of the JApplet.
*
* @return a String representation of information about this JApplet
*/
public String getAppletInfo()
{
// provide information about the applet
return "Title: \nAuthor: \nA simple applet example description. ";
}


/**
* Returns parameter information about this JApplet.
* Returns information about the parameters than are understood by this JApplet.
* An applet should override this method to return an array of Strings
* describing these parameters.
* Each element of the array should be a set of three Strings containing
* the name, the type, and a description.
*
* @return a String[] representation of parameter information about this JApplet
*/
public String[][] getParameterInfo()
{
// provide parameter information about the applet
String paramInfo[][] = {
{"firstParameter", "1-10", "description of first parameter"},
{"status", "boolean", "description of second parameter"},
{"images", "url", "description of third parameter"}
};
return paramInfo;
}
}
//




import java.awt.*;
import javax.swing.*;

/**
* Class Animate - write a description of the class here
*
* @author (your name)
* @version (a version number)
*/
public class Animate extends JApplet implements Runnable
{
// instance variables - replace the example below with your own
int width, height;
int y = 0;
Thread t = null;


public void run() {
//runs simultaneously with the applet's methods
try {
while (true) {
y++;
if ( y == 500 ) {
y = 0;
}

repaint();
t.sleep( 10 ); // interval given in milliseconds
}
}
catch (Exception e) { }
}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* has been loaded into the system. It is always called before the first
* time that the start method is called.
*/
public void init()
{
// this is a workaround for a security conflict with some browsers
// including some versions of Netscape & Internet Explorer which do
// not allow access to the AWT system event queue which JApplets do
// on startup to check access. May not be necessary with your browser.
JRootPane rootPane = this.getRootPane();
rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

// provide any initialisation necessary for your JApplet

width = getSize().width;
height = getSize().height;

}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* should start its execution. It is called after the init method and
* each time the JApplet is revisited in a Web page.
*/
public void start()
{
// provide any code requred to run each time
// web page is visited'
t = new Thread( this );
t.start();
}

/**
* Called by the browser or applet viewer to inform this JApplet that
* it should stop its execution. It is called when the Web page that
* contains this JApplet has been replaced by another page, and also
* just before the JApplet is to be destroyed.
*/
public void stop()
{
// provide any code that needs to be run when page
// is replaced by another page or before JApplet is destroyed
}

/**
* Paint method for applet.
*
* @param g the Graphics object for this applet
*/
public void paint(Graphics g)
{
// simple text displayed on applet
g.setColor( Color.white );
g.fillRect( 0,0,width,height);
g.setColor( Color.blue );
g.fillRect( width/2, y, 50 , 50 );

}

/**
* Called by the browser or applet viewer to inform this JApplet that it
* is being reclaimed and that it should destroy any resources that it
* has allocated. The stop method will always be called before destroy.
*/
public void destroy()
{
// provide code to be run when JApplet is about to be destroyed.
}


/**
* Returns information about this applet.
* An applet should override this method to return a String containing
* information about the author, version, and copyright of the JApplet.
*
* @return a String representation of information about this JApplet
*/
public String getAppletInfo()
{
// provide information about the applet
return "Title: \nAuthor: \nA simple applet example description. ";
}


/**
* Returns parameter information about this JApplet.
* Returns information about the parameters than are understood by this JApplet.
* An applet should override this method to return an array of Strings
* describing these parameters.
* Each element of the array should be a set of three Strings containing
* the name, the type, and a description.
*
* @return a String[] representation of parameter information about this JApplet
*/
public String[][] getParameterInfo()
{
// provide parameter information about the applet
String paramInfo[][] = {
{"firstParameter", "1-10", "description of first parameter"},
{"status", "boolean", "description of second parameter"},
{"images", "url", "description of third parameter"}
};
return paramInfo;
}
}

//
1 comments:

The Clove Cigarettes lover keep faith of taste and top quality never substitute to the other an individual also it is effortless to look for kretek smoking, in point has a lot of cigarettes on-line store emerge on most recent which deliver the a variety of makes and discount rates. The different quotation with exact same quality and excellent expert services with priority of speed, safety and totally free for express delivery services is assured.


The folks who [url=http://buycigarettesonline.buycigaretterollingmachinereviews.info]buy cigarettes onlinebuy cigarettes online " the exotic "Kretek cigarettes" processed by well known Madura Tobacco from East Java and mixed of Indonesian character clove or spices then produce sensational exotic fragrance from common of Indonesia tropical island.

Kretek smoking sound much more and extra familiar for every person then some folks commence to locate out.. what the secret and consists of of kretek cigarettes. Via the hygienic and superior processing make clove cigarettes lover certain and think the kretek cigarettes have not matched through the other cigarettes merchandise.

The reputation of clove cigarettes have almost spread Community extensively as well as become a single of the essential broadcasting physical activities sponsorship in Indonesian like FIFA Globe Cup 2006, League Calcio and League Premiership which is sponsored by official Djarum Super Soccer, KOBATAMA Basketball Competition by Sampoerna A Mild also Boxing Super Cup and La liga Soccer from Spain by Gudang Garam International. The clove cigarettes sponsorship Not just on sporting activities regime but also supporting the charity humanity regime and musics entertainment.


Post a Comment

Hi. :-h


Chem2

Recent Entries

Recent Comments