java help
2 posters
Page 1 of 1
java help
anyone knows how to insert a image in a frame using co ordinates?
like setBounds is used to set co ordinates + the size of components.. any way I can do that to images?
like setBounds is used to set co ordinates + the size of components.. any way I can do that to images?
Re: java help
And I thought it was hard..
- Code:
ImageIcon ima = new ImageIcon("theaddress\\oftheimage\\with\\the\\imagename\\with. extension");
JLabel label= new JLabel(ima);
getContentPane().add(label);
Re: java help
I have never worked with image in Java, if I would certainly help you.. search Google, you will find tons of example there... I just suggest you, use a JPanel, insert picture in JPanel, then, create instance in Frame, and then use setBounds like-
instanceOfJpanel.setBounds(arg0, arg1, arg2, arg3);
and it will be the best, if you use it in the constructor of the Frame. and how to insert image in JPanel is like -
class importImage extend JPanel{
public Image image;
public importImage(){
setLayout(null);
try {
image=ImageIO.read(new File("Image/stone1.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
image.setBounds(arg0, arg1, arg2, arg3);//here you'll set the image in the panel
add(image);}}
I'm afraid how it will work, you can try with this... but always remember, you've to initialize Layout,
I mean setLayout(null);
ok best of luck..
instanceOfJpanel.setBounds(arg0, arg1, arg2, arg3);
and it will be the best, if you use it in the constructor of the Frame. and how to insert image in JPanel is like -
class importImage extend JPanel{
public Image image;
public importImage(){
setLayout(null);
try {
image=ImageIO.read(new File("Image/stone1.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
image.setBounds(arg0, arg1, arg2, arg3);//here you'll set the image in the panel
add(image);}}
I'm afraid how it will work, you can try with this... but always remember, you've to initialize Layout,
I mean setLayout(null);
ok best of luck..
Re: java help
yeah, I thought about using JPanel. But was not sure whether the image becomes re sizable within the panel.
But main problem is :p I didn't use any panel previously, so was confused.
One problem with using images directly withing frame by creating labels is that you can't resize the image. (At least I didn't find any way to resize it.)
However, resize is an important issue here, and I will have to keep that JPanel advice in mind.
thanks a lot Rokon
But main problem is :p I didn't use any panel previously, so was confused.
One problem with using images directly withing frame by creating labels is that you can't resize the image. (At least I didn't find any way to resize it.)
However, resize is an important issue here, and I will have to keep that JPanel advice in mind.
thanks a lot Rokon
Re: java help
I don't know what u r actually going to do..? so I thought, you just wanted to know how can you use image in a Frame? anyway, If you would mention here, what you want to do actually, then I could try. Anyway, I couldn't understand your re-sizable issue. If it is possible, can you please explain what you are going to do..?
Anyway, it is not good practice to do anything in Frame I think. Frame is simply a container where you can import lots of Panel, label whatever you want. I can use panel, so if you need any help about JPanel, you can ask me.
Anyway, you can ask me anything about Java, whatever I can help you or not, at least I'll try to solve the problem. OK best of luck.
Anyway, it is not good practice to do anything in Frame I think. Frame is simply a container where you can import lots of Panel, label whatever you want. I can use panel, so if you need any help about JPanel, you can ask me.
Anyway, you can ask me anything about Java, whatever I can help you or not, at least I'll try to solve the problem. OK best of luck.
Last edited by bit0112-rokon on Mon Aug 02, 2010 7:14 am; edited 1 time in total
Re: java help
Hmm.. resize.. for example, say I want to use an image which's resolution is 300*400;
but I want to use it as a thumbnail, of size.. say 72*72. You see, I do not want to modify the picture, nor do I want to make a copy (at least in physical drive )of it and then use it, I simply want to use that image, resized (i.e. in my desired resolution).
but I want to use it as a thumbnail, of size.. say 72*72. You see, I do not want to modify the picture, nor do I want to make a copy (at least in physical drive )of it and then use it, I simply want to use that image, resized (i.e. in my desired resolution).
Re: java help
I dont have much idea about image issue, but I'll try. May be you'll get the solution after the math exam.
I've a question, why you are going to use image?will it be a background of your Frame..?or just as a Icon?Ok best of luck..?
I've a question, why you are going to use image?will it be a background of your Frame..?or just as a Icon?Ok best of luck..?
Re: java help
no it will not be background.
I think the idea I am going to use is also required in your project. Know why?
How about inserting a picture of the user in your income tax calculator?
like in facebook.. no matter whatever the image's resolution we upload, it always resizes it to a specific resolution for profile picture.
I think the idea I am going to use is also required in your project. Know why?
How about inserting a picture of the user in your income tax calculator?
like in facebook.. no matter whatever the image's resolution we upload, it always resizes it to a specific resolution for profile picture.
Similar topics
» Java Tutorial: Using Two Java Reference Keywords, this and super
» Java EE vs .Net???
» Java 7
» About Java 3D
» first java program
» Java EE vs .Net???
» Java 7
» About Java 3D
» first java program
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford