⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utilities.java

📁 SWT实现人人的象棋程序 供学习SWT的同志做个参考
💻 JAVA
字号:
package com.catking.Utility;

import java.io.*;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;

import sun.audio.*;

public class Utilities {
	public static void playSound(String fileName){
		try {
			InputStream in;
			in = new FileInputStream (new File(fileName));
			AudioStream as = new AudioStream (in);
			AudioPlayer.player.start (as); 
		} catch (Exception e) 
		{}
	}
	public static void delay(long time){
		try{
			Thread.sleep(time);
		}catch(InterruptedException e)
		{}
	}
	public static String getColor0XFromRGB(Color color){
		int r = color.getRed();
		int g = color.getGreen();
		int b = color.getBlue();
		StringBuffer s = new StringBuffer();
		String clr = Integer.toHexString(r);
		if(clr.length()==1){
			s.append("0");
		}
		s.append(clr);
		clr = Integer.toHexString(g);
		if(clr.length()==1){
			s.append("0");
		}
		s.append(clr);
		clr = Integer.toHexString(b);
		if(clr.length() ==1){
			s.append("0");
		}
		s.append(clr);
		return String.valueOf(s);
	}
	public static void saveBMPFile(String file, ImageData data){

		ImageLoader loader = new ImageLoader();
		loader.data = new ImageData[]{data};
		loader.save(file, SWT.IMAGE_BMP );
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -