Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3125
| From | "tar" <tar@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Spreading an image to |
| Message-ID | <ymifxw41umx.fsf@blackcat.isi.edu> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <ea7cdb8b-c83d-4dd3-b1b6-80eaf8ce0fa0@k39g2000hsf.googlegroups.com> |
| Date | 2011-04-27 15:43 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
jmtrg@hotmail.fr writes:
> Hello
>
> I found a java code allowing to display an image in a JPanel in 2
> ways : either by centering the image or by creating a mosaic picture
> of this image ;
Is it just me, or is the code for CENTER and MOSAIC reversed?
> public class JPanelImageBg extends JPanel
> {
> private int mode;
> private TexturePaint texture;
> private BufferedImage bufferedImage;
>
> public static final int CENTER = 0;
> public static final int MOSAIC = 1;
>
> public JPanelImageBg( String fileName, int mode )
> {
... snip
> }
>
> public void paintComponent(Graphics g)
> {
> super.paintComponent(g);
> switch( mode )
> { case CENTER :
> Graphics2D g2d = (Graphics2D)g;
> g2d.setPaint(texture);
> g2d.fillRect(0, 0, getWidth(), getHeight() );
> break;
> case MOSAIC :
> g.setColor(this.getBackground());
> g.fillRect(0,0,getWidth(), getHeight() );
> g.drawImage(bufferedImage,(getWidth()-
> bufferedImage.getWidth())/2,(getHeight()-bufferedImage.getHeight())/
> 2,null);
> break;
> default :
> super.paintComponents(g);
> }
> }
... snip
--
Thomas A. Russ, USC/Information Sciences Institute
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Find similar | Unroll thread
Spreading an image to the "jmtrg" <jmtrg@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: Spreading an image to "Michael Dunn" <michael.dunn@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: Spreading an image to "jmtrg" <jmtrg@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: Spreading an image to "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
csiph-web