lecture14

Lecture14 - Introduction to Computation and Problem Solving Class 14 Class Introduction to the Swing Toolkit Prof Steven R Lerman and Dr V Judson

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Introduction to Computation and Problem Solving Prof. Steven R. Lerman and Dr. V. Judson Harward Class 14: Class 14: Introduction to the Swing Toolkit Introduction to the Swing Toolkit 2 Class Preview Over the next 5 lectures, we will introduce you to the techniques necessary to build graphic user interfaces for your applications. Class 14: Introduction to Swing Basic Concepts: Components and containers, fonts, colors, borders, layout Class 15: Constructing Swing interfaces. Class 16: Lab: The Swing Event Model Class 17: Lab : How to do Custom Drawing in Swing, the Graphics 2D API Class 18: Lab : 2D Transformations in Swing 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3 Swing ) that library import java.awt.*; import javax.swing.*; See /books/ Package of user interface classes for windows, menus, scroll bars, buttons, etc. Independent of hardware and operating system (as long as they can paint a window Swing gains independence but loses performance by not relying on native toolkit components Has Windows, Motif, Mac look and feel options Supersedes Java Abstract Window Toolkit (AWT) though it still uses many non-drawing classes from http://java.sun.com/docs tutorial/uiswing/index.html 4 Let’s build a simple that displays today’s date: A Simple GUI Application application with a GUI, a date desk accessory 2
Background image of page 2
5 Getting the Date } } Converts Date If we are going to display the date, we first have to figure out what it is: import java.text.*; import java.util.*; public class Today0 { public static void main (String args[]) { DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL); Date now = new Date(); String dateStr = formatter.format( now ); System.out.println( dateStr ); Text Millisecond ticks since since January 1, 1970, 00:00:00 GMT A readable date 6 create an instance of a GUI class containing the String date and we make it visible: } Displaying the Date, Try 1 So, we’ve got the date. Let’s display it. We public static void main (String args[]) { DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL); Date now = new Date(); String dateStr = formatter.format( now ); Today1 today = new Today1( dateStr ); today.setVisible( true ); //today.show(); Our GUI class 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/29/2011 for the course CIVIL 1.00 taught by Professor Georgekocur during the Spring '05 term at MIT.

Page1 / 13

Lecture14 - Introduction to Computation and Problem Solving Class 14 Class Introduction to the Swing Toolkit Prof Steven R Lerman and Dr V Judson

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online