Java             3GL - .   4GL -     DB-

JAVA

Java

, , , , , . . , , . , , - . Java Abstraction Window Toolkit (AWT) .

Graphics Fonts 15. 18 . AWT, .

Component , - , , , / , , , , ( 10 ). Component.

Container

Container Component, , , . Container LayoutManager, .

Panel

Panel Container. , . Panel , . add Panel . , - , move, resize reshape Component.

Panel Applet. , Applet, paint update Panel. , Panel, Canvas, Panel Applet.

Canvas

Canvas , . Canvas . , , , .

Canvas GrayCanvas, . , .

/* <applet code = PanelDemo
width=300
height=300>
</applet>
*/
import java.awt.*;
import java.applet.*;
class GrayCanvas extends Canvas { 
Color gray;
public GrayCanvas(float g) { 
gray = new Color(g, g, g);
}
public void paint(Graphics g) { 
Dimension size = size();
g.setColor(gray);
g.fillRect(0, 0, size.width, size.height);
g.setColor(Color.black);
g.drawRect(0, 0, size.width-1, size.height-1);
} }
public class PanelDemo extends Applet {
static final int n = 4;
public void init() { 
setLayout(null);
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++) {
float g = (i * n + j) / (float) (n * n);
Canvas  = new GrayCanvas(g);
add(c);
c.resize(width / n, height / n);
c.move(i * width / n, j * height / n);
} 
}
} }

Canvas , size, Dimension. , Canvas resize move. , . setLayout(null).

Label

Label , , String , . , , Component. getFont/setFont getForeground/setForeground. setText. Label LEFT, RIGHT CENTER. , , .

/* <applet code = LabelDemo width=100 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class LabelDemo extends Applet { 
public void init() {
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
Label left = new Label("Left", Label.LEFT);
Label right = new Label("Right", Label.RIGHT);
Label center = new Label("Center", Label.CENTER);
add(left);
add(right);
add(center);
left.reshape(0, 0, width, height / 3);
right.reshape(0, height / 3, width, height / 3);
center.reshape(0, 2 * height / 3, width, height / 3);
} }

, Label, reshape. , 1/3 .

Button

- , Label ( . , , . , .

/* <applet code = ButtonDemo width=100 height=100>
</applet>

*/
import java.awt.*;
import java.applet.*;
public class ButtonDemo extends Applet {
public void init() {
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
Button yes = new Button("Yes");
Button no = new Button("No");
Button maybe = new Button("Undecided");
add(yes);
add(no);
add(maybe);
yes.reshape(0, 0, width, height / 3);
no.reshape(0, height / 3, width, height / 3);
maybe.reshape(0, 2 * height / 3, width, height / 3);
} }

Checkbox

Checkbox . Checkbox , . getState setState. Checkbox, .

/* <applet code = CheckBoxDemo width=120 height=100>
</applet>
*/
import java.awt.*;
import java.applet.*;
public class CheckboxDemo extends Applet { 
public void init() { 
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
Checkbox win95 = new Checkbox("Windows 95/98", null, true);
Checkbox Solaris = new Checkbox("Solaris 2.5");
Checkbox mac = new Checkbox("MacOS 7.5");
add(win95);
add(solaris);
add(mac);
win95.reshape(0, 0, width, height / 3);
Solaris.reshape(0, height / 3, width, height / 3);
mac.reshape(0, 2 * height / 3, width, height / 3);
} }

CheckboxGroup

Checkbox ( null) Checkbox. CheckboxGroup, Checkbox, ( ). , , Checkbox getCheckboxGroup setCheckboxGroup. getCurrent setCurrent Checkbox. , , .

