收集java的常用函数代码!大家分享,共同学习!请分享者到此接分[续一]!

jdlsfl 2008-07-28 07:56:30
由于无私的分享者很多,原贴分数不够,请到此接分!

原贴:http://topic.csdn.net/u/20080701/23/3390e185-d6c1-43d0-9222-ad03d2e303a6.html

至于内部代码,各位自行整理学习!
...全文
699 96 打赏 收藏 转发到动态 举报
写回复
用AI写文章
96 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinyi2011 2010-10-22
  • 打赏
  • 举报
回复





精华精华真的是很华啊
zhaojiubo 2009-04-20
  • 打赏
  • 举报
回复
哇 跨年了 都!
madee123 2009-04-17
  • 打赏
  • 举报
回复
收藏了
wawawa2222 2009-01-03
  • 打赏
  • 举报
回复
都是好东西啊...
nihility88 2008-10-30
  • 打赏
  • 举报
回复
顶,再学习
kahn178 2008-09-18
  • 打赏
  • 举报
回复

//ShowColors.java
//Demonstrating Colors.

//Java Core packages
import java.awt.*;
import java.awt.event.*;

//java extension packages
import javax.swing.*;

public class ShowColors extends JFrame{

//constructor sets window's title bar string and dimension
public ShowColors()
{
super("Using colors");

setSize(400,130);
setVisible(true);

}
//draw rectangles and Strings in different colors
public void paint(Graphics g)
{
//call superclass's paint method
super.paint(g);

//set new drawing colors using integers
g.setColor(new Color(255,0,0));
g.fillRect(25,25,100,20);
g.drawString("Current RGB:"+g.getColor(),130,40);

//set new drawing color using floats
g.setColor(new Color(0.0f,1.0f,0.0f));
g.fillRect(25,50,100,20);
g.drawString("Current RGB:"+g.getColor(),130,65);

//set new drawing color using static color objects
g.setColor(Color.blue);
g.fillRect(25,75,100,20);
g.drawString("Current RGB:"+g.getColor(),130,90);

//display individual RGB values
Color color = Color.magenta;
g.setColor(color);
g.fillRect(25,100,100,20);
g.drawString("RBG values:"+color.getRed()+","+color.getGreen()+","+color.getBlue(),130,115);

}

//excute application
public static void main(String args[])
{
ShowColors application =new ShowColors();
application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
}
}

//end class ShowColors
善桀 2008-08-08
  • 打赏
  • 举报
回复
口水泛滥........正在温习
zzkk_1980 2008-08-08
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 ZangXT 的回复:]
精华
[/Quote]
gloomy98 2008-08-08
  • 打赏
  • 举报
回复
厉害啊
cuixiuqin1954 2008-08-06
  • 打赏
  • 举报
回复
顶起
nick6610 2008-08-06
  • 打赏
  • 举报
回复

sxn19811006 2008-08-06
  • 打赏
  • 举报
回复
xx
  • 打赏
  • 举报
回复
jfjf
  • 打赏
  • 举报
回复
jfjf
daibu 2008-08-06
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 java2000_net 的回复:]
jfjf
[/Quote]
skylovehang 2008-08-06
  • 打赏
  • 举报
回复
我接分
xl_nj 2008-08-06
  • 打赏
  • 举报
回复
好东西
ian63 2008-08-06
  • 打赏
  • 举报
回复
送大家一个,我常用的配置文件管理类,多个配置文件大家就自己写个工厂类来管理吧:

public class PropertiesTool {
private Hashtable cachedFile = new Hashtable();

/**
* constructor
* @param fileName
*/
public PropertiesTool(String fileName){
getPropertiesFromClasspath(fileName);
}

public void getPropertiesFromClasspath(String file){
ResourceBundle rb = ResourceBundle.getBundle(file);
Enumeration en = rb.getKeys();
while(en.hasMoreElements()){
String key = String.valueOf(en.nextElement());
cachedFile.put(key,rb.getString(key));
}
}

public String getValueByKey(String key){
if (cachedFile!=null && cachedFile.size()!=0 && key !=null) {
return String.valueOf(cachedFile.get(key));
}
return "no data found";
}

public int getDataCount(){
if (cachedFile!=null) {
return cachedFile.size();
}else{
return 0;
}
}

public List getKeys(){
List result = new ArrayList();
Enumeration en = cachedFile.keys();
if (cachedFile!=null) {
while (en.hasMoreElements()) {
result.add(en.nextElement());
}
}
return result;
}
feng2112 2008-08-06
  • 打赏
  • 举报
回复
mark
skylovehang 2008-08-06
  • 打赏
  • 举报
回复
接分
加载更多回复(74)

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