Java Swing½Ì³Ì(»ù´¡)
´´½¨Ò»¸öJFrame
ÏÂÃæÓüòµ¥µÄʵÀýÑÝʾÁËJava Swing´´½¨Ò»¸öÄÜÊäÈëÄÚÈݵĴ°¿Ú
public class frameTest(){
public static void Main(String args[]){
//´´½¨JFrame¶ÔÏó£¬JFrameÓÃÀ´ÔÚÆÁÄ»ÉÏÏÔʾһ¸öWindows´°¿Ú¡£
JFrame frame = new JFrame("µÚÒ»¸öJFrame");
// ½¨Á¢Ò»¸öÎı¾ÊäÈëÓò¶ÔÏó£¬ÓÉÓÚÎı¾ÊäÈëÓòÊÇJComponentµÄ×ÓÀ࣬¿ÉÒÔ²ÉÓÃÒÔ
// Ï·½·¨¶¨Òå¡£
JComponent comp = new JTextArea();
// ½«ÉÏÃ潨Á¢µÄÎı¾ÊäÈëÓò¼ÓÈëµ½frame¶ÔÏó
// ĬÈÏÇé¿öÏ£¬frameµÄÄÚÈÝÃæ°å£¨ÈÝÆ÷£©²ÉÓÃBorderLayout²¼¾Ö£¬
// ÕâÀïÊǽ«Îı¾ÊäÈëÓò·ÅÈëBorderLayout²¼¾ÖµÄCenter²¿Î»¡£
// ÓйØBorderLayout²¼¾ÖµÄÄÚÈÝ£¬Çë²éÔÄ
// http://gyfinjava.blog.com.cn/archives/2007/2161340.shtml
frame.getContentPane().add(comp, BorderLayout.CENTER);
// ÉèÖÃÆä¸ß¶ÈºÍ¿í¶È·Ö±ðΪ£º288ÏñËغÍ188ÏñËØ
frame.setSize(288,188);
// ÏÔʾ¸ÃFrame
frame.setVisible(true);
}
}
JFrameµÄÔ¤¶¨Ò嶯×÷ʼþ
ÔÚJava Swing½Ì³Ì1ÖеÄMain·½·¨ÖмÓÈëÒÔÏ´úÂ룺
//µ±Óû§Ñ¡Ôñ´°¿ÚµÄÍ˳ö°´Å¥£¨´°¿ÚÓÒÉϽǵģأ©£¬
//»òÑ¡Ôñ´°Ì幦Äܲ˵¥µÄÍƳöÏîʱµÄ¶¯×÷
//ÏÂÐдúÂë¿ÉÒÔʹµ¥»÷Í˳ö°´Å¥Ê±£¬Í˳ö¸ÃJFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//ÏÂÐдúÂë¿ÉÒÔʹJFrameµÄÍ˳ö°´Å¥Ê§Ð§
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
´´½¨Ã»Îޱ߿òµÄFrame(Window)
¸ÃʵÀýÑÝʾÁËÔõÑù´´½¨Ò»¸öûÓб߿òµÄFrame(Window)¡£Èç¹ûÒª´´½¨
²»ÏÔʾ±ß¿òµÄFrame(Window)£¬ÔòÍƼöʹÓÃJWindow¡£
import javax.swing.JWindow;
public class JWindowTest {
public static void main(String[] args){
//´´½¨JWindows¶ÔÏó
JWindow window = new JWindow();
// ÕâÀһÑù¿ÉÒÔͨ¹ý½Ì³ÌgetContentPane().add()·½·¨Îª¸ÃJWindowÔö¼Ó×é¼þ
//window.getContentPane().add(JCompon
Ïà¹ØÎĵµ£º
ÏÂÃæµÄ·½·¨Òâͼȷ¶¨ËüÄÇΨһµÄ²ÎÊýÊÇ·ñÊÇÒ»¸öÆæÊý¡£Õâ¸ö·½·¨Äܹ»ÕýÈ·ÔËתÂð£¿
public static boolean isOdd(int i){
return i % 2 == 1;
}
ÆæÊý¿ÉÒÔ±»¶¨ÒåΪ±»2Õû³ýÓàÊýΪ1µÄÕûÊý¡£±í´ïʽ i % 2 ¼ÆËãµÄÊÇ i Õû³ý 2 ʱËù²úÉúµÄÓàÊý£¬Òò´Ë¿´ÆðÀ´Õâ¸ö³ÌÐòÓ¦¸ÃÄܹ»ÕýÈ·ÔËת¡£Òź¶µÄÊÇ£¬Ëü²»ÄÜ£»ËüÔÚËÄ·ÖÖ®Ò»µÄʱ¼äÀï·µ»Øµ ......
1. »·¾³±äÁ¿µÄÅäÖãºpathºÍclasspathÖ¸Ïòjava/binĿ¼Ï£»
2. javaÓïÑÔµÄÌص㣺¿ÉÒÆÖ²£¬ÃæÏò¶ÔÏ󣬷ֲ¼ÐÔ£¬½¡×³ÐÔ£¬°²È«ÐÔ£¬¼òµ¥ÐÔ£¬¸ßÐÔÄÜ£¬¶àỊ̈߳¬¶¯Ì¬ÐÔ¡£
3. Êý¾ÝÀàÐÍ£º
ÕûÐÍ£º×Ö½ÚÐÍ£¨byte 1×Ö½Ú£© ¶ÌÕûÐÍ£¨short 2×Ö½Ú£© »ù±¾ÐÍ£¨int 4×Ö½Ú£© ³¤ÕûÐÍ£¨long 8×Ö½Ú£©£»
¸¡µãÐÍ£ºµ¥¾«¶È¸ ......
Java»ù´¡·½Ãæ:
1¡¢×÷ÓÃÓòpublic,private,protected,ÒÔ¼°²»Ð´Ê±µÄÇø±ð
´ð£ºÇø±ðÈçÏ£º
×÷ÓÃÓò µ±Ç°Àà ͬһpackage ×ÓËïÀà ÆäËûpackage
public& ......
class Tank{
int level;
}
public class Assignment {
public static void main(String[] args) {
Tank t1 = new Tank();
Tank t2 = new Tank();
t1.level= 9;
t2.level= 47;
System.out.println("1:t1.l ......
import java.io.File;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;
import java.text.SimpleDateFormat;
public class FileViewer {
File myDir;
File[] contents;
Vector vectorList;
Iterator currentFileView;
File currentFile;
  ......