/* <applet code = CheckboxGroupDemo width=120 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class CheckboxGroupDemo extends Applet {
public void init() {
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
CheckboxGroup g = new CheckboxGroup();
Checkbox win95 = new Checkbox("Windows 95/98", g, true);
Checkbox solaris = new Checkbox("Solaris 2.5", g, false);
Checkbox mac = new Checkbox("MacOS 7.5", g, false);
add(win95);
add(solaris);
add(mac);
win95.reshape(0, 0, width, height / 3);
solaris. reshape(0, height / 3, width, height / 3);
mac.reshape(0, 2 * height / 3, width, height / 3);
} }

, , .

Choice

Choice () ( ComboBox Windows). Choice , , , , . , , . , Choice. countItems . , , select, ( ), , . , getSelectedItem getSelectedIndex , , - . , Choice.

/* <applet code = ChoiceDemo width=200 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class ChoiceDemo extends Applet { 
public void init() { 
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
Choice os = new Choice();
Choice browser = new Choice();
os.addItem("Windows 95/98");
os.addItem("Solaris 2.5");
os.addItem(MacOS 7.5");
browser.addItem("Netscape Navigator 3.0");
browser.addItem("Netscape Communicator 4.5");
browser.addItem(Internet Explorer 3.0");
browser.addItem("Mosaic 3.0");
browser.addItem("Lynx 2.4");
browser.select("Netscape Communicator 4.5");
add(os);
add(browser);
os.reshape(0, 0, width, height / 2);
browser.reshape(0, height / 2, width, height / 2);
} }

List

List ( ListBox Windows). , , .

/* <applet code = ListDemo width=200 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class ListDemo extends Applet { 
public void init() { setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
List os = new List(0, true);
List browser = new List(0, false);
os.addItem("Windows 95/98");
os.addItem("Solaris 2.5");
os.addItem("MacOS 7.5");
browser.addItem("Netscape Navigator 3.0");
browser.addItem("Netscape Communicator 4.5");
browser.addItem("lnternet Explorer 4.0");
browser.addItem("Mosaic 3.0");
browser.addItem("Lynx 2.4");
browser.select(1);
add(os);
add(browser);
os.reshape(0, 0, width, height / 2);
browser.reshape(0, height / 2, width, height / 2);
} }

Scrollbar

Scrollbar ( ) . , , . , , , . , , .

Scrollbar VERTICAL HORIZONTAL. , , . getValue setValue. getMinimum getMaximum, . , , .

/* <applet code = ScrollbarDemo width=200 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class ScrollbarDemo extends Applet { 
public void init() { 
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer. parseInt(getParameter("height"));
Scrollbar hs = new Scrollbar(Scrollbar.HORIZONTAL, 50, width / 10, 0, 100);
Scrollbar vs = new Scrollbar(Scrollbar.VERTICAL, 50, height / 2, 0, 100);
add(hs);
add(vs);
int thickness = 16;
hs.reshape(0, height - thickness, width - thickness, thickness);
vs.reshape(width - thickness, 0, thickness, height - thickness);
} }

TextField

TextField . . TextField setEditable, isEditable , . getText setText. select , , . selectAll.

setEchoChar , . , TextField , echoCharIsSet, , -, getEchoChar. , .

/* <applet code = TextFieldDemo width=200 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class TextFieldDemo extends Applet { 
public void init() {
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
Label namep = new Label("Name : ", Label.RIGHT);
Label passp = new Label("Password : ", Label.RIGHT);
TextField name = new Text Field(8);
TextField pass = new TextField(8);
pass.setEchoChar('*');
add(namep);
add(name);
add(passp);
add(pass);
int space = 25;
int w1 = width / 3;
namep.setBounds(0, (height - space) / 2, w1, space);
name.setBounds(w1, (height - space) / 2, w1, space);
passp.setBounds(0, (height + space) / 2, w1, space);
pass.setBounds(w1, (height + space) / 2, w1, space);
} }

, JDK 1.1 reshape setBounds TextFieldDemo.html. , Deprecated API, ( Java 1.2, , , ).

TextArea

. AWT , TextArea. TextArea String . , , . , TextArea: appendText String ; insertText ; rplaceText - , , -. , TextArea .

/* <applet code = TextAreaDemo width=200 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class TextAreaDemo extends Applet { 
public void init() { 
setLayout(null);
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
String val = "There are two ways of constructing " + 
"a software design.\n" + 
"One way is to make it so simple\n" + 
"that there are obviously no deficiencies.\n" + 
"And the other way is to make it so complicated\n" +
"that there are no obvious deficiencies.\n\n" + 
C.A.R. Hoare\n\n" +
"There's an old story about the person who wished\n" +
"his computer were as easy to use as his telephone. \n" +
"That wish has come true,\n" +
"since I no longer know how to use my telephone. \n\n" +
Bjarne Stroustrup, AT&T (inventor of C++)";
TextArea text = new TextArea(val, 80, 40);
add(text);
text.setBounds(0, 0, width, height);
}}

Layout

, , . setLayout(null). . AWT (layout managers).

LayoutManager

, LayoutManager, , String. , Panel, . Panel, minimumLayoutSize preferredLayoutSize. , , preferredSize minimumSize. , . , .

Java , .

FlowLayout

FlowLayout , , , . , . , , . FlowLayout. , , LEFT, RIGHT CENTER . CENTER, 5 .

, Panel Label. Panel FlowLayout RIGHT.

/* <applet code = FlowLayoutDemo width=200 height=100>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
import java.util.*;
public class FlowLayoutDemo extends Applet {
public void init() {
setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 3));
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
String val = "Data is not information " +
"is not knowledge is not wisdom.";
StringTokenizer st = new StringTokenizer(val);
while (st.hasMoreTokens()) {
add(new Button(st.nextToken()));
}
} }

FlowLayoutDemo1.html, FlowLayoutDemo2.html , , Label , ( a appletViewer).

BorderLayout

BorderLayout , , , , . -: String.North, String.South, String.East String.West , a Center . BorderLayout .

/* <applet code = BorderLayoutDemo width=300 height=200>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
import java.util.*;
public class BorderLayoutDemo extends Applet { 
public void init() {
setLayout(new BorderLayout());
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
add("North", new Button("This is across the top"));
add("South", new Label("The footer message might go here"));
add("East", new Button("Left"));
add("West", new Button("Right"));
String msg = "The reasonable man adapts " +
"himself to the world;\n" + 
"the unreasonable one persists in " +
"trying to adapt the world to himself.\n" +
"Therefore all progress depends " +
"on the unreasonable rnan.\n\n" +
George Bernard Shaw\n\n";
add("Center", new TextArea(msg));
} }

GridLayout

GridLayout . . , GridLayout 44, 15 16 , . , , , .

/* <applet code = GridLayoutDemo width=200 height=200>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class GridLayoutDemo extends Applet { 
static final int n = 4;
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));
}
}
} }

Insets

Insets , Panel , , . , Panel, Insets , Insets , , , .

public Insets insets() {
return new Insets(10, 10, 10, 10);
}

CardLayout

CardLayout . , , . , . , , .

Window

Window Panel , . Window, Frame.

Frame

Frame , . Frame , . , / Frame, show hide. , Frame TextArea.

/* <applet code = FrameDemo width=200 height=200>
</applet>
*/ 
import java.awt.*;
import java.applet.*;
public class FrameDemo extends Applet { 
public void init() {
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
String val = "There are two ways of constructing " +
"a software design.\n" +
"One way is to make it so simple\n" +
"that there are obviously no deficiencies.\n" +
"And the other way is to make it so complicated" +
"that there are no obvious deficiencies.\n\n" +
C.A.R. Hoare\n\n";
TextArea text = new TextArea(val, 80, 40);
Frame f = new Frame("Demo Frame");
f.setSize(width, height);
f.add("Center", text);
f.show();
} }

