![]() |
|
#1
|
|||
|
|||
New to Java: Putting a simple image file on the screenSorry to ask such a basic question, but I am new to the (unexpectedly complicated) world of Java graphics. I am familiar with basic Java concepts, but that's about it.
All I want to do is add an image to the screen in a JApplet. I need to be able to change the location of this image after it has been put on the screen, and I would like to retain the background transparency that makes PNG files so useful. Here's the URL of the image: Code:
I looked at several different tutorials and scrapped together this bit of code. I hope it doesn't make me look like a total moron JAVA Code:
Last edited by cable_guy_67 : 01-Apr-2006 at 07:14.
Reason: Please enclose java code in [java] ... [/java] tags
|
|
#2
|
||||
|
||||
Re: New to Java: Putting a simple image file on the screenApplet's do not have a 'main' function, per say...
see if the info. at this link may help: http://www.devx.com/java/article/8030 (as related to the image part, at least) __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: New to Java: Putting a simple image file on the screenThat's an excellent link. Thank you!
The only possible objection that I have is that the example link shows how to use an Applet and not a JApplet. What are the differences between the two? I may not need a JApplet after all. Can I still use text input boxes and such if I use an Applet and not a JApplet? |
|
#4
|
||||
|
||||
Re: New to Java: Putting a simple image file on the screenI'd say that it would be better to stick with JApplet -- rather than plain-old Applet (I didn't realize the Applet in the other link, sorry).
Basically, JApplet inherits from Applet, but there are differences and I don't know EVERY difference between the two. JAppet is a special swing container that uses a JRootPane [accessed via the getContentPane() call] and is typically more popular because it is generally much easier to use -- especially if you want to use the swing components and without having to use AWT (see below). Applets are strictly AWT. However, here are a couple of links about converting AWT to Swing for either an applet or application: http://www.ictp.trieste.it/~manuals/...rting/how.html then a link to a little more applet-specific conversion info: http://www.ictp.trieste.it/~manuals/...ps.html#applet Much more info can be found at the site of these two links! __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#5
|
|||
|
|||
Re: New to Java: Putting a simple image file on the screenThank you! You've been super helpful.
|
|
#6
|
|||
|
|||
Re: New to Java: Putting a simple image file on the screenGrr... I'm sorry to post again asking for help, but I just can't seem to figure out how to work with JApplets. I think it has something to do with a paint() vs a paintComponent() message? I don't know.
My request is this (sorry if it is a lot to ask): Could someone write me a super basic JApplet that displays a picture? Nothing fancy... just something that when you run it, has a picture in the top left corner. Maybe if I have some example source code to look at, I will be able to figure out what I am doing wrong. |
|
#7
|
|||
|
|||
Re: New to Java: Putting a simple image file on the screenNevermind! Problem solved... sort of.
|
|
#8
|
||||
|
||||
Re: New to Java: Putting a simple image file on the screenHow is that JApplet doing?
If you still need a small sample, I'll try to get one for you. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#9
|
||||
|
||||
Re: New to Java: Putting a simple image file on the screenTry this... I think it's about as "super basic" as it can be, and places the image in the top-left corner.
JAVA Code:
![]() ![]() __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! Last edited by TurboPT : 06-Apr-2006 at 19:41.
|
|
#10
|
|||
|
|||
Re: New to Java: Putting a simple image file on the screenThank you! That's perfect. This is all starting to make so much more sense.
|
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| Scalability in Java and C++ | agx | Miscellaneous Programming Forum | 7 | 04-Feb-2006 15:35 |
| Checking source codes of image, audio and video files | onauc | C Programming Language | 5 | 26-Feb-2005 21:47 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 11:28 |
| [Tutorial] Standard I/O | aaroncohn | C Programming Language | 20 | 27-Feb-2004 21:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The