Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java Swing GUIÎļþÍÏ×§

      ÎªÁË·½±ã£¬ÓÐʱÎÒÃÇÐèÒªÖ±½Ó½«±¾µØÎļþ»ò×Ö·û»òͼƬֱ½ÓÍÏ×§µ½Í¼ÐÎÉÏ£¬ÈÃ×é¼þ×Ô¶¯´ò¿ªÍÏ×§µÄÎļþ¡£»ùÓÚÕâÖÖ˼Ï룬ÎÒдÁËÈçÏ´úÂëʵÏÖÕâ¸öÍÏ×§¼àÌýµÄ¹¦ÄÜ¡£
      1.UIÔ´Âë
package ibees.desktop;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
/**
*
* @author zhang xiaojin
* ÑÝʾSwingÎļþÍÏ×§
*/
public class DropDragDemo {
public static void main(String[] args){
JFrame frame = new JFrame("ÎļþÍÏ×§Demo");
frame.setSize(500, 400);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createTitledBorder("ÎļþÍÏ×§ÑÝʾ"));
JTextArea textArea = new DropDragSupportTextArea();
JScrollPane jsp = new JScrollPane();
jsp.setViewportView(textArea);
textArea.setColumns(40);
textArea.setRows(20);

panel.add(jsp);
frame.add(panel);
frame.setVisible(true);
}
}
 
 Õâ¶ÎÔ´ÂëµÄЧ¹ûÈçÏ£ºÀïÃæµÄÁ½¸öÎļþÃûÊÇÎÒÍÏ×§½øÈ¥µÄ¡£
  2.ʵÏÖ¼àÌýµÄÀà
package ibees.desktop;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.swing.JTextArea;
/**
*
* @author Administrator
*/
public class DropDragSupportTextArea extends JTextArea implements DropTargetListener{
private DropTarget dropTarget


Ïà¹ØÎĵµ£º

javaÃæÏò½Ó¿Ú±à³Ì

½Ó¿Ú±¾ÖÊÉϾÍÊÇÓÉÖÆ¶¨ÕßÀ´Ð­µ÷ʵÏÖÕߺ͵÷ÓÃÕßÖ®¼äµÄ¹ØÏµ¡£
ËùÒÔͨ³£ËµµÄ“ÃæÏò½Ó¿Ú±à³Ì”¿ÉÒÔÀí½âΪ£º
Ö»ÓÐʵÏÖÕߺ͵÷ÓÃÕß¶¼×ñÑ­“ÃæÏò½Ó¿Ú±à³Ì”Õâ¸ö×¼Ôò£¬Öƶ¨ÕßµÄЭµ÷Ä¿µÄ²ÅÄÜ´ïµ½¡£
Ò»¸öÀÏÉú³£Ì¸µÄÀý×Ó¾ÍÊÇJDBC¡£
ºÜ¶àÈ˷ѽ⣺¼ÈÈ»ÎÒÿÁ¬½ÓÒ»ÖÖÊý¾Ý¿â£¨Èçmysql£©¶¼ÒªÊÂÏȲ¿ÊðÇý¶¯³ÌÐò£¬ÄÇÎÒÖ±½ ......

Java¶ÁÈ¡ÅäÖÃÎļþ

import java.util.Properties;
public class ConfigReader {
private static Properties cache = new Properties();
static{
   try {
    cache.load(ConfigReader .class.getClassLoader().getResourceAsStream("config.properties"));
   } catch (Exception e) {
 &nbs ......

Ḭ̈߳²È«µÄSingletonģʽµÄJavaʵÏÖ

public class Factory {
private static Factory factory;
private static Object classLock=Factory.class;
   private Factory(){}
   public static Factory getFactory(){
      synchronized(classLock){
          ......

java¶¯Ì¬±àÒë¼°ÔËÐÐ

תIBMµÄÎÄÕ£¬±È½ÏÏêϸ¡£ÐèҪעÒâµÄÊÇ£¬
ͨ¹ýJavaCompiler½øÐбàÒë¶¼ÊÇÔÚµ±Ç°Ä¿Â¼ÏÂÉú³É.classÎļþ£¬¶øÊ¹ÓñàÒëÑ¡Ïî¿ÉÒԸıäÕâ¸öĬÈÏĿ¼¡£±àÒëÑ¡ÏîÊÇÒ»¸öÔªËØÎªStringÀàÐ͵ÄIterable¼¯ºÏ¡£ÈçÎÒÃÇ¿ÉÒÔʹÓÃÈçÏ´úÂëÔÚDÅ̸ùĿ¼ÏÂÉú³É.classÎļþ¡£
 
Iterable options = Arrays.asList("-d", "d:\\");
JavaCompiler. ......

Ê®¶þ javaÃæÏò¶ÔÏó³ÌÐòÉè¼Æ(ÀàµÄ¼Ì³Ð)

Ê®¶þ javaÃæÏò¶ÔÏó³ÌÐòÉè¼Æ(ÀàµÄ¼Ì³Ð)
/**
 * ÀàµÄ¼Ì³Ð
 */
class Person
{
 private String name;
 private int age;
 public String setName(String name){this.name = name;return name;}
 public int setAge(int age){this.age = age;return age;}
 public void getInfo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