Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Network Communication


    

Blue Forest http://www.lslnet.com at 13:28 on July 26, 2006

JAVA incident summary


JAVA incident summary

JAVA incident in school so long I felt a little bit knows, I would like to sum up the reason is not right. Now I have a few small examples to me to understand more clearly the events in Java. JAVA incident is nothing more than a keyboard, mouse, buttons and so on. Semantic point can be divided into professional events (button at the event) and lower (for keyboard, mouse events); Now I will briefly summarize : Java incident in the school so long I felt a little bit knows, I would like to sum up the reason is not right. Now I have a few small examples to me to understand more clearly the events in Java. JAVA incident is nothing more than a keyboard, mouse, buttons and so on. Semantic point can be divided into professional events (button at the event) and lower (for keyboard, mouse events); Now I will briefly summarize : one mouse button mouse events : Call it three things : mousePressed sniffers, mouseReleased, mouseClicked.
MousePressed incident with the mouse, mouseClicked, mouseDragged, mouseEntered and mouseExited, mouseUp and mouseDown, mouseDrag incidents. The following are examples : a mouse, a
Import java.awt.*;
Import java.applet.Applet;
Public class CountClick extends Applet
{int CurrentMarks=0;
Int a, 1997a
Public boolean mouseDown (Event evt, int x, int y) 4003rd when the mouse?
-- CurrentMarks++;// dollars recorded number?
Repaint () version ;// renewable surface
A=x;// be abscissa of the mouse
B=y;// be vertical coordinates of the mouse
Return true;
}
Public void paint (Graphics g)
-- G.drawString ( "" +CurrentMarks,10,10) ;// number of print?
G.drawString ( "" +a,10,30) ;// print abscissa of the mouse
G.drawString ( "" +b,10,20) ;// printing firm mouse coordinates
}
}
//<applet Code= "CountClick.class" width= "200" height "100" and "</applet>
2, keyboard events : if we want to have input information using the keyboard, it is necessary to handle keyboard events. We can use the keyDown in Conponent to achieve. The following examples :
Import java.applet.Applet;import java.awt.*;
(Char Presskey;
Public boolean keyDown (Event evt, int key)
-- Presskey= (char) key;// you press the record button
Repaint (); Return true;
}
Public void paint (Graphics g)
-- G.drawString (Presskey,10,10); }// You press the Print key assignment
}
3, ammonium Niu other aspects of this incident : more, an example to make a brief introduction.
//*******2004, November 8 **************//
//******* Xiaodouzi better understanding of the incident ******//
//******* Attention Repaint () methods of ******//
JAVA //** through the process of furthering the understanding of data hiding with a ***///
//******* Continue to work hard. Gogogogogo******//
Import java.awt.*;
Import java.applet.Applet;
Import java.awt.event.*;
Public class Awtactiontest2 extends Applet implements ItemListener, ActionListener
4003rd achieve ItemListener, ActionListener Adapter
{
Also published int = 5;
Choice ch=new Choice ();
Button one=new Button ( "one");
Button two=new Button ( "two");
Button three=new Button ( "three");
Image aa[];
Image a;
Public void init ()
{
Aa = new Image[num];
For (int i = 0 i "num; i++) 4003rd put pictures on the path to its storage arrays
{
Aa[i] = getImage (getDocumentBase (), "A" + (+1) +. " JPG ");
}
Num=4;// to an initial value
This.setBackground (Color.white);
Ch. AddItem ( "A1.JPG");
Ch. AddItem ( "A2.JPG");
Ch. AddItem ( "A3.JPG");
Ch. AddItem ( "A4.JPG");
Add (ch);
A = getImage (getDocumentBase (), "A1.JPG") for a one ;// initial;
Add (one);
Add (two);
Add (three);
Ch.addItemListener (this) adapter implements them ;// paid ItemListener
One.addActionListener (this) adapter implements them ;// paid ActionListener
Two.addActionListener (this);
Three.addActionListener (this);
}
Public void itemStateChanged (ItemEvent e)
{

A = getImage (getDocumentBase (), ch.getSelectedItem ());
Repaint ();
}
Public void actionPerformed (ActionEvent e)
{
If (e.getSource () ==one)
{
Num=1;
Repaint () procedure to renewable ;//
}
If (e.getSource () ==two)
{
Num=2;
Repaint ();
}
If (e.getSource () ==three)
{
Num=3;
Repaint ();
}
}
Public void paint (Graphics g)
{
//g.drawImage (Aa[i],0,0, this);

Int w=a.getWidth (this);
Int h=a.getHeight (this);
4003rd g.drawLine (100,1,200,500);
Try{
G.drawImage (a,20,300,10+w,20+h, this) ;// grasp unusual, if not pictures?
G.drawImage (aa[num],50,50,200,200, this);
}
Catch (Exception e)
{
System.out.println (e);
}
}
Public boolean handleEvent (Event ewt) 4003rd relations Windows, I had originally thought that this can be related to the cycle of death and the other is not. Not the same customs procedures
{
If (ewt.id==Event.WINDOW_DESTROY)
System.exit (0);
Else
Return super.handleEvent (ewt);
Return true;
}
}
//<Applet Code= "Awtactiontest2.class" width=400 height=500></applet>
: Since I started writing files, we have not asked what level of understanding.
Www.chinaitlab.com//www/school/java.asp

!!

Of java could not speak. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Brother message is not made a mistake. This is Cisco technology.


 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com