Results 1 to 9 of 9
  1. #1
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default 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 NetBeans
    Last edited by Grom; 10-27-2008 at 05:26 PM. Reason: my software status

  2. #2
    georgemc is offline Senior Member
    Join Date
    Sep 2008
    Posts
    135
    Rep Power
    0

  3. #3
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default

    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, Grom
    Last edited by Grom; 10-27-2008 at 05:57 PM. Reason: learning connections

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default 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.

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default

    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

  6. #6
    georgemc is offline Senior Member
    Join Date
    Sep 2008
    Posts
    135
    Rep Power
    0

    Default

    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!

  7. #7
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default

    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

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,254
    Rep Power
    19

    Default

    > (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.

  9. #9
    Grom is offline Member
    Join Date
    Aug 2008
    Posts
    20
    Rep Power
    0

    Default

    Hello Darryl,

    I can Close one?
    Oh, man, now i have to choose, huh,.. hmmm
    (I am flipping coin): I am choosing this one!

    Let me check those links (Thanks Darryl) and I'll get back to you guys.

    Kind regards, Grom

Similar Threads

  1. Replies: 22
    Last Post: 07-25-2012, 09:51 PM
  2. pictures...
    By whosadork in forum New To Java
    Replies: 1
    Last Post: 10-20-2008, 02:18 AM
  3. Scale 2 or more pictures using a JSlider
    By Panchitopro in forum New To Java
    Replies: 0
    Last Post: 05-05-2008, 05:22 PM
  4. Help Loading Up Pictures
    By marco in forum Java Applets
    Replies: 3
    Last Post: 08-14-2007, 10:32 PM
  5. Help with pictures en Java
    By susan in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 04:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •