This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
I've been asked to write an applet or an application that will create a simple equation (using basic signs like /*+-). At the moment I don't really know where to start. Especially how to render the equation after lets say typing it in a text field or something. Should I use JLabels or java graphics drawstring or maybe something else?
Preferably I would use an MVC. Any suggestions? Please help!
P.S. I don't want to use ready made frameworks. I need to write all on my own...
Read that VERY carefully and thoroughly. Then read it again.
Any time someone says "I want to use X", they are putting the cart before the horse. That's like going to a construction site and saying "I am going to use a saw" - when what may be needed is a tool to drive nails into wood.
You should not let the technology drive your design, but let your design drive the technology.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Okay the idea is to make a model class that will break the string onto separate signs/variables. The view part will use JPanels of nested JLabel inside with a sign or a variable. But how to arrange such blocks? What layout should I use?
Slawomir Wieczorek wrote:Okay the idea is to make a model class that will break the string onto separate signs/variables. The view part will use JPanels of nested JLabel inside with a sign or a variable.
Whoa there. You haven't even described what the "break the string into separate signs/variables" part is supposed to do, and you're already deciding how you're going to display it?
This is precisely what Fred was talking about:
Describe your solution in English (or your native language), NOT in Java-ese. The second you start putting Java class names into a description, we know that you've leapt to an implementation far too soon, so DON'T DO IT.
But how to arrange such blocks? What layout should I use?
My advice: Don't worry about it for the moment.
Your problem appears to have two major parts:
1. Breaking up the String.
2. Displaying the result.
and neither one has anything much to do with the other.
Get part 1 working properly first, and then deal with part 2. And even then, keep them as separate as you possibly can.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here