差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| study:java:design_pattern:proxy [2008/11/10 13:16] – banana | study:java:design_pattern:proxy [2021/05/12 00:27] (現在) – [ImageProxy Class] banana | ||
|---|---|---|---|
| 行 86: | 行 86: | ||
| - **이미지를 가져오는 동안에는 " | - **이미지를 가져오는 동안에는 " | ||
| - **이미지 로딩이 끝나면 paintIcon(), | - **이미지 로딩이 끝나면 paintIcon(), | ||
| - | - **사용자가 새로운 이미지를 요청하면 프록시를 새로 만들고 위이 과자을 새로 진행합니다.** | + | - **사용자가 새로운 이미지를 요청하면 프록시를 새로 만들고 위의 과정을 새로 진행합니다.** |
| 行 103: | 行 103: | ||
| ImageIcon imageIcon; | ImageIcon imageIcon; | ||
| URL imageURL; | URL imageURL; | ||
| - | Thread retrievalThread; | + | Thread retrievalThread; |
| boolean retrieving = false; | boolean retrieving = false; | ||
| 行 116: | 行 116: | ||
| */ | */ | ||
| public int getIconHeight() { | public int getIconHeight() { | ||
| - | if(imageIcon!=null) return imageIcon.getIconHeight(); | + | if (imageIcon != null) return imageIcon.getIconHeight(); |
| else return 600; | else return 600; | ||
| } | } | ||
| 行 124: | 行 124: | ||
| */ | */ | ||
| public int getIconWidth() { | public int getIconWidth() { | ||
| - | if(imageIcon!=null) return imageIcon.getIconWidth(); | + | if (imageIcon != null) return imageIcon.getIconWidth(); |
| else return 800; | else return 800; | ||
| } | } | ||
| 行 132: | 行 132: | ||
| */ | */ | ||
| public void paintIcon(final Component c, Graphics g, int x, int y) { | public void paintIcon(final Component c, Graphics g, int x, int y) { | ||
| - | if(imageIcon!=null){ | + | if (imageIcon != null) { |
| // | // | ||
| imageIcon.paintIcon(c, | imageIcon.paintIcon(c, | ||
| } else { | } else { | ||
| - | g.drawString(" | + | g.drawString(" |
| // | // | ||
| - | if(!retrieving){ | + | if (!retrieving) { |
| // | // | ||
| //할 수 있습니다. | //할 수 있습니다. | ||
| retrieving = true; | retrieving = true; | ||
| - | + | ||
| // | // | ||
| retrievalThread = new Thread(new Runnable(){ | retrievalThread = new Thread(new Runnable(){ | ||
| public void run(){ | public void run(){ | ||
| try { | try { | ||
| - | // | + | // |
| - | //객체를 리턴합니다. | + | |
| imageIcon = new ImageIcon(imageURL, | imageIcon = new ImageIcon(imageURL, | ||
| // | // | ||
| 行 157: | 行 156: | ||
| } | } | ||
| }); | }); | ||
| - | + | ||
| retrievalThread.start(); | retrievalThread.start(); | ||
| } | } | ||
| 行 283: | 行 282: | ||
| {{: | {{: | ||
| + | ===== reference ===== | ||
| + | *[[http:// | ||
| + | ]] | ||