Java             3GL - .   4GL -     DB-

JAVA

Java

AWT, Java1.1 , Java 1.0. , .

Java 1.0

, , , , , , .

, , handleEvents Component. Event, . , , , , Component.

, , , , .

, keyDown keyUp . . , , -, shiftDown, controlDown metaDown. Event , , , PGUP HOME.

, , , (callback) Button, Scrollbar Menu, action. , , . , , , . , , , , Button, instanceof.

. Label , action , , . Component.

/* <applet code = EventDemo width=200 height=200>
   </applet>
*/ 
import java.awt.*;
import java.applet.*;
public class EventDemo extends Applet {
static final int n = 4;
Label lab = new Label("?", Label.CENTER);
public void init() {
setLayout(new GridLayout(n,  n));
setFont(new Font("Helvetica", Font.BOLD, 24));
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
for (int i = 0;  i < n;  i++)  {
     for (int j = 0;  j  < n;  j++)  {
          int k = i * n + j;
          if (k > 0)
              add(new Button("" + k));
     }
}
lab.setFont(new Font("Helvetica", Font.ITALIC, 24));
add(lab);
}
public boolean action(Event e,  Object o)  {
if (o instanceof String)  {
lab.setText((String) o);
}
return false;
} }

5 AWT , . , . , id Event.

, -when ( ), ( ), ( ), key ( ) modifiers ( , ) . , , . , , arg Event.

, Component, java.awt. Component, , window, window, Dialog Frame.

5. AWT Java 1.0,

(id)

w

h

e

n

x

y

k

e y

m

d

s

arg

Button ()

ACTION_EVENT

 

 

 

 

 

 

 

 

 

 

String:

Checkbox ()

ACTION_EVENT

 

 

 

 

 

 

 

 

 

 

Boolean:

Choice ( )

ACTION_EVENT

 

 

 

 

 

 

 

 

 

 

String:

Element ()

GOT_FOCUS

 

 

 

 

 

 

 

 

 

 

Element ()

KEY_ACTION

*

*

*

*

*

, key

Element ()

KEY_ACTION_ RELEASE

*

*

*

*

*

, key

Element ()

KEY_PRESS

*

*

*

*

*

, key ASCII-

Element ()

KEY_RELEASE

*

*

*

*

*

, key ASCII-

Element ()

LOST_FOCUS

 

 

 

 

 

 

 

 

 

 

Element ()

MOUSE_ENTER

*

*

*

 

 

 

 

Component

Element ()

MOUSE_EXIT

*

*

*

 

 

 

 

Component

Element ()

MOUSE_D0WN

*

*

*

 

 

*

Element

()

MOUSE_UP

*

*

*

 

 

*

Element ()

MOUSE_MOVE

*

*

*

 

 

*

Element ()

MOUSE_DRAG

*

*

*

 

 

*

List ()

ACTION_EVENT

 

 

 

 

 

 

 

 

 

 

String:

List ()

LIST_SELECT

 

 

 

 

 

 

 

 

 

 

Integer:

List ()

LIST_DESELECT

 

 

 

 

 

 

 

 

 

 

Integer:

Menu Item ()

ACTION_EVENT

 

 

 

 

 

 

 

 

 

 

String:

Scrollbar ( )

SCROLL_LINE_UP

 

 

 

 

 

 

 

 

 

 

Integer: ,

Scrollbar ( )

SCROLL_LINE_

DOWN

 

 

 

 

 

 

 

 

 

 

Integer: ,

Scrollbar ( )

SCROLL_PAGE_UP

 

 

 

 

 

 

 

 

 

 

Integer: ,

Scrollbar ( )

SCROLL_PAGE_

DOWN

 

 

 

 

 

 

 

 

 

 

Integer: ,

Scrollbar ( )

SCROLL_

ABSOLUTE

 

 

 

 

 

 

 

 

 

 

Integer: ,

Text Field ()

ACTION_EVENT

 

 

 

 

 

 

 

 

 

 

[Return].

String:

Window ()

WINDOW_

DESTROY

 

 

 

 

 

 

 

 

 

 

Window ()

WINDOW_

ICONIFY

 

 

 

 

 

 

 

 

 

 

Window ()

WINDOW_

DEICONIFY

 

 

 

 

 

 

 

 

 

 

Window ()

WINDOW_MOVED

 

 

*

*

 

 

 

 

"" Java 1.0

, Java 1.0. mouseDown() mouseDragO , "" . keyDown(), [] , action(), Clear.

/* <applet code = Scribble1 width=200 height=200>
   </applet>
*/
import java.applet.*;
import java.awt.*;
/**  ,       1.0 */
public class Scribble1 extends Applet {
private int lastx, lasty;    //    .
Button clear_button;         //  Clear.
Graphics g;                  //  Graphics,   .
/**     Graphics */
public void init() {
clear_button = new Button("Clear");
this.add(clear_button);
g = this.getGraphics();
}
/**      */
public boolean mouseDown(Event e, int x, int y) {
lastx = x; lasty = y;
return true;
}
/**       */
public boolean mouseDrag(Event e, int x, int y) {
g.setColor(Color.black) ;
g.drawLine(lastx, lasty, x, y);
lastx = x; lasty = y;
return true;
}
/**     [] */
public boolean keyDown(Event e, int key) {
if ((e.id == Event.KEY_PRESS) && (key == '' ) ) {
clear() ;
return true;
}
else return false;
}
/**     Clear */
public boolean action(Event e, Object arg) {
if (e.target == clear_button) {
clear();
return true;
}
else return false;
}
/**     */
public void clear() {
g.setColor(this.getBackground());
g.fillRect(0, 0, bounds().width, bounds().height);
} }

