DOC PREVIEW
TRINITY CSCI 1321 - GUIs in Java

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 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 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 71GUIs in Java2/12/20092Opening Discussion■Do you have any questions about the quiz?■Let's look at solutions to the interclass problem.■Do you have any questions about the assignment?■We will cover both mergesort and quicksort when we do recursion.3GUIs■One of the greatest benefits of Java is the vast size of the standard libraries and all the functionality they provide.■GUIs are part of this standard library and, in fact, there are two GUI libraries in Java.java.awt is the Abstract Windowing Toolkit and it was the original GUI package in Java.javax.swing was added later and is actually written in Java so it doesn't directly make calls to the windowing environment. Originally this hurt speed, but now it provides a lot of flexibility and power.4Swing Basics■We will be using Swing for everything in this class.■GUIs have a lot of inheritance and Swing stuff is built on AWT stuff.■Let's go look at some of the things in the javax.swing package.■All GUI elements in Swing inherit either directory or indirectly from JComponent. (Note that things in Swing often start with J to distinguish them from the AWT counterparts.)■We need a JFrame generally for the base window and we can put stuff inside of it.■The components include things like JButton, JList, JComboBox, JRadioButton, JCheckBox, JTree, JTable, etc.5Layout Managers■To place components inside of other components we use layout managers. We could position them directly, but this is very inflexible. The layout managers follow fairly simple rules for where things should go and how they change size as windows change size.■The nesting of components in components (and hence layouts inside of layouts) gives you a lot of power without needing complex layouts.■Commonly used layouts include GridLayout, FlowLayout, and BorderLayout.■Swing provides some custom components that do layouts for you.6Coding a GUI■Let's write a little GUI. I want a JTree on the left side of the frame with buttons above and/or below that say “Add” and “Remove”, a panel in the middle, and on the right I want a GUI that might be used for setting properties on a rectangle. At the least I'd like to set a width, height, and color.■Let's give the frame a menu bar. For now we can just add a “File” menu and have an “Exit” selection in it.7Minute Essay■Why should you use layout managers when programming GUIs instead of explicitly setting the positions and sizes of elements?■Remember the design for assignment #3 is due on Tuesday.■Interclass Problem – Build a GUI for a calculator. It needs the have buttons for the numbers, operators, and other functions. Use a JTextField for the display. You can decide exactly how to lay it


View Full Document

TRINITY CSCI 1321 - GUIs in Java

Documents in this Course
Recursion

Recursion

11 pages

Iterators

Iterators

10 pages

Actors

Actors

9 pages

Recursion

Recursion

15 pages

Recursion

Recursion

10 pages

Threads

Threads

7 pages

Trees

Trees

11 pages

Load more
Download GUIs in Java
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 GUIs in Java 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 GUIs in Java 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?