█████████
█┏━━━━━┓█
█★ ★█
█ ☆ ☆ █
█ █
█ 〖初窥Java〗 █
█ 【虚心学习】 █
█★ ★█
█┗━━━━━┛█
█████████
█┏━━━━━┓█
█★ ★█
█ ☆ ☆ █
█ █
█ 〖初窥Java〗 █
█ 【虚心学习】 █
█★ ★█
█┗━━━━━┛█
█████████
解决方案 »
- 求助:博客排名2万内,目前需要多少的访问量才可以做到? 100分送出
- 如何在web工程中定时启动线程
- java对象中的主类型元素存在哪里,是否和main函数中的主类型变量一样存在堆栈中,还是作为对象的一部分存在堆中?
- 在cmd里执行 bat 文件提示输入行太长,不应该有。。。
- 请问文件对话框和消息框分别是哪个类?
- JTextField中鼠标拖动选择字符时会触发KeyListener事件?代码如下,求解决
- 如何在Applet中获取客户端本机IP?
- 各位,给个建议给我!
- 郁闷中:可能要有一长段时间专门搞Java,矛盾中:(大家给点意见好吗?
- 怎么实现,让图片填充整个按钮区域吗?
- 怎样做windows2000/xp的输入法?
- 求助 JCreator 中如何加入"watch" 查看变量值?
import java.awt.*;
import java.awt.image.*;/**
* <strong>MemoryImageExample</strong> -- creating an image from
* raw pixel data.
*
* <p>
* This example creates a 29-by-29 array of pixels and displays it in
* an image magnified by a factor of 8. The pixel indices progress
* from left to right in a row, and from higher row to lower row.
*
* <p>
* The pixels have red turned on if the index is divisible by 2, green
* turned on if the index is divisible by 3, and blue turned on if the
* index is divisible by 5. Note, for instance, that every thirtieth
* pixel is white (divisible by 2, 3, and 5) and is surrounded by
* black pixels (index divisible by NONE of 2, 3, and 5).
*/
public class MemoryImageExample extends java.applet.Applet { static final int opaque = 0xFF << 24;
static final int red = 0xFF << 16;
static final int green = 0xFF << 8;
static final int blue = 0xFF; Image myImage; public void init() {
myImage = buildImage();
} public void paint(Graphics g) {
g.drawImage(myImage, 4, 4, 232, 232, this);
} Image buildImage() {
int width = 29;
int height = 29;
int[] pixels = new int[width * height]; /* Set pixel color according to divisibility by 2, 3,
* and 5.
*/
for (int i = 0; i < width * height; ++i) {
int val = opaque; /* current pixel value */
if (i % 2 == 0) val |= red;
if (i % 3 == 0) val |= green;
if (i % 5 == 0) val |= blue;
pixels[i] = val;
}
return createImage(new MemoryImageSource(width, height,
pixels, 0, width));
}}