Presentation is loading. Please wait.

Presentation is loading. Please wait.

Field Trip #29 Creating an Event Calendar with Java By Keith Lynn.

Similar presentations


Presentation on theme: "Field Trip #29 Creating an Event Calendar with Java By Keith Lynn."— Presentation transcript:

1 Field Trip #29 Creating an Event Calendar with Java By Keith Lynn

2 JFrame A JFrame is a top-level container It can run in a stand alone program It can contain independent panels The JFrame has a title

3 JButton A JButton is a component that we can place on a JFrame It is a push button We can place a label in the button A JButton has a margin. If the label won't display, we can obtain the insets of the button and change the margin

4 JTextComponent In order to get input from the user, we will use a JtextField A JtextField is a JtextComponent It is a box on the screen We can retrieve the text in a box with the method getText()

5 iText We will use a third party library called iText iText was written by Bruno Lowagie It allows us to directly create PDF documents We begin with creating a Document object and then a PdfWriter The PdfWriter is created using the Document and a FileOutputStream attached to a file After we have completed the document, we need to save it

6 PdfContentByte There are many things we can place in a PDF document One way of adding content is to draw directly on it In order to do this, we obtain the PdfContentByte of the document We use the method getDirectContent on the PdfWriter

7 Finding Days of Month We make use of the Calendar class The Calendar class is found in the java.util package When we create a Calendar object, we will set the year, month, and day of the month the user specified Then using the field DAY_OF_WEEK, we can determine where the current day falls We can then fill in the numbers of the month

8 Drawing a Grid In order to draw the grid on the screen, we will use the PdfContentByte To create a line on the screen, we move to a certain location with the moveTo method Then we move to another location with the lineTo method After we have moved to all the locations, we call the method stroke Repeating this, we can draw a rectangle

9 Displaying Event We will make use of arrays in this app An array is a collection of elements of the same type The array we will create will contain objects that contain information about the current day of the week In particular, we will include whatever event the user entered

10 Displaying the Month After we have created the object representing the days of the week and the events, we use the method setTextMatrix to hold text We can change the font We can change the color We can change the font using a BaseFont We can change the color using a BaseColor After the events are displayed, we can save the document

11 The Calendar


Download ppt "Field Trip #29 Creating an Event Calendar with Java By Keith Lynn."

Similar presentations


Ads by Google