. MenuBar Menu. , , MenuItem. Menu MenuItem, Menu , . , .

/* <applet code = MenuDemo width=200 height=200>
</applet>
*/ 
import java.awt.*;
import java.applet. *;
public class MenuDemo extends Applet { 
public void init() {
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
Frame f = new Frame("Demo Frame");
f.setSize(width, height);
MenuBar mbar = new MenuBar();
f.setMenuBar(mbar);
Menu file = new Menu("File");
file.add(new MenuItem("New... "));
file.add(new MenuItem("0pen..."));
file.add(new MenuItem("Close"));
file.add(new MenuItem("-"));
file.add(new MenuItem("Quit..."));
mbar.add(file);
Menu edit = new Menu("Edit");
edit.add(new MenuItem("Cut"));
edit.add(new MenuItem("Copy"));
edit.add(new Menultem("Paste"));
edit.add(new MenuItem("-"));
Menu sub = new Menu("Special");
sub.add(new MenuItem("First"));
sub.add(new MenuItem("Second"));
sub.add(new MenuItem("Third"));
edit.add(sub);
edit.add(new CheckBoxMenuItem("Debug"));
edit.add(new CheckBoxMenuItem("Testing"));
mbar.add(edit);
f.show();
} }

AWT

AWT , - , . AWT , , AWT- , . AWT Swing, Java Foundation Classes (Netscape), Application Foundation Classes (Microsoft).

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