i made a loading bar, basicly and im develpoing a program, can someone give me a basic on how to add it, it consist of 100+ pictures.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
i made a loading bar, basicly and im develpoing a program, can someone give me a basic on how to add it, it consist of 100+ pictures.
1.) Get the image first
2.) get a lightweight container
3.) override paintComponent
4.) paint the image that you called
im not sure if this is what you want
See
Lesson: Working with Images (The Java™ Tutorials > 2D Graphics)
How to Use Icons (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
And you might want to do something about that signature....the all caps and animated flashing animation is beyond annoying (and could detract people from actually replying to your posts)
chronoz13 (January 19th, 2012)
ImageIcon pic = new ImageIcon("Filename.extension"); panel.add(new JLabel(pic)); this.setVisible(true);
This should work.
Java Programmer (January 21st, 2012)
import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class Class2 extends JFrame { public Class2(){ super(" "); ImageIcon pic = new ImageIcon("ProgressBar000.PNG"); add(new JLabel(pic)); this.setVisible(true); } }
Picture dosent show up?
This should work.
import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Class2 extends JFrame { public static void main(String[] args) { new Class2(); } public Class2() { this.setSize(300, 300); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setTitle("ImageTest"); JPanel panel = new JPanel(); JLabel label = new JLabel("ImageTest"); panel.add(label); ImageIcon pic = new ImageIcon(Class2.class.getResource("ProgressBar000.png")); panel.add(new JLabel(pic)); this.add(panel); this.setVisible(true); } }
Make sure the program has access to the file.ie put it in the projects bin folder.
-Duster
Last edited by DusteroftheCentury; January 19th, 2012 at 11:49 PM.
Java Programmer (January 21st, 2012)
@DusteroftheCentury: Though you are trying to help others and that's why this community is but spoon feeding is one of the violations of the Forums rules if you read the rules.
I Personally Don't Believe The Words "Spoon Feeding"
I Asked "can someone give me a basic on how to add it" So He have me what i asked for, a understanding on how to add pictures into a JFrame.
I Didn't Asked to be "spoon fed" i asked for help.
i understand your part, i've been on that before, and up to now i still crave for exact answers for my problems, the term "Spoon feeding" was not yet , i can say implemented way back ago when i was on my very beginning of Java Programming, i got answers by code. I became inactive for years, when i got back, rules are strictly implemented including the Spoon feeding, i was thinking same as you are, "i just need answers(CODES) why CANT you give it?" thats the help that i need", but when i read the rules, i realize that, its better to solve your problems on your own, being a programmer its not like solving anything in an instant nor all at the same time, everything is step-by-step.i asked for help
think of this, "I want to learn integral calculus! give some example please!", if you dont even know how to add 1 + 1 or anything like advanced math like polynomials, how would you be able to solve that calculus? the point is, start from start dont start at the middle, if they give codes, would you be able to understand it all? what if you encounter a bug? a syntactical error? would be able to debug it on your own? I bet you WONT(Thats what i suffered when i got codes(Spoon Fed) even by our fellow professional forum mates) Because of the rules against spoon feeding , i learned how to be resourceful, google became my bestfriend, if i need codes, google can provide me, then if he doesnt, ill think of another solution, whats the benefit? i learned another thing,
"Resourcefulness"
ill give you an idea, your problem is "how to add picutres in JFrame", try to type it in google, exactly those words, he will throw you LOTS of references, when i say LOTS, its ALOT, and ill bet, one reference that google will gave you will refer to this site's tutorials and code snippets
you said the word "Basic", google can still provide you codes for that, you know the word basic, then you should start from there,I Asked "can someone give me a basic on how to add it"
i even got a problem right now, i dont have any big projects yet, so i decided to solve all available sorting algorithms that i know, i started with QuickSort, instead of asking the forums, "how to QuickSort", i typed in google, "QuickSort Algorithm procedure", and Boom! google gave tons of references, Codes, guides, pseudocode. At first glance, i dont understand the codes that im seeing, so i decided, to solve the Sorting by following the procedure, STEP-BY-STEP, and now im almost done, by trying to solve it in 5 days T_T, atleast, i can understand the flow of the algorithm, i even saw the Loopholes of the guides, it doesnt even state some of the important details. I even learned the term "PIVOT", the median-of-three, how to get it, the importance, things like that. After i finish it, its time to ask some here, if the thing that i did is efficient, then that s the time to take advantage of ONE OF the importance of forums.
i hope you understand my point, english is not my native language, so im getting some problems expressing my thoughts, but i think its enough for you to understand it.
please read this, youll enjoy this article
http://www.javaprogrammingforums.com...n-feeding.html
Last edited by chronoz13; January 21st, 2012 at 04:02 AM.
Ok, I understand.
Ill go read the rules.
Where exactly are they located?
Last edited by DusteroftheCentury; January 21st, 2012 at 11:39 AM.
I Googled it, Read everything in my Java Programming Book and i couldn't get it to work, i don't use Java Programming Forums as my first source of help.