This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Java Software Solutions Graphics Example 3.9 noob help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java Software Solutions Graphics Example 3.9 noob help" Watch "Java Software Solutions Graphics Example 3.9 noob help" New topic
Author

Java Software Solutions Graphics Example 3.9 noob help

Bryce Heath
Greenhorn

Joined: Sep 16, 2011
Posts: 19
Hey guys
This is my first post, and hope this board is alot more helpful towards new programers then the last one I joined. Apparently something about programing makes people a little rude lol. Anyway Im working on a graphics example listed above and I understand it, but when I run the code the icon gif of the devil doesent show "because I dont have the .gif file for 1" but the question being where would this program be going to find the devil.gif file IE what folder. If some 1 could explain this a little better I think it would help thanks )


also if there is a better way to post code please let me know, I feel bad making huge posts lol
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

I added code tags to make your source more readable. You can either highlight your java and click the button (just like you want to make it italic or bold), click the button first and paste your code between the tags, or type the tags by hand. the look like this:

[ code=java]
[ /code]

only no space after the open bracket


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38025
    
  22
Welcome to the Ranch

So you think we're helpful? You've fallen into my hands! Mwaaahaaahaahaa!

I see Fred has been at your post and added code tags, and you can see how much better it looks. If you click the code button before writing the code, go left 7 places so your cursor is between the first ] and the second [, where there is no gap. That is by no means a huge post; it fits easily onto my 11 inch screen. I shall move your post, however, because we usually discuss GUIs on another forum.

It works all right for me. I went to GIMP, drew a little devil, which I won't give you because I am embarrassed about its artistic quality (or crappiness), and saved that in a folder created specially for the occasion, called devil. Then I copied your .java file into that, with this one change: public class LabelDemo instead of labelDemo.
So now we have this folder structureThen I compiled it with javac -d . LabelDemo.java and now we have this sort of structure:[Then I ran it with java labelDemo.LabelDemo. And wondered, did he voluntarily choose cyan for the background?

I think you are supposed to use something like getClass().getResource("devil.gif"), which is discussed in a recent thread.
That won't work because you are working in a static context. You ought not to put everything into the main method anyway. It is better to set up a GUI in a constructor or a (private void) method like "initComponents()" or "setUpGUI()".
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38025
    
  22
Put your cursor after [code] and before [/code] to gain access to the code tags. Or highlight the code and click the code button afterwards.
And you can show the [ without spaces if you remember its Unicode number is 005b, by writing [code]
Bryce Heath
Greenhorn

Joined: Sep 16, 2011
Posts: 19
Hey guys
Thank you for the quick reply's. I love this board already, as I said had a bad experience with another one I joined after a quick google search " it will remain nameless" and found that even basic noobie questions took days to get a reply, and it was always from the same moderator, who for some one in charge of a forum was very snarky and not at all helpful. That being said glad its behind me lol, thank you for the quick code bracket tutorial I assumed it was something like that, glad to know how it works. I apologize for the miss post also I will try to be more mindful in the future. The example I posted is from the first 4 chapters of the book hence only having a main method, I think they are trying not to be to confusing yet. LOL no I did not choose cyan it was just what they listed in the example love the comment though thank you for the detailed post im going to go over it fully to make sure I understand. Looking forward to posting again, just started the creating your own classes chapter hehe. Thank you again for your help, and have to say that this seems to be a wonderful community here.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Bryce Heath wrote:Hey guys
This is my first post, and hope this board is alot more helpful towards new programers then the last one I joined. Apparently something about programing makes people a little rude lol.


Bryce Heath wrote:as I said had a bad experience with another one I joined after a quick google search " it will remain nameless" and found that even basic noobie questions took days to get a reply, and it was always from the same moderator, who for some one in charge of a forum was very snarky and not at all helpful.


16 minutes for a helpful response, actually, and I consider it rude of you to not reply to the response and cross post the question here.
http://www.javaprogrammingforums.com/whats-wrong-my-code/10912-wheres-my-devil.html

Your other two threads on that forum also had very decent responses, by several different members. I don't see any signs of snarkiness on the part of the moderators who responded in your threads. Your response at #7 in this thread could however be considered snarky.

luck, db
There are no new questions, but there may be new answers.
Bryce Heath
Greenhorn

Joined: Sep 16, 2011
Posts: 19
Hello Darryl
Im sorry that you are upset about how I felt, but I do feel it is my right and was not happy with the comments made. I said my piece, and was respectful in the fact that I dident say any names nor the site itself. Again I am sorry you are upset about how I felt, and hope it wont be a problem for you being apart of this forum instead.
Best wishes
Bryce
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Bryce Heath wrote:Hey guys
Thank you for the quick reply's. I love this board already, as I said had a bad experience with another one I joined after a quick google search " it will remain nameless" and found that even basic noobie questions took days to get a reply, and it was always from the same moderator, who for some one in charge of a forum was very snarky and not at all helpful. That being said glad its behind me lol


I don't want to argue here, but I'd like to point out that the three questions you asked in "the other forums" all had answers within 20 minutes (which is even faster than the response time here). If you thought my reply (I assume you're talking about me) was short, it was because you already received the correct answer but were ignoring it. Had you responded with a description of what about the answer you didn't understand instead of simply posting uncompilable code, it would have been much easier to help you.

But oh well. Happy programming.
Bryce Heath
Greenhorn

Joined: Sep 16, 2011
Posts: 19
Nor I Kevin, and thank you for the well wishes, glad to see that you to are so passionate about this. I guess I could feed in and have a pointless argument, but id rather read my java book. I do hope you guy will be as attentive to my other posts here as you were this one .
Again Best Wishes Bryce
 
 
subject: Java Software Solutions Graphics Example 3.9 noob help
 
Similar Threads
Icons and labels?
I can't load a file with getResource
Funny ImageIcon loading
Would my code help?!
Icons and a Label