问题一
BufferedImage image;
public void createImage(String fileLocation) {
try {
FileOutputStream fos = new FileOutputStream(fileLocation);
BufferedOutputStream bos = new BufferedOutputStream(fos);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
encoder.encode(image);
bos.close();
} catch(Exception e) {
System.out.println(e);
}
}
当然你要在先得到 image.
问题二
这个在 windows 中设定打开类型就行。 win2000 中工具-〉文件夹选项-〉文件类型。如果有这个文件类型就更改它的打开方式,没有则创建一个jar 类型,设定打开方式。问题三
Button
b1=new Button("button 1"),
b2=new Button("button 2");
b1.addActionListener(this);
b2.addActionListener(this);
add(b1);
add(b2);
public void actionPerformed(ActionEvent e){
Object source=e.getSource();
if(source==b1)
...
else if(source==b2)
...
else
...
}
你看看Java 编程思想就知道了。
BufferedImage image;
public void createImage(String fileLocation) {
try {
FileOutputStream fos = new FileOutputStream(fileLocation);
BufferedOutputStream bos = new BufferedOutputStream(fos);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
encoder.encode(image);
bos.close();
} catch(Exception e) {
System.out.println(e);
}
}
当然你要在先得到 image.
问题二
这个在 windows 中设定打开类型就行。 win2000 中工具-〉文件夹选项-〉文件类型。如果有这个文件类型就更改它的打开方式,没有则创建一个jar 类型,设定打开方式。问题三
Button
b1=new Button("button 1"),
b2=new Button("button 2");
b1.addActionListener(this);
b2.addActionListener(this);
add(b1);
add(b2);
public void actionPerformed(ActionEvent e){
Object source=e.getSource();
if(source==b1)
...
else if(source==b2)
...
else
...
}
你看看Java 编程思想就知道了。
问题二还要在MANIFEST.MF文件里加一句:Main-Class: classname
不过又出来一个问题,不好意思的很,俺如何给你加分?:)俺是读Herbert Schildt的《Java2 编程起步》入门的(其他的书越读头越大),因此对这人特有好感,现正看着他的另一本书。
一直错误觉得《Java编程思想》属于说得多练得少那种,且涉及的论题太深,没敢去翻;现在看来得去翻一翻了~~:)