![]() |
|
#1
|
|||
|
|||
Image onto JFrameHello I am starting an app to import an image, it imports an image ok when it i hard coded. I am trying to provide a name for the image in main, using args[0], but I keep getting a "Exception in main()java.lang.NullPointerException". is this because the args parameter is not getting used by the paint method?
cheers tedds JAVA Code:
Last edited by LuciWiz : 24-Oct-2007 at 11:23.
Reason: Please insert your Java code between [java] & [/java]
|
|
#2
|
||||
|
||||
Re: Image onto JFrameYes, 'args' IS null at the paint method, for in the TestImage class, 'args' is declared, but never assigned anything -- so it is null.
How does that code work for you? The Image class is abstract, and compiling gives this: Code:
JAVA Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: Image onto JFrameThats not good, I should have said that I have a class "Image". Thank you for your response, i changed the constuctor and it worked, so i have quickly gone onto creating a JFileChooser.
I just added a JFileChooser to my code, so that when the app is running you can click the button to choose a different file. I can see how I can allocate the new pic to a brand new frame by duplicating the main method and creating a new JFrame. Is there a way that I can use the selected file from JFileChooser and replace the original file from args[0]? cheers JAVA Code:
|
|
#4
|
||||
|
||||
Re: Image onto JFrameIf there's a way to get the file string from the JFileChooser, I would think it would be a simple of matter of reassigning the 'args' variable with the file string -- if that it what you mean.
Note: I made a minor edit in post #2. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#5
|
|||
|
|||
Re: Image onto JFrameyep, thats what I had in mind. Im going to give that a go now. I just have to make sure the args[0] in the main method still don't override the new file string.
cheers yep it worked a charm, excatly what you mentioned thank you for your time, its good to learn from not just books. cheers |
|
#6
|
|||
|
|||
Re: Image onto JFramehello again, im going pretty quick through what to do with this swing stuff. the Image class has a method of flipX(), which turns the image upside down. I am trying to use this method and see if I can in fact change the image. I think that this is similar to the last issue that I had, but I'm not to sure. Do you how I can do this?
cheers JAVA Code:
|
|
#7
|
|||
|
|||
Re: Image onto JFrameHello TurboPT, thanks for your advice on the previous. I have come back to this and am checking out how to cycle through the rbg colors of a loaded image. for example, the red takes the blue value, blue takes the green value and green takes the red value. I ave stated the method for this, but am stuck on how to get the rbg values from the array. I am assuming that after the second for loop, I find the rbg values then assign them, i.e. r(value) = b(value), b(value) = g(value), g(value) = r(value). Am I making a correct assumption here?
Cheers Code:
|
|
#8
|
||||
|
||||
Re: Image onto JFrameThere is a getRGB() function (as well as other 'get' functions for specific, individual [Red,Green,Blue] colors) is this what you need?
Unfortunately, I haven't done much with color-space stuff, so my help might be limited here. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#9
|
|||
|
|||
Re: Image onto JFrameYeah thats what I need, I've just been reading up about it and it looks like I can figured it out.
Thanks for the response. |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Importing images | arety33 | Java Forum | 1 | 12-Jul-2007 13:28 |
| VC++: Image doubt | gal4MS | MS Visual C++ / MFC Forum | 0 | 04-Oct-2006 15:56 |
| How to create or display an image | Unit1 | C Programming Language | 1 | 27-Sep-2006 02:18 |
| GIM gidedit - a fltk fluid resize project | cable_guy_67 | FLTK Forum | 2 | 01-Jun-2005 15:00 |
| Checking source codes of image, audio and video files | onauc | C Programming Language | 5 | 26-Feb-2005 21:47 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The