mshd.net
当前位置:首页 >> JAvA的imAgEIO读取图片后,怎么把他显示在pAnEl上呢? >>

JAvA的imAgEIO读取图片后,怎么把他显示在pAnEl上呢?

您好:读取bmp文件到BufferedImage中 File file2 = new File("c:\\testimages\\tttt" + ".bmp"); // BufferedImage bi = backstore.getBufferedImage(); try { output = ImageIO.read(file2); } catch (IOException e) { e.printStackTrace(); }...

private static Toolkit tk = Toolkit.getDefaultToolkit(); private static Image im=E.class.getResource("images/6.gif");//E指当前所在类images/6.gif目录 void draw(Graphics g) { Color c = g.getColor(); g.setColor(Color.BLUE); g.draw...

看看这个是不是你想要的; JPanel jpanel = new JPanel(); BufferedImage image = new BufferedImage(jpanel.getWidth(),jpanel.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); jpanel.paint(g2); ImageIO...

你可以尝试下面两种方法: 获取JPanel的画布,用drawImage方法把图片画在JPanel上 新建个JLabel,用setIcon方法设置JLabel的图片,再添加进JPanel filechooser可以参考一下这段代码 private void openImage() { JFileChooser jfc=new JFileChoos...

java中获取Panel上某个像素点的像素颜色,代码如下: public static void main(String[] args) {//创建一个150*150,RGB高彩图,类型可自定BufferedImage img=new BufferedImage(150, 150, BufferedImage.TYPE_INT_rgb);//取得图形Graphics g=im...

根据窗口大小显示图象 import java.awt.*; import java.io.*; import javax.imageio.*; import javax.swing.*; public class ImageTest { public static void main(String[] args) { ImageFrame frame = new ImageFrame(); frame.setDefaultClos...

楼主,你肯定是搞错了什么,这代码测试过,可以生成图片的

package test;import javax.swing.*;import javax.imageio.ImageIO;import java.awt.*;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;public class TestJLabel2Image { public static void main(String ...

根据我的经验,问题还是在paint方法里,你可以这样试试: 不要通过重写paint方法来画图,这会造成很多难以估计的影响。比较好的办法是重写paintComponent方法,如下: public void paintComponent(Graphics g) { super.paintComponent(g); //然...

public class GifComponent extends JComponent { private static final long serialVersionUID = 1L; private GifBean[] gifBeans; private Map gifBeanMap = new HashMap(); private int index = 0; private int delayFactor; private Timer t...

网站首页 | 网站地图
All rights reserved Powered by www.mshd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com