DOC PREVIEW
TRINITY CSCI 1320 - Creating GUIs

This preview shows page 1-2-3-4-5 out of 15 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Creating GUIs3-7-2011Opening DiscussionQuestions on the assignment?Finishing the example from last class.MotivationWhile text based programs still play a very big role in computing, it is mostly behind the scenes.You are far more used to working with Graphical User Interfaces (GUIs).It is time that we learn how to write GUIs in Scala.LibrariesThere are three libraries that will wind up being relevant to our discussion.java.awt – The Abstract Windowing Toolkit. Original Java GUI library.javax.swing – Swing was built on top of AWT to be more flexible.scala.swing – Scala code wrapped around Java Swing to aid Scala GUI programming.Making a WindowIn order to write a GUI we need to start by popping up a window.For the main window of a GUI, we will make a MainFrame. For other windows there are Frame and Dialog types.We can set the title and size fields of the MainFrame when we create it.Set visible to true to bring up the window.Oddly, we have to prevent the script from stopping.Active ComponentsGUIs are made from components. Use scala.swing package.Button(text:String)(action : => Unit).new CheckBox(label:String)selected:Booleannew ComboBox(items:Seq[A])selection.index to get the index of the current selectionnew EditorPane(contentType:String,text:String)More Componentsnew FormattedTextField(format:String)text:String that will tell you the textnew Label(text:String)new ListView(items:Seq[A]) Use collection selection.indices to interact with the index values that are selected.new PasswordField or new PasswordField(text:String)text:String will tell you the textMore Componentsnew ProgressBarmin:Int, max:Int, and value:Intnew RadioButton(text:String)selected:Booleannew ScrollBarminimum, maximum, and value are all IntsGenerally use ScrollPanenew Slidermin, max, valueorientationStill More Componentsnew Table(rowData: Array[Array[Any]], columnNames: Seq[Any])new TextArea(text:String)text:Stringnew TextField(text:String)text:StringPanes and PanelsWe build complex GUIs by nesting panels and panes.BorderPanelCan hold up to five different components in the north, south, east, west, and center positions. Add to the layout as a tuple of (Component, Position).BoxPanelCan hold a number of components either vertically or horizontally, each takes the space it needs. Use new BoxPanel(Orientation.Vertical). Use contents+=Button(“text”)(action).More PanelsFlowPanelComponents are laid out from left to right wrapping like text in a word processor. You can pass a variable length list of components as an argument at construction or add the components to contents.GridBagPanelThis panel is more complex.GridPanelHolds a regular grid of components. You specify how many rows and columns the grid has at creation.PanesScrollPaneHolds a single component passed in as an argument at construction. Scroll bars automatic. SplitPaneTwo components separated by a moveable bar.new SplitPane(Orientation.Horizontal, leftComp,rightComp)TabbedPaneOne component shown at a time. Tabs are always shown. Add components by adding Pages to the page object. pages += new Page(“A Tab”,tabComponent)MenusWindows can set the MenuBar.Add Menu objects to the contents of the MenuBar.Add MenuItems to the contents of the Menus.new MenuItem(Action(“Exit”){ exit(0) })GUI for NBA TeamsLet's spend the rest of class laying out and coding up a GUI we could use to view players and edit teams.Minute EssayIs there some type of GUI you would like to have as IcP #6.Assignment #2 is due on


View Full Document

TRINITY CSCI 1320 - Creating GUIs

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Creating GUIs
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Creating GUIs and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Creating GUIs 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?