|
-
Jan 30th, 2009, 06:36 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Adding image to Java Application
Hi to all,
As a part of my college project i have to make an online auction application, I have made all except one thing. I need a client application to load item picture.
The idea was that the picture will be on server, and its address stored in a database. Client clicks on an item, application loads its image address from database and opens that image in current frame, or in some of its component.
So im stuck here, i have image address in a String but i cannot load the image because i dont know how.
Help please!

I have the second question.
How to load local picture into applet, from the same disk.
I need an applet on a web page and it to load the picture from its directory.
Just need the code to load the picture.
Last edited by Dungeon Keeper; Jan 30th, 2009 at 06:43 AM.
-
Feb 9th, 2009, 04:09 AM
#2
Lively Member
Re: Adding image to Java Application
Well i am having some code do one thing i am sending the code if it works fine not means u just send me a copy code of ur project.
Code:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.awt.BorderLayout;
public class GUI2 extends JFrame
{
ImageIcon icon;
Image image;
public GUI2()
{
icon = new ImageIcon("Winter.jpg");
JPanel panel = new JPanel()
{
protected void paintComponent(Graphics g)
{
// Dispaly image at full size
g.drawImage(icon.getImage(), 0, 0, null);
super.paintComponent(g);
}
};
panel.setOpaque( false );
panel.setPreferredSize( new Dimension(500, 500) );
getContentPane().add( panel );
panel.setLayout(new BorderLayout());
JPanel southPanel = new JPanel();
JButton button = new JButton( "Hello" );
southPanel.setOpaque(true);
button.setOpaque(true);
southPanel.add(button);
add(southPanel, BorderLayout.NORTH);
// southPanel.add(button);
// southPanel.add(b);
}
public static void main(String [] args)
{
GUI2 frame = new GUI2();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(450, 250);
frame.setLocationRelativeTo( null );
frame.setVisible(true);
}
}
Success = 1 % Knowledge + 99 % Hard work
-
Feb 9th, 2009, 08:59 AM
#3
Thread Starter
Fanatic Member
Re: Adding image to Java Application
Thank you very much. Ive got the point how is it done 
Where does this Winter.jpg needs to be placed? In which folder?
Where my .class files are?
-
Feb 9th, 2009, 09:24 AM
#4
Re: Adding image to Java Application
the applet will be running on the client and you wanted your pictures to be on a server.
Ensure that the directory where the images are on the server is accessible
and from that you can try
icon = new ImageIcon("\\\\server\\imagedir\\Winter.jpg");
-
Feb 9th, 2009, 09:57 AM
#5
Thread Starter
Fanatic Member
Re: Adding image to Java Application
thanks oceanebelle but i think ill make an applet on server side 
Its easier this way.
-
Feb 9th, 2009, 10:21 AM
#6
Re: Adding image to Java Application
 Originally Posted by Dungeon Keeper
thanks oceanebelle but i think ill make an applet on server side 
Its easier this way.
Sorry to disappoint you but Applets are all client-side
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Feb 9th, 2009, 12:10 PM
#7
Thread Starter
Fanatic Member
Re: Adding image to Java Application
Yeah i know but its different if applet is on user pc or on server pc
-
Feb 10th, 2009, 07:50 AM
#8
Lively Member
Re: Adding image to Java Application
well i am not clear with ur replay give me detailed thing i will try to help and the jpg file has to place in the directory where the oceanebelle given u the way u have
Success = 1 % Knowledge + 99 % Hard work
-
Feb 10th, 2009, 03:29 PM
#9
Thread Starter
Fanatic Member
Re: Adding image to Java Application
Thanks for help maheshkanda i think ill manage to do it on my own from here. Thanks a lot for help!
-
Feb 11th, 2009, 06:12 PM
#10
Re: [RESOLVED] Adding image to Java Application
good luck
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|