Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!

Greg Brannon

Bartender
+ Follow
since Oct 24, 2010
Maryland, USA
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
89
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Greg Brannon

I don't understand the question. Why do you think there's a problem? Describe what you think the problem is with evidence and how the problem would act differently if there was no problem.
Was the condition of the ASUS laptop a SECRET, or could you have learned about it with more research, a visit to a forum, a call to ASUS customer support beforehand, etc? I often find out details available in the public domain about a product after I already own it that might have convinced me not to buy it had I known them before making the decision. I feel cheated afterwards, but I have to accept that it's really my fault.
3 years ago
Your understanding wasn't wrong, just incomplete. These simple exercises are meant to not only demonstrate simple concepts but to be played with to explore and better understand the subtleties that everyone sees differently. It's great that you're typing out and running the examples, but don't be satisfied to just get them 'working.' Ask yourself, "What happens if i do this?" then make those minor modifications or vary the inputs to see what happens.

Keep coding!
3 years ago
To advance your understanding of the read() method, try typing a number of characters and see what happens. Something like, "abcdefghi<return>". How many passes were shown? How many characters were typed?
3 years ago
I can't judge your interpretation of the book's message, but perhaps you can gain some insight to the program's behavior by examining the API for System.in.read(). Note that input from the keyboard includes the character(s) typed and the Enter key or <return>.
3 years ago
An intriguing question, but I don't think you've given us enough info for an assessment of what might be going on. Knowing whether you call repaint() and/or revalidate() after adding components and when would be helpful.

On the whole, adding components to a container while the Swing application is running has always been challenging. It can be done, even reliably I think, but mechanisms were provided to avoid having to hassle with it. For example, to do what you describe I recommend using CardLayout with at least 2 different 'cards.' One will be visible at all times while the other is being built in response to user input. Then, when the the newly built card is ready, it is made visible, replacing the currently visible card.
4 years ago
Per this page, quoting allows embedding white space in array elements. There may be other helpful hints on that page if this one is not sufficient.
4 years ago
Start here, and then come back with more specific questions.
4 years ago
When source code doesn't successfully compile, there are resulting compiler errors that are helpful to explain and locate the errors. Learning what those errors mean is an important step in debugging your code. Please copy and paste the error and stack trace into your post so that we can help you understand the error and learn what to do about it or them.

Good luck!
4 years ago
I don't see how your example would contribute to safety or neatness. Frankly, a square only requires one field. Then, since the area of a square is calculated from width x height (which are equivalent) then this gives the opportunity to create a getter or accessor method that returns a calculated result based on the single existing value. While you (and others) might see the attribute area as a useful field, others might see it as unnecessary.
4 years ago
Not videos, but you should consider starting withOracle's Swing Tutorials. They lean towards using Netbeans (fine) and the GUIBuilder (not so fine). First, learn to code Swing aps by hand.
4 years ago
And what's the one question?
4 years ago
Have you considered using an EventBus or something like that? What you have outlined is similar to an Observable/Observer pattern, except your pattern outline requires the class originating the event to be responsible for knowing which classes have subscribed to which events and then responsible for notifying each subscriber. A much more flexible design that is easier to modify and maintain would be to simply send the event to the event bus and let those classes interested in that event become aware of it and take the desired action.

I've just learned EventBus so am kind of high on it, and what you describe seems to be a great application for it. The EventBus examples and tutorials available on the web aren't great, but this is the simplest one I could find that was easily understandable and scalable to my own examples. I have written my own study from that tutorial that I can share with you on request.
4 years ago
Put this project down for a sec and write a simple container with a text box that adds text driven by a javax.swing.Timer. Get it started and come back when you need help.
4 years ago