java:Applet²¼¾ÖÎÊÌâ,ÈçºÎÌí¼Ó°´Å¥£¬±êÇ©ÎÊÌâ×ܽá
½ñÌìѧϰÁËapplet²¼¾ÖÎÊÌ⣺
°´Å¥¡¢±êÇ©ÊÇÔõÑù¼ÓÈëµ½applet³ÌÐò(ÈÝÆ÷)µ±ÖÐÈ¥µÄÄØ£¿
ÐèÒªÓõ½²¼¾ÖÈÝÆ÷¹ÜÀíÆ÷(LayoutManager)£ºËüÓÃÓÚÐÖúÈÝÆ÷È·¶¨¼ÓÈëµÄ×é¼þ(°´Å¥µÈ)Ó¦¸Ã·ÅÖõÄλÖÃ
awtÌṩÁË4Öг£ÓõIJ¼¾ÖÈÝÆ÷¹ÜÀíÆ÷
>>FlowLayout
>>BorderLayout
>>GridLayout
>>CardLayout
appletĬÈÏʹÓÃFlowLayout,appletʹÓÃÈÝÆ÷¹ÜÀíÆ÷µÄ·½·¨ÈçÏ£º
setLayout (new BorderLayout)
setLayout()·½·¨ÊÇappletÀà¼Ì³ÐContainerÀàÖеķ½·¨¶øÀ´£¬Òò´ËÔÚapplet³ÌÐòÖпÉÒÔÖ±½Óµ÷ÓÃ
applet¼ÓÈë°´Å¥Ò»¶¨ÐèÒªÉÏÃæµÄÈÝÆ÷¹ÜÀíÆ÷ô£¿
²»Ò»¶¨£¬¿ÉÒÔÏÈ setLayout(null); È»ºó×Ô¼ºÈ·¶¨×é¼þ·ÅÖõÄϸ½Ú£¬´úÂëÂé·³¡£
Èç¹ûÄã²»Óò¼¾Ö¹ÜÀíÆ÷£¨JframeÖеÄÓ÷¨£©£º
JButton b1 = new JButton("hello");
getContentPane().add(b1);
b1.setLocation(100,10);
ÒÔÏÂÊÇÈÝÆ÷¹ÜÀíÆ÷³£ÓõÄ4ÖÖ²¼¾Öд·¨
=================================================
applet ʹÓà FlowLayout ²¼¾Ö£º
Ö¸¶¨²¼¾Ö:setLayout(new FlowLayout())
¼ÓÈë×é¼þ£ºadd(×é¼þʵÀý)
×÷ÓãºÓÉ×óµ½ÓÒ£¬ÓÉÉϵ½ÏÂÒÀ´Î·ÅÖÃ×é¼þ
¼ÓÈë×é¼þʹÓÃappletÀà¼Ì³ÐContainerÀàÖеķ½·¨³ÉÔ±add();
=================================================
import java.awt.*;
import java.applet.*;
public class UseFlowLayout extends Applet{
public void init()
{
setLayout(new FlowLayout()); //ÒòΪÊÇĬÈϹÜÀíÆ÷£¬¿ÉÒÔÊ¡ÂÔ
//setLayout()·½·¨ÊÇappletÀà¼Ì³ÐContainerÀàÖеķ½·¨¶øÀ´£¬Òò´ËÔÚapplet³ÌÐòÖпÉÒÔÖ±½Óµ÷ÓÃ
for(int i = 0; i<5;i++){
add(new Button("°´Å¥" + i )); //¼ÓÈë5¸ö°´Å¥
//appletÀà¼Ì³ÐContainerÀàÖеķ½·¨³ÉÔ±add();
}
}
}
==================================================
appletʹÓÃBorderLayout();
Ö¸¶¨²¼¾Ö£ºsetLayout(new BorderLayout());
¼ÓÈë×é¼þ£ºadd(×é¼þʵÀý,λÖó£Á¿)
×÷Ó㺴ËÖÖ²¼¾Ö½«ÈÝÆ÷»®·ÖΪ5¸öÇøÓò£¬·Ö±ðÊÇÉÏ¡¢Ï¡¢×ó¡¢ÓÒ¡¢ÖÐ
[λÖó£Á¿]Ö¸¶¨ÁË×é¼þ½«Òª·ÅÖõ
Ïà¹ØÎĵµ£º
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author troy(J2EE)
* @version 1.0
*/
public class Test {
public static void main(String[] args) throws Exception {
DateFormat df = DateFormat.getDateInstance();
&n ......
1.ÔÚÄã¾õµÃÓдíµÄµØ·½ÉèÖöϵã
2.µã»÷¼×¿Ç³æÒ»ÑùµÄ°´Å¥ÏÂÃæµÄ×Ó°´Å¥£¬Ò²ÊǼ׿dzæÒ»ÑùµÄ£¬½ÐDebug
3.ÔËÐгÌÐò£¬µ±³ÌÐòÔËÐе½¸Õ²ÅÉèÖöϵãµÄλÖþͻáÍ£ÏÂÀ´£¬²¢ÇÒÄÇÐдúÂëµ×É«»á¸ßÁÁÏÔʾ¡£
4.½Ó×ÅÄãÔÚÈçϽçÃæÄã¿ÉÒÔ¿´µ½ÄãÏëÒªµÄÐÅÏ¢
5.ÔÚVariablesÀïÃæ¿ÉÒԲ鿴ËùÓбäÁ¿µÄÖµ£¬±ÈÈç¸Õ²ÅÉèÖõĶϵãÀïÃæµÄstrClassNameµÄÖµ¾Í ......
»ñµÃmysqlºÍoracleÁ´½ÓµÄÀà
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB {
private static final String MYSQL = "jdbc:mysql://";
private static final String ORACLE = "jdbc:oracle:thin:@";
private ConnectD ......
eclipseÑ¡Ò»¸ö±äÁ¿ºó£¬Õâ¸öÀàÀïµÄ¸Ã±äÁ¿²»±äÉ«ÎÊÌâ½â¾ö£º
alt + shift + o
/**
* дÈëÈÕÖ¾
* filePath ÈÕÖ¾ÎļþµÄ·¾¶
* code ҪдÈëÈÕÖ¾ÎļþµÄÄÚÈÝ
*/
public
static
boolean
print(String filePath,String code) {
try
{
File tofile
=
new
File(filePath);
......
package stone;
public class PrimerNumber {
public static void main(String[] args) {
int MAX_NUMBER = 100;
boolean[] notPrimer= new boolean[MAX_NUMBER];
for(int i=2;i<=MAX_NUMBER;i++){
if(!notPrimer[i-1]){
for(int j=2*i;j<=MAX_NUMBER;j++){
if(j%i==0) notPrimer[j-1]=tr ......