!.

Java 1.1

, , (callback). GUI- , ( , ..). C++, ( , ). Java ( ). , . GUI-, . , GUI- , .

Java 1.1 AWT, JavaBeans API. Java. java.util.EventObject. AWT, , java.awt.AWTEvent. AWT (, MouseEvent tionEvent) java.awt.event.

, getSource(), AWT , getid(). , , . , FocusEvent : FocusEvent.FOCUS_GAINED FocusEvent.FOCUS_LOST. , . , MouseEvent getX(), getY() getClickCount (). , , getModifiers() getWhen().

Java 1.1 . , . , ( ), , , , , . ( , ), , .

( EventObject). , . , . , ActionEvent ActionListener. Java.awt.event (, MouseEvent : MouseListener MouseMotionListener). java.util.EventListener. , -, .

. , , MouseEvent, , , . . , , , . , . 6 java.awt.event , , , .

6. , Java 1.1

ActionEvent

ActionListener

actionPerformed()

AdjustmentEvent

AdjustmentListener

adjustmentValueChanged()

ComponentEvent

ComponentListener

componentHidden() componentMoved() componentResized() CorcomponentShown()

ContainerEvent

ContainerListener

componentAdded() componentRemoved()

FocusEvent

FocusListener

focusGained()

focusLost ()

ItemEvent

ItemListener

itemStateChanged()

KeyEvent

KeyListener

keyPressed()

keyReleased()

keyTyped()

MouseEvent

MouseListener

mouseClicked()

mouseEntered()

mouseExited()

mousePressed() mouseReleased()

MouseMotionListener

mouseDragged()

mouseMoved()

TextEvent

TextListener

textValueChanged()

WindowEvent

WindowListener

windowActivated() windowClosed() windowClosing() windowDeactivated() windowDeiconified() windowlconified() windowOpened()

 

, , java.awt.event -, . , -, . , , , . - , , , Listener Adapter: MouseAdapter, WindowAdapter ..

-, , . . AWT - . : X, addXListener () removeXListener() . Java 1.1 , . , . , API Button , ActionEvent. 7 AWT , .

7. AWT Java1.1

Button

ActionEvent

CheckBox

ItemEvent

CheckBoxMenuItem

ItemEvent

Choice

ItemEvent

Component

ComponentEvent

, ,

FocusEvent

KeyEvent

MouseEvent

, , ,

Container

ContainerEvent

List

ActionEvent

ItemEvent

MenuItem

ActionEvent

Scrollbar

AdjustmentEvent

TextComponent

TextEvent

TextField

ActionEvent

Window

WindowEvent

, , ,

"" Java 1.1

Java 1.1 . . MouseListener MouseMotionListener, addMouseListener() addMouseMotionListener().

/* <applet code = Scribble2 width=200 height=200>
   </applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Scribble2 extends Applet implements
             MouseListener, MouseMotionListener {
private int last_x, last_y;
public void init() {
//     ,  
//  MouseListener  MouseMotionListener   
//  ,      .
//      ,
//      .
this.addMouseListener(this) ;
this.addMouseMotionListener(this);
}
//   MouseListener.   
//   .
public void mousePressed(MouseEvent e) {
last_x = e.getX();
last_y = e.getY();

} // MouseMotionListener. // . public void mouseDragged(MouseEvent e) { Graphics g = this.getGraphics(); int x = e.getX(), y = e.getY(); g.drawLine(last_x, last_y, x, y); last_x = x; last_y = y;

} // , MouseListener. public void mouseReleased(MouseEvent e) {;} public void mouseClicked(MouseEvent e) {;} public void mouseEntered(MouseEvent e) {;} public void mouseExited(MouseEvent e) {;} // MouseMotionListener. public void mouseMoved(MouseEvent e) {;} }

( ).

""

Java 1.1 , Java 1.1: (, , ;-(). , , . . , - Clear. ActionListener, .

/* <applet code = Scribble3 width=200 height=200>
   </applet>
*/ 
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Scribble3 extends Applet {
int last_x, last_y;
public void init() {
// ,     MouseListener.
this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
last_x = e.getX(); last_y = e.getY();
}
});
// ,      MouseMotionListener.
this.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
Graphics g = getGraphics();
int x = e.getX(), y= e.getY();
g.setColor(Color.black);
g.drawLine(last_x, last_y, x, y);
last_x = x; last_y = y;
}
});
//   Clear.
Button b = new Button("Clear");
// ,     
//   ,    .
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//  
Graphics g = getGraphics();
g.setColor(getBackground());
g.fillRect(0, 0, getSize().width, getSize().height);
}
});
//    .
this.add(b);
} }
Java             3GL - .   4GL -     DB-

, - - , , , , , .




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution