�����:   ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½:




�������
��������
�����
�����


Java
- �������
- ������-�����
- ������
- �������
- �����������
- ������
- IDE
- ������� ��������
- �������

��������� Java
- ����
- �������
- ������
- WAP, WML � ��.

JavaScript
- ������-�����
- �������
- ������

���-���������
- HTML
- CSS
- SSI

�������� ��� ���
�������
�����
������
���������
���� :)




Rambler's Top100

������������� Java programming������ 13-�

������������ ������� ��������!

����������

1. ����������
2. ���� "�� �����"
3. ������ - �����
4. ����������� ���
5. JavaScript

����������

������������� ������� ���������

��� ����� �������� ����� ������ � long, int, short, char � byte, ��������� �������������� ����� ����������, � ������� ������� ����� ��������� � �������������� ��������� ��������� ����� ��������������� ��������. � ������� ��������� ������ ����� ����������. ��������� ������� ���������� �������� � ������ ����� ��� � ��������������� ���������.

��������� ������� ��������� (NOT)
�������� ��������� �������� ���������
~
& ��������� � (AND) &= ��������� � (AND) � �������������
| ��������� ��� (OR) |= ��������� ��� (OR) � �������������
^ ��������� ����������� ��� (XOR) ^= ��������� ����������� ��� (XOR) � �������������
>> ����� ������ >> = ����� ������ � �������������
>>> ����� ������ � ����������� ������ >>>= ����� ������ � ����������� ������ � �������������
<< ����� ����� <<= ����� ����� � �������������

������ ���������, �������������� � ������

� �������, ����������� ����, ��������, ��� ������ �� ���������� ������� ���������� ������������ �� ��������� ���������� ����� ����� ���������. ����������� ����� ������� ������ ������������ ������������� ���� ���������� � ��������� �� ����� Java.

A B OR AND XOR NOT A
0 0 0 0 0 1
1 0 1 0 1 0
0 1 1 0 1 1
1 1 1 1 0 0

class Bitlogic
{ 
 public static void main(String args [])
 { 
  String binary[] = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", 
                                                      "1001", "1010", "1011", "1100", "1101", 
  "1110", "1111" }; 
  int a = 3; // 0+2+1 ��� �������� 0011 
  int b = 6; // 4+2+0 ��� �������� 0110 
  int c = a | b; 
  int d = a & b; 
  int e = a ^ b; 
  int f = (~a & b) | (a & ~b); 
  int g = ~a & 0x0f; 
  System.out.println(" a = " + binary[a]); 
  System.out.println(" b = " + binary[b]); 
  System.out.println(" ab = " + binary[c]); 
  System.out.println(" a&b = " + binary[d]); 
  System.out.println(" a^b = " + binary[e]); 
  System.out.�rintln("~a&b|�^~� = " + binary[f]); 
  System.out.println(" ~a = " + binary[g]); 
 } 
} 

���� �������� ���������, ���������� ��� ���������� ���� ���������:


a = 0011 
b = 0110 
a | b = 0111 
a & b = 0010 
a ^ b = 0101 
~a & b | a & ~b = 0101 
~� = 1100 

������ ����� � ������

�������� << ��������� ����� ����� ���� ����� ������ ������ �������� �� ����� �������, �������� ������ ���������. ��� ���� ����� ����� � ����� �������� ������� �� ������� � ��������, � ��������������� ������ ������� ����������� ������.

�������� >> �������� � ����� Java ����� ������. �� ���������� ��� ���� ������ ������ �������� ������ �� ����� �������, �������� ������ ���������. ����� ���� ������ �������� ����������� �� ����� ������ ������� �����, ��� ��������. ��� ������ ������ ��������������� ������� (�����) ������� ����������� ����� ����������� ���������� ���������� ��������� �������. ����� ��������� �������� ����������� ��������� �������.

