Results 1 to 9 of 9
Thread: pictures in application
- 10-27-2008, 05:24 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 20
- Rep Power
- 0
pictures in application
Hello New To Java Forum,
I started 'programming' 2 years ago and I picked up C#. I managed* to make quite useful application for certain job.
Anyway, now I am trying to 'translate' my application to Java, and I decided to add one more functionality to it.
I am thinking of taking pictures with camera, or phone and such, and storing them in certain folders on PC, so the application can use them to display them on some jPanel 300x200 pixels.
So, my question is, how to display pictures (jpg, png..??) in my application? Links and examples are welcomed. Of course, some simple zoom is in order, and 'hand/grab' scroll.
(I have java doc (and in it api?), but I don't know how to use it, yet)
Kind regards, Grom
* with extensive help of forums
Sorry for edit: I use NetBeansLast edited by Grom; 10-27-2008 at 05:26 PM. Reason: my software status
- 10-27-2008, 05:42 PM #2
Senior Member
- Join Date
- Sep 2008
- Posts
- 135
- Rep Power
- 0
Cross-posted at Sun
New To Java - Picture in Application
- 10-27-2008, 05:46 PM #3
Member
- Join Date
- Aug 2008
- Posts
- 20
- Rep Power
- 0
Hey George, what's up?
I am not a native english speaker, so,... what is that cross standing for?
Thanks
Edit, oh, right, I think I get it! These two forums are kind of connected?, ...right?
And I can't post on both forums the same, identical question because..?
Anyway, Ioverthere I got this link, which I did not yet checked, since I started this thread like 15 minutes ago, but I will give it a try and report on both forums.
I can not post links yet, so I'll bend the rule like this:
http: //java.sun.com/docs/books/tutorial/2d/images/index.html
Kind regards, GromLast edited by Grom; 10-27-2008 at 05:57 PM. Reason: learning connections
- 10-28-2008, 12:44 AM #4
because...
People are trying to help you. They may spend some time answering your questions/doubts, only to find out that the it was already answered on the other forum and they have just wasted their time trying to help you on this forum.
Suggestion: stick with one forum. If you don't get an answer or the answer doesn't satisfy/help you, then you could try another similiar forum.
As you can see, cross posting tends to anger people.
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 10-28-2008, 06:24 AM #5
Member
- Join Date
- Aug 2008
- Posts
- 20
- Rep Power
- 0
Hello,
off topics:
First off, George, Thanks for your time. Because of you I now know better - not to cross post my questions. I must addmit you, it was my standard practice... sorry. I will ask separately and I promise to give back the 'results'. Hope to hear from you in my other thread!
CJSLMAN, man, I was way off, thanks for putting me on the right track. Thank you.
back on topic:
I checked link and its links, and I tried to 'implement' their code - still unsecesfully, but I need couple more days to post my results.
Kind regards, Grom
- 10-28-2008, 09:02 AM #6
Senior Member
- Join Date
- Sep 2008
- Posts
- 135
- Rep Power
- 0
Yep, cross-posting means posting the same thing in multiple places. Nothing actually wrong with it, but usually one gets answered, and the person asking doesn't let people know in the other place, which can waste time needlessly. No biggie!
- 10-31-2008, 09:56 AM #7
Member
- Join Date
- Aug 2008
- Posts
- 20
- Rep Power
- 0
Hello guys,
George, I am glad to hear from you.
I kind of managed to understand that link, so here is where I got stuck:
lead me to http: //java.sun.com/docs/books/tutorial/2d/images/loadimage. html . There is picture of strawberry. Code is in LoadImageApp.java (http: //java.sun.com/docs/books/tutorial/2d/images /examples/LoadImageApp.java), and here I have some questions.
(Sorry for my terminology, I'll try to be descriptive)
Class LoadImageApp has main, LoadImageApp, paint and dimension 'events'.
If I understand correctly, main event creates a window, calls (adds) LoadImageApp event, packs and sets visible (the only thing I dont understand is pack thing).
when LoadImageApp is called from main, it 'loads' picture strawberry.
Now here is where I don't understaind, when paint and Dimensin events are called/executed?
I can see paint event is Graphical event, with line: g.drawImage(img, 0, 0, null)
I tried to call paint event in my app, but I could not 'pass graphicall event g'
also, I could not put g.drawImage in jButton event, since it has not g but evt
and Dimension, it sets size or sets none. but where is it called to be executed?
My (main) question is, how do I display picture now that I loaded it? How to call paint event?
Am I supposed to have a canvas for this in my app?
I got this far, and debugging shows that it is loaded, I believe, since it passes through try statement . (it does not enter catch statement). I have this in button action event:
String home = System.getProperty("user.home"); // I set path to picture on desktop
File desktop = new File(home, "Desktop");
File Slika = new File(desktop + "/strawberry.jpg");
try {
img = ImageIO.read(Slika); //Load picture
// canvas1.repaint();
// canvas1.set
// boolean Graphics.drawImage(img, 0, 0, null);
// paint(evt);
}
catch(Exception e) {
}
If I am not making sense, I apologize, and I'd be glad to elaborate more.
Of course, since I messed up I have this same topic over on: http: //forums.sun.com/thread.jspa?messageID=10487407
Kind regards, Grom
- 10-31-2008, 11:34 AM #8
> (the only thing I dont understand is pack thing).
Window (Java Platform SE 6))
> My (main) question is, how do I display picture now that I loaded it? How to call paint event?
Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI with JFC/Swing)
db
Response repeated on the other forum. I suggest you mark one of the threads as closed.
- 10-31-2008, 11:52 AM #9
Member
- Join Date
- Aug 2008
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
The Funny Pictures Thread(this means a lot of pictures...)
By joshua in forum EntertainmentReplies: 22Last Post: 07-25-2012, 09:51 PM -
pictures...
By whosadork in forum New To JavaReplies: 1Last Post: 10-20-2008, 02:18 AM -
Scale 2 or more pictures using a JSlider
By Panchitopro in forum New To JavaReplies: 0Last Post: 05-05-2008, 05:22 PM -
Help Loading Up Pictures
By marco in forum Java AppletsReplies: 3Last Post: 08-14-2007, 10:32 PM -
Help with pictures en Java
By susan in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 04:36 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks