//显示对象为jpg,gif canvas中画图使用double buffering,使用scroll bar显示,显示区域固定了,可以扩展成按照canvas的大小来显示的模式,因为canvas放在center位置。 import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.swing.*; class Frameext extends Frame { } public class Images extends Frame implements ActionListener, WindowListener ,WindowStateListener { //Frameext fr = new Frameext(); Label Label1 = new Label(” “,Label.LEFT); //will show the file name Button Button1 = new Button(“open file”); int xpos,ypos; int imageHeight; int w,h; Image offimg, bg; Graphics offg; boolean first=true; //extends Canvas. This code will use its paint method. public MyCanvas Canvas1 = new MyCanvas(); static Scrollbar horizontal, vertical; //scrollbar used FileDialog fd = new FileDialog(this,”Open”, FileDialog.LOAD); Image Image1; public void initialize() { //System.out.println(” dddddd “+this.MAXIMIZED_BOTH); //this.setLocation(0, 0); //this.setSize(this.getToolkit().getScreenSize()); this.setSize(600,600); this.setLocation(30,30); this.setBackground(Color.lightGray); Canvas1.setBackground(Color.white); Canvas1.setSize(580,580); //ColorChooserDialog colorDialog = new ColorChooserDialog(this, “@fff”, this); this.add (“North”, horizontal = new Scrollbar (Scrollbar.HORIZONTAL)); this.add (“East”, vertical = new Scrollbar (Scrollbar.VERTICAL)); Panel pa=new Panel(); pa.setBackground(Color.white); Label1.setBackground(Color.lightGray); Label1.setAlignment(Label.LEFT); pa.add(Label1); pa.add(Button1); //add label and button on panel this.add(“South”,pa); //add panel at south this.add(“Center”,Canvas1); this.addWindowListener(this); this.addWindowStateListener (this); Button1.addActionListener(this); try { System.out.println (“getsize” + Canvas1.getSize () + “getwidth” + Canvas1.getWidth () + “getheight ” + Canvas1.getHeight ()); } catch (Exception e) {System.out.println(e.toString()); } this.pack(); this.show(); } void imageload () { fd.setFile(“*.jpg” />
支付宝 赏一听可乐吧~
文章知识点与官方知识档案匹配,可进一步学习相关知识Java技能树首页概览92733 人正在系统学习中 相关资源:诗词鉴赏大全软件-教育文档类资源-CSDN文库
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!