� ��������� ��������� �������� �������� ������������� � ������, ���������� ��� ����������������� �������������. �������� �������� - ��������� �������� ���������� �����������, �� ���� ��������� �������� �� �������� 0�0f, ��� ����, ����� �������� ����������� � ���������� ���������� ����� ���� � �������� �������� �� ��������, ���������� ��� �������������� ������� ����������������� ����.


class HexByte
{ 
 static public void main(String args[])
 { 
  char hex[] = { '0', '1, '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f }; 
  byte b = (byte) 0xf1; 
  System.out.println(�b = 0x� + hex[(b >> 4) & 0x0f] + hex[b & 0x0f]); 
 }
} 

���� �������� ��������� ������ ���� ���������:

b = 0xf1 

����������� ����� ������

����� ���������, ����� ��� ������ ������ ���������� ��������� ������� �� �����������, � ��������������� ����� ������� ������ ����������� �� ������.


class ByteUShift
{ 
 static public void main(String args[])
 { 
  char hex[] = { '0', '1�, '2', '3', '4', '5', '6', '7', '8', '9', '�', 'b', '�', 'd', 'e', 'f� }; 
  byte b = (byte) 0xf1; 
  byte c = (byte) (b >> 4); 
  byte d = (byte) (b >> 4); 
  byte e = (byte) ((b & 0xff) >> 4); 
  System.out.println(" b = 0x" + hex(b >> 4) & 0x0f] + hex[b & 0x0f]); 
  System.out.println(� b >> 4 = 0x" + hex[(c >> 4) & 0x0f] + hex[c & 0x0f]); 
  System.out.println(�b >>> 4 = 0x" + hex[(d >> 4) & 0x0f] + hex[d & 0x0f]); 
  System.out.println(�(b & 0xff) >> 4 = 0x" + hex[(e >> 4) & 0x0f] + hex[e & 0x0f]); 
 }
} 

��� ����� ������� ���������� b ����� ���� �� ���������������� ������������ ������������� ������, �� ������������ ����� � ����������������� �������������� 0xf1. ���������� � ������������� ��������� ��������� ������ b ������ �� 4 �������. ��� � ���������, ���������� ��������� ������� �������� � ����, ��� 0xf1 ������������ � 0xff. ����� � ���������� d ��������� ��������� ������������ ������ b ������ �� 4 �������. ����� ���� �� �������, ��� � ���������� d �������� 0x0f, ������ �� ���� �� ����� �������� 0xff. ��� � ��������� ���������� ��������� �������, ������������ ��� �������������� ��������� ���� ���������� b �� int ����� ��������� ������ ������. �������, � ��������� ��� ���������� � ��� ������� �������� ��������� ���������� � �������� 0x0f. ��� ����� ��� �������� ����� ������� ������ ��������� �������� �������� ���������� b �� ����� 0xff, ������� ����� ������� ������� �������, ����������� ��� �������������� ��������� ����. �������� ��������, ��� ��� ���� ��� ��� ������������� ������������ ����������� ����� ������, ��������� �� ����� ��������� ��������� ���� ����� �������� AND.


b = 0xf1 
b >> 4 = 0xff 
b >>> 4 = 0xff 
b & 0xff) >> 4 = 0x0f 

������� ��������� ������������

��� ��, ��� � � ������ �������������� ����������, � ���� �������� ������� ���������� ���� ����������� �����, ����������� ������������� ����������� ��������� �������� ������ ��������. � ��������� ������� ��������� ��������� ����� ����������, � �������� � ������� ����������, ��������� ����, ����������� ��������� ��������.


class OpBitEquals { 
public static void main(String args[]) { 
int a = 1; 
int b = 2; 
int � = 3; 
a |= 4; 
b >>= 1; 
� <<= 1; 
� ^= �; 
System.out.println("a = " + a); 
System.out.println("b = " + b); 
System.out.println("c = " + c); 
} } 

���������� ���������� ��������� ������:



� = 3 
b = 1 
� = 6 

��������� ���������

��� ����, ����� ����� ���� ���������� ��� ��������, � Java ������� ����� ����������, ����������� ��������� � ���������. ������ ����� ���������� �������� � �������.

�������� ���������
== �����
!= �� �����
> ������
< ������
>= ������ ��� �����
<= ������ ��� �����

�������� ����� �����, ������� ����� � ������������ �����, ���­ï¿½ï¿½ï¿½ï¿½, ���������� �������� � ������, ����� ����������, ��������� �������� �������� �� ��������� == � ����������� !=. �������� �������� � � ����� Java, ��� ��, ��� � � � C++ �������� �� ��������� ������������ ������������������� (==). ���� ���� (=) � ��� �������� ������������.

� ��������� ������ �� ���������� ������ ���������� ���������.

���� "�� �����"

������ �� Java-���������� (�����������)

����� Printer

����� Printer ������ ���������� �� ������. �� ����� ���� ����� ���������, ������� �� ����� �������� �� �����, � �� ������� ����� ��� �� ����. �� ����� ��������� ������ printer ����� ������������ ��� �� ������ Canvas. ��� �������, ������ ������ Canvas ����� ������������ � ������������ �������: 1 x 1 ������. ��� ��� �� ���������� �������� ���� ������ � ������ Graphics, ������������ ������ ������� ������� canvas, � ��� ���������� ����������� ������� ����� ���������������� ��������� �������� (����������� ��� ��������������� �����������) ����� ����������� ������� Canvas � ������ ������ paint.

�������� ������ Printer

����, ������� ����������, ��� �� �����, ����� ������ ����� ��������. �� ������ �� ����� ����������� �������� ������� ������, ������ � ��������� �������, �������� ������, �������� �������, ������� ������������ � ������� �������� ���������. ����� ����, ���� �� ������� ����� ����������� ���������������� ��������� ������, ���������� �� ������.

� ������, �� ������ ��, ����� ������ Printer �������� ������ �������, � �������, ����������� ������ � �����, ��� ���� �������, ���� ���� �� ����� �������� ��� ���������������. ����� ������������ ������ ������������, ���� ������ ������ ��������������� �������� � ������� Printer ��������� ���������� ��������, �� ��� ��� ���� ������ �������� �� ����� ���������; � ����� ����������� �� ��� �����. �� �� ���������� ������������� � � ����������� ���������������� ��������� ��������.

������ ������ Printer

��� ����� ����� ����������� �������� � ���������� �� ����� ������. ������� ��� ����� ��� ����� print, ��� � ����� println:


printer = new Printer(.. .);
printer.print("Hello ");    
printer.println(" printer); 

����� ����, �� ������ �� �������� ����� ������:


printer.setFont(font);

� ����� ����������� ������������ �� �������� ���������:


printer.tab(35);   

����� ����, ��� ����� ���������� �� ����� ��������, �� �������� ����� ������ ��� ������ ��������:


printer.newPage(); 

�, ������� ��, ��� �����, ����� ������� ������ ���������� ���, ��� �� ��� ���������:


printer.endJob();

������ ������� ����������, ��� �� ����� ����������� ��� ������ ���, ����� ����� ���� ������� ��������� ������� ������ ������� printer � "����������� ��", ����� �� ������� �� �� ������ ��� �������������� ������������� �� ������.

�����, ���� �� ����� ���������� ��������� ���� ������ printer, �� ������ �� ����� ����������� ������������ ����������� ����� � �����������.

������ ��������������� ��������

������ ���, ����� ��� ����� ��������� ������������� ���������� ��������, ������, ��� �������� � ������, - ��� ������������ ����� Vector (��������� � ������ Vector (/java/class/Vector.html).

�� ����� ������� �� ����� ��������� � ��� �� ����� ���������, ������� �� ��� ����� ���������� ���������? �����������, ��� � ��� ���� ������� String, Font � NewLine, ������� �������� � ������ Vector.

���� �� ��� ����� ���� �� �����������, ��� �� �������� ���������� ��� �������, � ����� ������� ��� ����� ���� ��������������� �����:


for (int i =0; i<objects.size; i++)
{ 
 obj = objects.elementAt(i);
 if (obj instanceof String)print((String)obj);
 if (obj instanceof Font) 
				//etc.. 

��� �� ������ ����� �������, �� ����� �������� ������������ ����������������, ��� ��������-����������������. ������ ������������ ������� if-������, ������� � ��� �������, �������, ���������� ������� ����� ��������, ������� ���� �����, ��� ���� ����������� ��� ����������.

����� printerObject

���� �� ����� ����� ����������� ���������� ������ ������ ��������������� ��� �������, �� ������ ������� ����� ��� ���������������� �������, � ������� ���� ����� draw. �� �������� ���, �� ����������� ������ ������� Graphics ����� �������� � � ����� ��������� ������ ���������:


abstract class printerObject
{
 abstract void draw(Graphics g, Point p);
}

����� �� ��������� ���������� ������� ������� ������ �� ������������ ������, ������ �� ������� ����� ��������� ����� draw ��-�������. ������������ ������� ������ ����������� � ���, ��� ��� ������ �� ����� ����� ��������� ��� �������: ������ ������ (String, Font ��� NewLine) ��� ����� ��������������� ��� ����� draw.

����� ����� �� ����� ����������� ���� ������ �������� ����� ����������� �� ������� � ������ ������ draw ���������������� printObject.


public void print(Graphics g)
{
 printerObject p;
 f.setFont(fnt); 			     //������ �������� � ����� ������ 
 for (int i = 0; i < objects.size(); i ++)
 {
  p = (printerObject)objects.elementAt(i);
  p.draw(g, pt);
 }
} 

����� ��������, ��� ��� ��������� ����� �������� �� ������ Vector � �������������� �� � ���� printerObjects, ��� �� ����������� �����, ����� ������ �� � ������ ������ ��������: � ������� �� ��� ���� ���� ����� draw.

� ��������� ������ �� ���������� ����������� ��� ������ printerObject � �������� ������� ������ ������ Printer.

������ - �����

������:
� ���� ������: �������� �� ���������� ������� combobox?
Vladimir Mishkin

�����:
�� �����. �������� � ��� ������� combobox:


JComboBox c = new JComboBox();

�� ��� �������� � ������ ��� ����� ��������:


c.showPopup();

������:
��� �������� ������� � ������� ������� "open" � AWT ������ FileDialog?
Kirill

�����:
����� ��� �������� �������? ������ ����� �������� ������� (���� ������ ������ ������� ��� ������ ��� �������) ��������� ��������� ������:

  1. ��������� �������� fd.getFile() ����� ��������� �������.
  2. �������� ������.
  3. �������� ������ (�������� ������ "�������" ��� "������").
  4. ���������: ���� ������� �������� fd.getFile() ������������ ����������� �� ���� ������ ������ "������" , ���� �� �������� ���������� �� ���� ������ ������ "�������".

������ ������������� FileDialog �������� � ������� ����������� ���

������:
����� Java-������� � Windows ��������� � ������� �� ����� �������� �� ������� ��������� �� ���. ������� ����� ������ �������� ������ *.class � ����� Java... � Windows, �� ������������ ����� ������ �� �����. ��� ����� ���������� ��� ������ � ������ � ������ ���?
Alex

�����:
������������� ������� ������ ���������, ��� ������� � ������������� ��������. ���������� ������� �� ����������� Java ������ ��� ������������� �������� � �������� ���������� ������ ���� �������� jar-������ ����������� ��� ������. �� � ���� ����� ����� �� ���������, ���� ������ �������� ����������� ������� ��������.

������:
����� �������� Graphics �� Image, �� getGraphics() ����������� ����������. ��� ��� -


Image img; 
Graphics offscreen; 
img = createImage(100, 100); 
offscreen = img.getGraphics(); //????????????? 

Alex

�����:
��� ���� ����������, ������ �� �� �������� ��� ������������� �����������, �� ���� �� ����� �������� � ����� ������ ����� ������������ �������.

������:
�� ����� �� �� ���������� � ����������� � ����� ������: ��� ����� ��������, ����� ����� ������������ ��� ������ � ORACLE 8.15.

�����:
������������� ����� Sun ���������� ������������������ ����� java.sql, ������� ��������� Java-��������� ������������ ������ � ������� ���������� ������������ ������ ������(�����). � ��������� ������ JDBC (Java Database Connectivity) ����� ����������� � ����������� ���� ������ � ����������������� � ���, ��������� ���������� ���� ���������� ������ ������ - SQL. ����������� JDBC SQL-��� ��������� �������� ���� ������, �������, � ���� �������, ����������� ��� � ������� ���������� �����. ��� ���������� "����������� � ���� ������ � ������� JDBC".

����������� ���

������ ������������� FileDialog

import java.awt.*;
import java.awt.event.*;
class RotateImg extends Frame
{
 Panel panel = new Panel();
 FileDialog fd =new FileDialog(this,"�������� �����",FileDialog.LOAD);
 public RotateImg()
 {
  addWindowListener(new WindowAdapter()
  {
   public void windowClosing(WindowEvent e)
   {
	dispose();
	System.exit(0);
   }
  });
  Button b =new Button(" ������� ���� ");
  b.addMouseListener(new java.awt.event.MouseAdapter()
  {
   public void mouseClicked(MouseEvent e)
   {
    String tempStr = fd.getFile();
    fd.show();
    if(fd.getFile() != tempStr) setTitle("������ ����: "+fd.getFile());  	
    else setTitle("�������� ��������!!!");  	
   }
  });
  this.add(panel);
  panel.add(b);
  
 }
 public static void main(String args[])
 {
  System.out.println("Starting RotateImg...");
  RotateImg mainFrame = new RotateImg();
  mainFrame.setSize(400, 400);
  mainFrame.setTitle("������ ������ FileDialog");
  mainFrame.setVisible(true);
 }
}

JavaScript

������:
� ���� ������ ������ �� ��� ������: ���� �� � ������� �����, ������� ��������� ������������ midi ��� wav �� �� ����, � �� �������? ��� ���� �� ��� ������ �����, ������� ������� play(file_name) ����� ��� ������.
������.

�����:
��� ������� ����� �������:


<html><script language="JavaScript">
<!--
function Music()
{
document.write('<embed src="1.wav" hidden="true" autostart="true" loop="false" />');
}
Music()
//--></script></html>

������� Music() ��������� �� ������� ��� �������.

������:
���������� �������� ����� ����� (��� �������), ����� ��� ����� "��" ������ ��� ���������� ����� ����� � ���������� ������� (���), ���������� ������� + ����������� �����.
���������

�����:
��� ���������� ����� �����: /javascript/examples/loadFormFIO.html.






������� ���������� �� E-mail [email protected] � �������� "������ �� Java".

��� �������� � �����������.
���� �����.

����������� �� ��� �������� ����� ��� /subs/subs.html


���� �����, ����� ������
"Java 2"
���������>>
��������>>


�. �. ���������
"�����������: Java. �����������"
���������>>
��������>>

����� � ��� �� �� ����� ���� ������ ������� ���.


[an error occurred while processing this directive]



Apache Struts 2.0.11
Apache MyFaces Trinidad Core 1.2.3.
Sun ��������� ��������� ���������� � Java ME �� Java SE
��������� �����!



������ 29-�
������ 28-�
������ 27-�
������ 26-�
������ 25-�
������ 24-�
������ 23-�
������ 22-�
������ 21-�
������ 20-�
������ 19-�
������ 18-�
������ 17-�
������ 16-�
������ 15-�
������ 14-�
������ 13-�
������ 12-�
������ 11-�
������ 10-�
������ 9-�
������ 8-�
������ 7-�
������ 6-�
������ 5-�
������ 4-�
������ 3-�
������ 2-�
������ 1-