how do you put images on a screen?
12 Message(s) by 5 Author(s) originally posted in java help
| From: blah bah7 |
Date: Monday, October 22, 2007
|
can someone give me some simple
code only showing me how to put
image s
on a
screen (from an image file)
| From: Joshua Cranmer |
Date: Monday, October 22, 2007
|
wrote in message:
can someone give me some simple code only showing me how to put images
on a screen (from an image file)
... The acronyms `GIYF' (Google is your friend) and `RTFM' (Read the
fine manual) are relevant here.
<http://JAVA.sun.com/JAVAse/6/docs/> is a great resource, including even
links to a plethora of manuals.
<http://JAVA.sun.com/JAVAse/6/docs/api/JAVA/awt/Image.html> is another
good starting point.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E.
Knuth
| From: blah bah7 |
Date: Monday, October 22, 2007
|
wrote in message:
wrote in message:
> can someone give me some simple code only showing me how to put images
> on a screen (from an image file)
... The acronyms `GIYF' (Google is your friend) and `RTFM' (Read the
fine manual) are relevant here.
<http://JAVA.sun.com/JAVAse/6/docs/> is a great resource, including even
links to a plethora of manuals.
<http://JAVA.sun.com/JAVAse/6/docs/api/JAVA/awt/Image.html> is another
good starting point.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
i was hoping for an example so I could study the example...
| From: Lew |
Date: Monday, October 22, 2007
|
wrote in message:
... The acronyms `GIYF' (Google is your friend) and `RTFM' (Read the
fine manual) are relevant here.
<http://JAVA.sun.com/JAVAse/6/docs/> is a great resource, including even
links to a plethora of manuals.
<http://JAVA.sun.com/JAVAse/6/docs/api/JAVA/awt/Image.html> is another
good starting point.
wrote in message:
i [sic] was hoping for an example so I could study the example...
And your hope will be realized when you follow Joshua's advice.
--
Lew
| From: Joshua Cranmer |
Date: Monday, October 22, 2007
|
wrote in message:
i was hoping for an example so I could study the example...
If you want an example, you are going to need to tell us some of the
context of what you want to do. I can think of two (three?)
fundamentally different ways to
display a
picture off of the top of my
head, depending on what the overarching
goal is. "Code to display an
image" is only a notch or two less vague than "Code to display output."
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
| From: blah bah7 |
Date: Monday, October 22, 2007
|
wrote in message:
wrote in message:
> I was hoping for an example so I could study the example...
If you want an example, you are going to need to tell us some of the
context of what you want to do. I can think of two (three?)
fundamentally different ways to display a picture off of the top of my
head, depending on what the overarching goal is. "Code to display an
image" is only a notch or two less vague than "Code to display output."
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
say the image was pac_man.gif
I want to know how to say something like "display pac_man.gif at x,y",
only in a working example
| From: Lew |
Date: Monday, October 22, 2007
|
| From: Andrew Thompson |
Date: Monday, October 22, 2007
|
wrote in message:
..."display pac_man.gif at x,y",
<sscce>
import JAVAx.swing.*;
import JAVA.net.
URL ;
class ImageAnywhereOnScreen {
public static void main(final String[] args)
throws Exception {
final URL imageLocation =
new URL("
http://JAVA.sun.com/images/lgsun.gif");
Runnable r = new Runnable() {
public void run() {
int x = 300;
int y = 200;
if (args.length>=2) {
try {
x = Integer.parseInt(args[0]);
y = Integer.parseInt(args[1]);
} catch(Exception e) {
//use defaults
System.err.println(
"Number(s) unparsable as "+
"integer, using defaults" );
}
}
JLabel label = new JLabel(
new ImageIcon(
imageLocation));
JWindow w = new JWindow();
w.setLocation(x,y);
w.add(label);
w.pack();
w.setVisible(true);
}
};
SwingUtilities.invokeLater(r);
}
}
</sscce>
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via
http://www.JAVAkb.com
| From: Andrew Thompson |
Date: Monday, October 22, 2007
|
wrote in message:
wrote in message:
>..."display pac_man.gif at x,y",
...
class ImageAnywhereOnScreen {
As an aside, that example was intended to help you
appreciate the advice already offered by Joshua and
Lew.
The Layouts tutorial might also help with that 'x,y'
bit , although Lew's
pointer to the 2D part of the
tutorial is another way to do it (whereas the way I
place the image in the example, is 'crude and simple').
Andrew T.
| From: Joshua Cranmer |
Date: Monday, October 22, 2007
|
wrote in message:
wrote in message:
wrote in message:
I was hoping for an example so I could study the example...
If you want an example, you are going to need to tell us some of the
context of what you want to do. I can think of two (three?)
fundamentally different ways to display a picture off of the top of my
head, depending on what the overarching goal is. "Code to display an
image" is only a notch or two less vague than "Code to display output."
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
say the image was pac_man.gif
I want to know how to say something like "display pac_man.gif at x,y",
only in a working example
Given this context, it seems to me that your ultimate end result'd
fall into this
sort of pattern: [ much code removed for conciseness]
public class GameDisplay extends JComponent {
private static Image pacMan;
private int x, y;
public GameDisplay() {
if (pacMan == null) {
pacMan = this.getToolkit().createImage("pac_man.gif");
}
}
public void paintComponent(Graphics g) {
// Do other stuff
g.drawImage(pacMan, x, y, this);
// Do more stuff
}
}
(note: code untested)
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
| From: Lew |
Date: Monday, October 22, 2007
|
wrote in message:
... Lew's pointer to the 2D part of the
tutorial is another way to do it (whereas the way I
place the image in the example, is 'crude and simple').
I came into Swing
program ming ass backwards, and I do not have anywhere near
Andrew's expertise, particularly in the
GUI aspects of Swing. A couple of
years back I did a project to print /n/-up images, much as a
printer runs off
a batch of business cards. (/n/-up printing is a grid layout of the same
item, /n/ to a row, as many rows as fit on a page.) This required extensive
use of JAVA 2D and affine transforms. Yummy.
People gripe about Swing as a GUI framework, but really it's quite potent. I
used to program GUIs in
Motif and Open Look; there's a distinct similarity of
outlook among these frameworks.
Anyway, that experience has me more attuned to the 2D
library than some folks
might be.
FWIW, I implemented the project as a grid of JPanels with a BufferedImage
drawn into each of them, scaled to fit. Details escape me after this time,
but I think I also played some fun
games with laying out
text over top of the
image within each JPanel.
Then the print library came into play. More fun. I was surprised to find
that JAVA lets a body do some magic with a printer.
The result was a
WYSIWYG /n/-up print-layout tool.
After some learning curve, including even buying a book, it really was not so
hard to do it. Familiarity with the
API (application programming interface)was the key, as with everything JAVA.
It did turn out pretty hard to put together what I wanted to know about the
JAVA printing libraries. For one thing, there are at least two. Not entirely
incompatible with each other. For another no one
source really said much
about it. There'd be a little bit here, another take on it there, all
over the place. It took me some effort to synthesize information from the
disparate sources in that area.
--
Lew
| From: Roedy Green |
Date: Tuesday, October 23, 2007
|
On Mon, 22 Oct 2007 13:18:17 -0700, blah bah7
<blahbah7@xxxxxxxxxxx>
wrote in message, quoted or indirectly quoted someone who said :
can someone give me some simple code only showing me how to put images
on a screen (from an image file)
see
http://mindprod.com/jgloss/image.html
--
Roedy
Green Canadian Mind Products
The JAVA Glossary
http://mindprod.com
Next Message: Newbie question re linked list
Blogs related to how do you put images on a screen?
Rpg Maker 2003
Can't
do much yet 'cept move around and fire lasers. In one of the parts in the middle
you see a laser against the wall, that's because I haven't
put the border in yet -_- Rpg Maker 2003 Resources iso-maker word-maker gif-maker
...
ok it definately php was the splash screen one thing Im concerned ...
where
do i
put a command which i want to be run at start up? bense, are
you a troll? Should be call the moderators? Falstius,
do you know how to change the “human” color behind the splash screen when signing in
...
Online Dating Tip - Dinner For Two At Your Place - Top Tips To ...
This may sound like a batch to see when all
you desire to make is pass a relaxed eventide at place with your new partner. But with a small forward planning and a well thought out, simple menu,
you can
put the
scene for a perfect
...
Liveblogging MAX 2007 Day 2 General session keynote
You can change the characteristics of the item - color, accent colors — change the color of a layer.
You can go beyond the customization.
You can even
put graphics onto the
image — he’s putting a number on a uniform that he has already
...
mineo
And I housemaid's putting me on!
You want me to teach
you how to dance?' And he said 'I want to learn how to
do that!' Well, the
scene was that I took a towel" - he demonstrates drying his bottom 11 and it was about 20 minutes later,
...
25 new messages in 11 topics - digest
of a novel and accuse him of "forgery",
do you? >> >> Just take is as mind stimulating experience >> and see how much your real life is affected by >> what it says in those protocols? >> >> Why
do you need to mix Russian Tsar into
...