Hello! What would be the best way to place a .png image on a JPanel? for instance if the picture was called flower.png, how should I go about importing it and making it visible on a JPanel? I tried messing around with BufferedImage but could not exactly get it. Also, would it work if the image was saved to my desktop? or would I have to put the image in a file and then into my workspace. Thank you!
adding png image to JPanel
Page 1 of 16 Replies - 308 Views - Last Post: 16 November 2012 - 04:53 AM
Replies To: adding png image to JPanel
#2
Re: adding png image to JPanel
Posted 15 November 2012 - 05:14 PM
Before replying to that post...
I have already answer a lot of your posts
Do you reply sometimes "Thank you" ?
Or do you click +1
It is kind of frustrating to provide you with answer and not having a feed back if our answers were right/useful and fix the problem
Or you are part of the generation who just ask and don't give a shit of the person who spent time answering your post ?
I have already answer a lot of your posts
Do you reply sometimes "Thank you" ?
Or do you click +1
It is kind of frustrating to provide you with answer and not having a feed back if our answers were right/useful and fix the problem
Or you are part of the generation who just ask and don't give a shit of the person who spent time answering your post ?
#3
Re: adding png image to JPanel
Posted 15 November 2012 - 05:16 PM
add(new JLabel(new ImageIcon("foo.png"));
#4
Re: adding png image to JPanel
Posted 15 November 2012 - 06:04 PM
Yes, you have answered several of my posts and almost all of them have been what I was looking for. I am new to dreamincode, I do not know exactly know what +1 means but I will definatly upvote your posts that help if that is what you mean. I have been in a programming fog all day, I am not trying to be rude. But please dont be so brash, I am not that type of person and I dont appreciate being thought of as so. Thank you for all of your help, you are truly a talented programmer.
#5
Re: adding png image to JPanel
Posted 15 November 2012 - 07:26 PM
g00se, I tried that
Didnt quite work
I will show you the full code segment
Thanks for the help!
add(new JLabel(new ImageIcon("Warlock.png")), BorderLayout.CENTER);
Didnt quite work
class Instructions extends JFrame {
private static JLabel instructions;
private static JLabel p;
Instructions(){
instructions = new JLabel();
add(new JLabel(new ImageIcon("Warlock.png")), BorderLayout.CENTER);
instructions.setText("<html>YOU are the Arcane Inventor... A magical source that is responsible" +
"<p> for creating all of the life-forms in existence. It is the Arcane " +
"<p>Inventor's job to combine elements of MIGHT, SOUL, and WISDOM to bring " +
"<p>These beings into existence. Good Luck...</html>");
instructions.setFont(new Font("Narkisim", Font.BOLD, 20));
setLayout(new BorderLayout());
setLocationRelativeTo(null);
add(instructions, BorderLayout.SOUTH);
}
}
Thanks for the help!
#6
Re: adding png image to JPanel
Posted 15 November 2012 - 08:20 PM
Where is Warlock.png located?
#7
Re: adding png image to JPanel
Posted 16 November 2012 - 04:53 AM
Why do you mean "didn't quite work" ?
Do you see an Image at all ? If you see it, is it crooked, badly positionned, ?
Do you see an Image at all ? If you see it, is it crooked, badly positionned, ?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|