TextEditor Tutorial - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

TextEditor Tutorial

Description:

TextEditor Tutorial. Development of a JBuilder Application. TextEditor 1 ... Step 16: Deploying the Text Editor application to a JAR file. TextEditor Files. Main class ... – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 23
Provided by: Jo66
Category:

less

Transcript and Presenter's Notes

Title: TextEditor Tutorial


1
TextEditor Tutorial
  • Development of a JBuilder Application

2
TextEditor 1
  • Tutorial Building a Java text editor
  • Step 1 Setting up
  • Step 2 Adding a text area
  • Step 3 Creating the menus
  • Step 4 Adding a FontChooser dialog
  • Step 5 Attaching a menu item event to the
    FontChooser

3
TextEditor 2
  • Step 6 Attaching menu item events to
    JColorChooser
  • Step 7 Adding a menu event handler to clear the
    text area
  • Step 8 Adding a file chooser dialog
  • Step 9 Adding code to read text from a file
  • Step 10 Adding code to menu items for saving a
    file

4
TextEditor 3
  • Step 11 Adding code to test if a file has been
    modified
  • Step 12 Activating the toolbar buttons
  • Step 13 Hooking up event handling to the text
    area
  • Step 14 Adding a context menu to the text area

5
TextEditor 4
  • Step 15 Showing filename and state in the window
    title bar
  • Step 16 Deploying the Text Editor application to
    a JAR file

6
TextEditor Files
  • Main class
  • TexEditClass.java
  • Most Event handlers
  • TextEditFrame.java
  • Information frame
  • TextEditFrame_AboutBox.java

7
ImageIcons
  • Icons in source directory
  • OpenFile.gif
  • CloseFile.gif
  • Help.gif

8
Screenshot 1
9
TextEditFrame 1
  • ContentPane
  • BorderLayout
  • ToolBar
  • Button1
  • Button2
  • Button3

10
TextEditFrame 2
  • ScrollPane1
  • jTextArea1
  • StatusBar
  • jFileChooser1 popup window

11
Screenshot 2
12
FileChooser
13
AboutBox
14
MenuBar 1
  • MenuBar
  • MenuFile
  • MenuItem1 to 5
  • Menu1
  • MenuItems1 to 3
  • MenuHelp
  • MenuHelpAbout
  • Menu - double click for Menu Tool

15
MenuBar 2
16
MenuBar 3
  • MenuBar not visible user adds Java code
  • this.setJMenuBar(menuBar1)
  • Compare with original master
  • Add events by using the JB tool

17
ToolBar 1
  • Menu items selected via ImageIcons
  • Add manually
  • ImageIcon image1
  • ImageIcon image2
  • ImageIcon image3
  • image1 new ImageIcon(TextEditFrame.class.getReso
    urce("openFile.gif"))
  • image2 new ImageIcon(TextEditFrame.class.getReso
    urce("closeFile.gif"))
  • image3 new ImageIcon(TextEditFrame.class.getReso
    urce("help.gif"))

18
User Modification
  • This example may be modified to provide general
    file handling functions.
  • // Call openFile to attempt to load the text from
    file into TextArea
  • Call to openFile
  • jFileChooser1.getSelectedFile().getPath()
  • jFileChooser1.getSelectedFile().getName()

19
References 1
  • TextEditor Tutorial
  • http//info.borland.com/techpubs/jbuilder/jbuilder
    9/designui/texteditor/tetutorial.html
  • Free Java Tutorials
  • http//www.freeprogrammingresources.com/jbuild.htm
    l

20
References 2
  • Tutorial Creating a GridBagLayout in JBuilder
  • http//info.borland.com/techpubs/jbuilder/jbuilder
    9/designui/gridbaglayout/intro.html
  • Using GridBagLayout
  • http//info.borland.com/techpubs/jbuilder/jbuilder
    9/designui/gridbaglayout/part1.html

21
References 3
  • Prototype your UI in XYLayout
  • Advocates - Creating layout using XY and switch
    to GridBagLayout
  • The main advantage to prototyping your UI design
    in JBuilder's XYLayout is that this layout keeps
    components at the exact pixel location and size
    as you create them.

22
References 4
  • JBuilder documentation
  • Separate download
  • Installs into JBuilder Directory
  • http//info.borland.com/techpubs/jbuilder/
  • Provides about 50 prebuilt projects
  • TextEditor is an example
Write a Comment
User Comments (0)
About PowerShow.com