lecture14 - Introduction to Computation and Problem Solving...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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);
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern