이 기사에서는 Java-implemented Image Viewer에 대해 설명합니다. 참조를 위해 공유하십시오. 세부 사항은 다음과 같습니다.
1. mycanvas.java :
Package PictureViewer; import java.awt.*; import java.awt.image int image_height; public void setimage (bufferedimage bi) {this.bi = bi; (this.getheight ()-image_height)/2);} public void componentresized (bi! = null) {system.out.println ( "resize !!"); ; int screen_width = int screen_height = 1.0 * screen_height / screen_width.out. p0 "+screen_proportion); image_width = bi.getWidth (this); image_height = bi.getheight (this); double image_proportion = 1.0 * image_height / i mage_width; system.out.println ("image : w "+image_width+", h. "+image_height+", p1 "+image_proportion); if (im } indime_width = (induce_width); );}}2. myfilter.java :
Package PictureViewer; import java.io.file; import java.io.filenamefilter; public class myfilter는 filenamefilter {private String [] extendi on {extension = new String [] { ". jpg", ".jpg ",".gif ",".gif ",".png ",".png ",".jpeg ",".jpeg "};} public myfilter (string [] extension) {this.extension = extension;} public boolean accept (file dir, string name) {for (string s : extension) {if (s)3. PictureViewer.java :
Package PictureViewer; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.io.*; import javax.imageio. 프레임은 개인 문자열; ) 예외 {new PictureViewer () init () {frame = 새 프레임 ( "PictureViewer"); 이전 = "다음 버튼"; Add (pb.add) (New); .add (Mc, "Center"); }); this.validatebutton (); ActionPerformed (ActionEvent e) {String Command = e.getActionCommand ( "Select Picture") {fd_load.setVisible (true); (fpath! = null) && (fname! = null) {새 파일 (fpath + fname); } else ( "prevain") {findex = 0; 사진 ")) {findex ++; if (findex> = files.length) findex = files.length-1; this.Display (files [findex]);} this.validateButton ();} public void display (file f) { {bufferedImage bi = imageio.Read (f); PrintStackTrace (); ; i ++) {if (current.equals (files [i])) {findex = i; 다음 .setEnabled ((files! = null) && (findex <(files.length-1)));이 기사가 모든 사람의 Java 프로그래밍에 도움이되기를 바랍니다.