From: Brett L. <wak...@ea...> - 2005-03-07 03:29:18
|
As I'm mucking about attempting to acquaint myself with AWT and Swing, I'm= faced with the following unpleasantness: My options for implementing a stock market GUI seem to end up in two= categories: 1. I can use the existing widgets, such as JTable, JButton, etc. to cobble= together something vaguely resembling a stockmarket. The downside being= that there are inherent limitations to these widgets because they are= generic widgets and weren't specially crafted just for me. 2. I can use something like java.awt.Graphics2D to explicitly draw every= element in the stock chart. The advantage being, I've got full control= over _everything_. The downside being that I then get to explicitly define= and implement _everything_, which seems like a rather large and daunting= task. Seeing as how I have the sneaking suspicion that when we get to working on= the hexmap we'll need to use option #2, I'm rather reluctant to use it for= the stockmarket as well (despite the seemingly obvious need for it). It didn't really help matters much that when I dug into the source of= Colossus for inspiration, I saw that they're making heavy use of= Graphics2D to draw damn near everything. On the up side, the Colossus= source does use one concept that will be important for the hexmap:= entrances and exits from a hex. I think we'll be able to use their ideas,= if not their code, for dealing with route calculation. However, I think= that whole discussion needs to wait until after the stockmarket is "done"= and/or somebody starts working on implementing the map. So, assuming that we take the long road and use Graphics2D for the stock= market GUI, here's how I'm thinking on doing it: 1. Use a square ( or rectangle ) for each location on the stockmarket. 2. Make the whole stockmarket reside in (extend) a JPanel, possibly within= a JTable. 2. Use the drawString() methods to render the values of each location onto= the square itself. 3. Create a circle object (chit) for representing each company's position= on the stockmarket; extends a JPanel. 4. Draw the chit (JPanel) on top of the location object. Use the layout= manager to achieve overlaying a JPanel on top of another JPanel. 5. Moving the chit ought to be a matter of moving the x,y location of the= chit and calling repaint(). Now, if only actually implementing it were so simple... :-) ---Brett. |