User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,551 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,602 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1111 | Replies: 5
Reply
Join Date: Jul 2006
Posts: 3
Reputation: grah3596 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
grah3596 grah3596 is offline Offline
Newbie Poster

Help Java newbie

  #1  
Jul 12th, 2006
Hi,

I am quite a competent c++ console programmer but I need to do some work with loading images and clicking on the images.

I want to load a screen full of images, click on an image and be able to retrieve the code, index or some value which uniquely identifies the image which I clicked on.

Is java the right tool? i need some direction to get started. Sample code would be a good jumpstart. i am prepared to read an experiment
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2004
Posts: 9
Reputation: danglingChap is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
danglingChap danglingChap is offline Offline
Newbie Poster

Re: Java newbie

  #2  
Jul 13th, 2006
Originally Posted by grah3596
Hi,

I am quite a competent c++ console programmer but I need to do some work with loading images and clicking on the images.

I want to load a screen full of images, click on an image and be able to retrieve the code, index or some value which uniquely identifies the image which I clicked on.

Is java the right tool? i need some direction to get started. Sample code would be a good jumpstart. i am prepared to read an experiment


well you can implement it in any language you wish. implementing in Consol C is a bit lenghty, since first you have to make function to load images bla bla.

I'd prefer to go for any High level language of your choice (C#, VC, VB, Java etc)

The logic behind this work is quite simple. you can either use a database or simple file (XML preferable). There will eb unique name for each image say "image1", "image2" ... if i talk XML then you'll have some tags like that
<image>
    <name="image1">
        <value>
        "any value you wish to have for that image to be loaded in your program"
        </value>
    </name>

    <name="image2">
        <value>
        "any value you wish to have for that image to be loaded in your program"
        </value>
    </name>

</image>

Now on image click you read the xml, match the TAG and read it's value. The same thing can be done using Simple File. Just make a structure like
class ImageDate{
    String name="image1";
    String value="data";
}
and write this data into file, you can then read those files and match the name to get value.

You can implement in Database as well. For this you have to do Database connectivity.
There can be a table
name: varchar(50) PK
value: varchar(50) NOT NULL

on selecting the image you can use the following query to search from the Db
select * from image where name = [apend it from the program]
Reply With Quote  
Join Date: Jul 2006
Posts: 3
Reputation: grah3596 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
grah3596 grah3596 is offline Offline
Newbie Poster

Re: Java newbie

  #3  
Jul 13th, 2006
Ok, let me see if I grasp this.

1. I have a directory that has for example 9 jpg images (img1, img2,..etc.).
2. I load these images on the screen from Java
3. Each image has a name and value record
4. When I click on the image, I trigger statements which writes this record to a file

My questions then are:

Does Java have some methods that would load an image to the screen? Do you know which package this function is in?

This "on-click", actually recognizes which of the images on the screen get clicked? Do I have find a way to determine the mouse pointer position on the screen when the click is made?

My questions are naive, I am sure. It is just that my programming experience is restricted to reading text files, processing them etc. I have no gui experience
Reply With Quote  
Join Date: May 2006
Posts: 25
Reputation: DaSogo is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
DaSogo DaSogo is offline Offline
Light Poster

Re: Java newbie

  #4  
Jul 13th, 2006
I know that you can load images into a JLabel. You can find tutorials online no problem. I used swing once to load an image into a JLabel for my background. It wasn't that hard to implement. As far as being able to click the images. You should be able to use java event handling and use an IF-else statement for control. From the control structure you should be able to retrieve the info you stored about that particular image.
Reply With Quote  
Join Date: Sep 2004
Posts: 9
Reputation: danglingChap is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
danglingChap danglingChap is offline Offline
Newbie Poster

Re: Java newbie

  #5  
Jul 14th, 2006
yeah you can use JLabel and set it's icon. Then on ActionPerformed you can get the label of the image and can manipulate according to your choice. you have to go through the documentation of JLabel and EventHandling.
Reply With Quote  
Join Date: Jul 2006
Posts: 3
Reputation: grah3596 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
grah3596 grah3596 is offline Offline
Newbie Poster

Re: Java newbie

  #6  
Jul 14th, 2006
Thanks for all of your help!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 9:21 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC