JAVA ¶ÔÊ÷ÐνṹÖÐͼƬµÄÐÞ¸Ä
package graphic;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import java.awt.Component;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultMutableTreeNode;
/**
*
* @author bianzhiqi
* ¾ßÌå·½·¨µÄʹÓò鿴DefaultTreeCellRendererµÄÎĵµ
*/
public class MyRenderer extends DefaultTreeCellRenderer{
private ImageIcon leafIcon;
private ImageIcon midIcon;
public MyRenderer(ImageIcon leafIcon,ImageIcon midIcon)
{
this.leafIcon=leafIcon;
this.midIcon=midIcon;
}
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(
tree, value, sel,
expanded, leaf, row,
hasFocus);
DefaultMutableTreeNode node=(DefaultMutableTreeNode)value;
if(leaf && leafIcon!=null) setIcon(leafIcon);
else if((isKeyword(node)||isSpecial(node)) && midIcon!=null) setIcon(midIcon);
else setIcon(null);
return this;
}
protected boolean isKeyword(DefaultMutableTreeNode node)
{
String value=node.toString();
if(value.equals("int") || value.equals("real")||value.equals("while")||
value.equals("write")||value.equals("if")||value.equals("else")||
value.equals("read") ||value.equals("else if")
)
return true;
else return false;
}
protected boolean isSpecial(DefaultMutableTreeNode node){
String value=node.toString();
if(value.equals("<")||value.equals("<>")||value.equals("=")||value.equals("=="))
return true;
else return false;
}
}
Ïà¹ØÎĵµ£º
ÔÚjavaÖпÉÒÔͨ¹ýRuntime.getRuntime().exec(cmd)À´Ö´ÐÐÍⲿÃüÁÎұȽϳ£ÓõÄÊǵ÷ÓÃshell½Å±¾À´Íê³ÉijЩ¹¤×÷£¬Ò²¿ÉÒÔÖ±½ÓÖ´ÐÐÒ»¸öos µÄÃüÁ±È½Ïµ÷ÓÃimagemagickÀ´Íê³ÉͼƬµÄһЩ²Ù×÷£¬ÆäÖÐÐèҪעÒâµÄÓÐÁ½µã£¬1ÊÇ×îºÃ´øÉÏÃüÁîµÄÍêÕû·¾¶,·ñÔòÃüÁî¿ÉÄܲ»»á±»Ö´ÐУ¬¶øÇÒҲûÓÐÈκα¨´íµÄÐÅÏ¢Êä³ö£¬2ÌرðҪעÒâ¿Õ¸ñ£¬±ÈÈçÎÄ ......
ComparatorºÍComparableÔÚÅÅÐòÖеÄÓ¦ÓÃ
µ±ÐèÒªÅÅÐòµÄ¼¯ºÏ»òÊý×é²»Êǵ¥´¿µÄÊý×ÖÐÍʱ£¬Í¨³£¿ÉÒÔʹÓÃComparator»òComparable£¬ÒÔ¼òµ¥µÄ·½Ê½ÊµÏÖ¶ÔÏóÅÅÐò»ò×Ô¶¨ÒåÅÅÐò¡£
Ò»¡¢Comparator
Ç¿ÐжÔij¸ö¶ÔÏócollection½øÐÐÕûÌåÅÅÐòµÄ±È½Ïº¯Êý£¬¿ÉÒÔ½«Comparator´«µÝ¸øCollections.sort»òArrays.sort¡£
½Ó¿Ú·½·¨£º
......
javaËÄÉáÎåÈë
package Test;
import java.math.BigDecimal; //ÒýÈëÕâ¸ö°ü
public class Test {
public static void main(String[] args) {
double i = 3.856;
// ÉáµôСÊýÈ¡Õû
System.out.println("ÉáµôСÊýÈ¡Õû:Math.floor(3.856)=" + (int) Math.floor(i));
......
RMI (Remote Method Invocation£¬Ô¶³Ì·½·¨µ÷ÓÃ)ÈçºÎÓÃÓÚ³ÌÐò¼äͨѶ£¬ÁíÒ»¸öÓÃÓÚͨѶµÄ¼¼ÊõÊÇRuntime.exec() ·½·¨¡£Äã¿ÉÒÔÓÃÕâ¸ö·½·¨´ÓÒ»¸öÔËÐа¢java³ÌÐòÖе÷ÓÃÁíÒ»¸ö³ÌÐò¡£Runtime.exec Ò²ÔÊÐíÄãÖ´ÐкͳÌÐòÏà¹ØµÄ²Ù×÷£¬ÀýÈç¿ØÖƳÌÐòµÄ±ê×¼ÊäÈëÊä³ö£¬µÈ´ý³ÌÐòµÄ½áÊø²¢µÃµ½ËüµÄÍ˳ö״̬¡£ÏÂÃæÊÇÒ»¸ ......
¾¡Á¿¸´ÓöÔÏ󣬶ø²»ÊÇ´´½¨ÐµĶÔÏó£¬ÌرðÊǵ±Ò»¸ö¶ÔÏóÊÇimmutable£¨²»¿É¸Ä±ä£©µÄʱºò¡£ ÈçString¶ÔÏó£¬ String s= new String(¡°String¡±); ǧÍò²»ÒªÕâÑù×ö£¬ÒòΪÕâÀïʵ¼ÊÉÏ´´½¨ÁËÁ½¸ö¶ÔÏó¡£ Òª±ÜÃâ³öÏÖÕâÑùµÄÇé¿ö£¬ 1ÊÇ¿ÉÒÔÓþ²Ì¬¹¤³§º¯Êý£¬À´½â¾ö£¬ÈçÀà¿âÖеÄBoolean.valueOf(¡°true¡±)£¬ÕâÖÖ·½Ê½ÒªÓÅÓÚn ......