Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21516 > unrolled thread

Swing image class

Started bybob smith <bob@coolfone.comze.com>
First post2013-01-18 07:20 -0800
Last post2013-01-19 00:48 -0800
Articles 8 — 8 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Swing image class bob smith <bob@coolfone.comze.com> - 2013-01-18 07:20 -0800
    Re: Swing image class FredK <fred.l.kleinschmidt@gmail.com> - 2013-01-18 08:25 -0800
    Re: Swing image class "John B. Matthews" <nospam@nospam.invalid> - 2013-01-18 11:37 -0500
    Re: Swing image class Knute Johnson <nospam@knutejohnson.com> - 2013-01-18 09:05 -0800
    Re: Swing image class Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-18 10:55 -0800
    Re: Swing image class Arne Vajhøj <arne@vajhoej.dk> - 2013-01-18 18:40 -0500
    Re: Swing image class Roedy Green <see_website@mindprod.com.invalid> - 2013-01-18 23:30 -0800
      Re: Swing image class Lew <lewbloch@gmail.com> - 2013-01-19 00:48 -0800

#21516 — Swing image class

Frombob smith <bob@coolfone.comze.com>
Date2013-01-18 07:20 -0800
SubjectSwing image class
Message-ID<3a854a9f-1fb5-4001-ab84-7d6fd7987069@googlegroups.com>
Is there really no built-in Swing class that just displays an image?

This is very hard to believe, but it looks like it at first google.

[toc] | [next] | [standalone]


#21522

FromFredK <fred.l.kleinschmidt@gmail.com>
Date2013-01-18 08:25 -0800
Message-ID<82a9e787-299d-4b57-842b-df2d7d4979d5@googlegroups.com>
In reply to#21516
On Friday, January 18, 2013 7:20:15 AM UTC-8, bob smith wrote:
> Is there really no built-in Swing class that just displays an image? This is very hard to believe, but it looks like it at first google.

What's wrong with using JLabel?

[toc] | [prev] | [next] | [standalone]


#21524

From"John B. Matthews" <nospam@nospam.invalid>
Date2013-01-18 11:37 -0500
Message-ID<nospam-C8AFDB.11374218012013@news.aioe.org>
In reply to#21516
In article <3a854a9f-1fb5-4001-ab84-7d6fd7987069@googlegroups.com>,
 bob smith <bob@coolfone.comze.com> wrote:

> Is there really no built-in Swing class that just displays an image?
> 
> This is very hard to believe, but it looks like it at first google.

Unable to reproduce:

<http://www.google.com/search?q=Swing%20class%20that%20displays%20an%20image>

First hit: <http://stackoverflow.com/q/299495/230513>.

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [next] | [standalone]


#21526

FromKnute Johnson <nospam@knutejohnson.com>
Date2013-01-18 09:05 -0800
Message-ID<kdbvdd$clo$1@dont-email.me>
In reply to#21516
On 1/18/2013 7:20 AM, bob smith wrote:
> Is there really no built-in Swing class that just displays an image?
>
> This is very hard to believe, but it looks like it at first google.
>

http://rabbitbrush.frazmtn.com/

Three methods for loading an image for display.

-- 

Knute Johnson

[toc] | [prev] | [next] | [standalone]


#21536

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2013-01-18 10:55 -0800
Message-ID<ZUgKs.128924$pV4.2814@newsfe21.iad>
In reply to#21516
On 1/18/13 7:20 AM, bob smith wrote:
> Is there really no built-in Swing class that just displays an image?
>
> This is very hard to believe, but it looks like it at first google.

JFrame mainFrame = new JFrame();
mainFrame.add(new JLabel(new ImageIcon(imageFile)));
mainFrame.pack();
mainFrame.setVisible(true);


Done.

[toc] | [prev] | [next] | [standalone]


#21554

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-18 18:40 -0500
Message-ID<50f9dd70$0$282$14726298@news.sunsite.dk>
In reply to#21516
On 1/18/2013 10:20 AM, bob smith wrote:
> Is there really no built-in Swing class that just displays an image?
>
> This is very hard to believe, but it looks like it at first google.

Google was not your friend today.

:-)

There are different ways of doing it.

JLabel lbl = new JLabel();
lbl.setIcon(new ImageIcon(location));
getContentPane().add(lbl);

is the simplest.

protected void paintComponent(Graphics g) {
         super.paintComponent(g);
         BufferedImage img = ImageIO.read(location);
         g.drawImage(img, 0, 0, this);
}

gives you the option to play with AffineTransform.

Arne


[toc] | [prev] | [next] | [standalone]


#21571

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-01-18 23:30 -0800
Message-ID<4mikf8h7enquva3icl2d085grd5e04emt0@4ax.com>
In reply to#21516
On Fri, 18 Jan 2013 07:20:15 -0800 (PST), bob smith
<bob@coolfone.comze.com> wrote, quoted or indirectly quoted someone
who said :

>Is there really no built-in Swing class that just displays an image?
>
>This is very hard to believe, but it looks like it at first google.

Perhaps they considered it too simple.  Here is one

https://wush.net/svn/mindprod/com/mindprod/common11/ImageViewer.java

You can download the whole package at
http://mindprod.com/products1.html#COMMON11


You can use a JLabel/ImageIcon combo to get that effect in Swing.

see http://mindprod.com/jgloss/imageicon.html
-- 
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development 
time. 
~ Tom Cargill  Ninety-ninety Law 

[toc] | [prev] | [next] | [standalone]


#21575

FromLew <lewbloch@gmail.com>
Date2013-01-19 00:48 -0800
Message-ID<d94c3a3e-7946-4ef7-982e-a8b7b26cd334@googlegroups.com>
In reply to#21571
Roedy Green wrote:
> Perhaps they considered it too simple.  Here is one
> https://wush.net/svn/mindprod/com/mindprod/common11/ImageViewer.java

That is a pretty little piece of code with Javadocs, clean and spare design, 
complete functionality without overstepping its purpose, and usefulness.

> You can download the whole package at
> http://mindprod.com/products1.html#COMMON11
> 
> You can use a JLabel/ImageIcon combo to get that effect in Swing.
> 
> see http://mindprod.com/jgloss/imageicon.html

-- 
Lew

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web