Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

35.1 The visual framework > 35.1 The visual framework - Pg. 769

Chapter 35 The SCells Spreadsheet In the previous chapters you saw many different constructs of the Scala pro- gramming language. In this chapter you'll see how these constructs play together in the implementation of a sizable application. The task is to write a spreadsheet application, which will be named SCells . There are several reasons why this task is interesting. First, everybody knows spreadsheets, so it is easy to understand what the application should do. Second, spreadsheets are programs that exercise a large range of differ- ent computing tasks. There's the visual aspect, where a spreadsheet is seen as a rich GUI application. There's the symbolic aspect, having to do with formulas and how to parse and interpret them. There's the calculational as- pect, dealing with how to update possibly large tables incrementally. There's the reactive aspect, where spreadsheets are seen as programs that react in intricate ways to events. Finally, there's the component aspect where the ap- plication is constructed as a set of reusable components. All these aspects will be treated in depth in this chapter. 35.1 The visual framework We'll start by writing the basic visual framework of the application. Fig- ure 35.1 shows the first iteration of the user interface. You can see that a spreadsheet is a scrollable table. It has rows going from 0 to 99 and columns going from A to Z . You express this in Swing by defining a spreadsheet as a ScrollPane containing a Table . Listing 35.1 shows the code. The spreadsheet component shown in Listing 35.1 is defined in pack- age org.stairwaybook.scells , which will contain all classes, traits, and 769