同步操作将从 serv/JavaDesigner 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.text.*;import javax.swing.border.*;import java.awt.*;public class ProxyDisplay extends JxFrame{public ProxyDisplay(){super("Display proxied image");JPanel p = new JPanel();getContentPane().add(p);p.setLayout(new BorderLayout());ImageProxy image = new ImageProxy("d:\\JavaProject\\Proxy\\src\\elliott.jpg", 321, 271);//ImageProxy image = new ImageProxy("c:\\winnt\\web\\Wallpaper\\Windows 2000.jpg", 321, 271);p.add("Center", image);p.add("North", new Label(" "));p.add("West", new Label(" "));setSize(370, 350);setVisible(true);}//------------------------------------static public void main(String[] argv){new ProxyDisplay();}}//==================================class ImageProxy extends JPanelimplements Runnable{int height, width;MediaTracker tracker;Image img;JFrame frame;Thread imageCheck; //to monitor loading//------------------------------------public ImageProxy(String filename, int w, int h){height = h;width = w;tracker = new MediaTracker(this);img = Toolkit.getDefaultToolkit().getImage(filename);tracker.addImage(img, 0); //watch for image loading//imageCheck = new Thread(this);//imageCheck.start(); //start 2nd thread monitor//this begins actual image loadingtry{tracker.waitForID(0,1);}catch(InterruptedException e){}imageCheck = new Thread(this);imageCheck.start(); //start 2nd thread monitor}//------------------------------------public void paint(Graphics g){if (tracker.checkID(0)){height = img.getHeight(frame); //get heightwidth = img.getWidth(frame); //and widthg.setColor(Color.lightGray); //erase boxg.fillRect(0,0, width+5, height+5);g.drawImage(img, 0, 0, this); //draw loaded image}else{//draw box outlining image if not loaded yetg.setColor(Color.red);g.drawRect(1, 1, width+10, height+10);}}//------------------------------------public Dimension getPreferredSize(){return new Dimension(width, height);}//public int getWidth() {return width;}//public int getHeight(){return height;}//------------------------------------public void run(){//this thread monitors image loading//and repaints when done//the 1000 msec is artifically long//to allow demo to display with delaytry{Thread.sleep(1000);while(! tracker.checkID(0))Thread.sleep(1000);}catch(Exception e){}repaint();}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。