NetBeans the Definitive User Guide phần 1 pot

65 376 0
NetBeans the Definitive User Guide phần 1 pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

NetBeans: the Definitive Guide Table of Contents NetBeansinaNutshell 1.Introduction IsNetBeansForYou? 1 Is This Book For You? 2 NetBeansandJava 2 WhatareJavaBeans? 2 The Core Concept of NetBeans 3 NetBeans as the "Visual JDK" 4 AllTheUsualFeatures 4 NetBeans as a tools platform 5 NetBeans as an open source community 6 A Steady Stream of Creativity 6 Don't Be Cross That This Book Is Cross-Platform 6 Contents of the Accompanying Sources 7 Licensing of the Code Examples in this Book 7 Writing Conventions in this Book 7 CommentsandQuestions 7 Acknowledgments 8 Reviewers 8 SimeonGreene 8 VaughnSpurlin 9 JackWoehr 9 JesseGlick 9 TimBoudreau 10 2. Getting and Installing the IDE PlatformsandRequirements 11 What are the system requirements to run NetBeans? 11 Getting and Installing a JDK 12 TheJavaDevelopmentKit 12 Relationship of JDK to JRE 13 ObtainingtheJDK 13 WhichIDEDistribution? 14 InstallingBinaryDistributions 15 Building the IDE from Source (Simple builds) 16 What you'll need to build the IDE 16 Setting up and performing the build 17 Wheredideverythinggo? 18 How do I install a newly built version of NetBeans? 18 RunningtheIDE 19 Minimalenvironment 19 HowtoLaunchNetBeans 20 MultipleNetBeansusers 21 Troubleshooting 22 UpdatingtheIDEAutomatically 25 TheUpdateCenter 25 ConfiguringtheUpdateCenter 26 SetupWizard 27 You'renowrunningNetBeans 27 3.ConceptsandParadigms NetBeans and the Java abstract model of computing 29 Explorer 30 Objects in the UI are represented by NetBeans nodes 30 Data objects, nodes, and the concept of actions and properties 31 Tabs in the Explorer and their purposes 38 NodeParadigms 44 Sometimes Explorer Gets Behind the Times 47 FilesystemsandtheCLASSPATH 48 CreatingPackagesandClasses 52 CreatingPackages 52 CreatingClasses 52 Services 55 Compilerservices 55 Executionservices 57 Debuggingservices 57 Workspaces 58 Editing 59 GUIEditing 59 Browsing 59 Running 59 Debugging 59 Persistenceacrosssessions 59 Using multiple instances of Explorer in different workspaces. 60 Using multiple instances of the Source Editor in different workspaces. 60 ProjectManagement 60 Managingmultipleprojects 61 Managing project builds using Ant 62 ObjectBrowser 63 Summary 66 4. Working with the Source Editor Why learn a new editor? 68 OpeningtheSourceEditor 68 Contextmenus 69 ClosingtheSourceEditor 69 Codecompletion 69 Using (and Not Using) NetBeans Source Editor Code Completion 70 Updating the parser database to include new classes 71 Abbreviations 73 Editorcolorings 74 Shortcuts 75 Wordmatching 76 Indentation engines and code formatting 77 Automaticedits 77 OtherEditorFunctionality 78 Creating, editing, compiling and running a simple example 79 More on Customizing the Source Editor 82 5.Debugging DebuggerTypes 83 BreakpointTypes 84 Addingandremovingbreakpoints 85 Settingwatches 89 StartingtheDebugger 89 TheDebuggerWindow 90 TheVariablesView 92 RemoteDebugginginNetBeans 93 Howtodebugremotely 93 Caveats 95 Advancedfeatures 96 6. Compilation and Execution Services Using Custom Compilation and Execution Services 97 Creating and Customizing Internal Compilation Services 97 Creating and Customizing External Compilation Services 98 TheInternalExecutionService 103 Creating and Customizing External Execution Services 103 Associating Services With Java Files 104 Setting Default Services for Java Files 104 Setting Services for Specific Files 104 BuildingWithAnt 104 CreatingaBuildScript 104 ConfiguringtheAntModule 107 Executing and Compiling With Ant Scripts 108 WhyUseAnt? 108 7.Customizingtheenvironment TheSetupWizard 109 GeneralNetBeansSettings 109 ModuleInstallation 112 UpdateCenter 112 TheToolsOptionsDialog 113 ConfiguringToolbars 114 ConfiguringMenus 116 ConfiguringEditors 117 ObjectTypeAssociations 117 EditorSettings 118 Commandlineoptions 126 Modules 128 InstallingModules 128 EnablingandDisablingModules 131 8. Using Source Control (CVS) WhatisCVS? 133 The How, When and Why of CVS in NetBeans 135 WhentouseCVS 135 Where to get a client 135 How does NetBeans interact with CVS? 135 UsingGenericVCS 136 Using Command-Line CVS Support versus Built-in CVS 136 What parts of my project does CVS within NetBeans save? 137 Does NetBeans automatically add new files and packages I create to the repository? 137 How do I manipulate my NetBeans project directly with CVS outside of NetBeans? 137 MountingCVSsources 138 ExploringVersionedSources 138 Performing common CVS operations within the IDE 139 Checkout/Get 140 Checkin/Commit 141 AddandImport 141 Log 142 Diff 143 Update 144 UnexpectedResults 144 Spurious[Local]Designation 144 WhenAddingdirectories 145 WhenAddingbinaryfiles 145 Uncommon CVS operations within the IDE 145 Branching,MergingandTagging 146 NetBeans CVS and the Secure Shell (SSH) 146 Mounting and Customizing a Generic Versioning System 146 OneFinalTip 149 9.GUIBuilding How to create a GUI frame or panel 151 How to add components to a GUI container 155 Configuring components with the Component Inspector 156 Buildingmenus 157 How to change and configure a container's Layout 157 WorkingwithBorders 158 Accessibility 158 CopyingaSourceObject 159 TheConnectionWizard 159 TheGridBagLayoutCustomizer 161 Addingeventhandlers 164 Using the Code Generation Properties 166 NetBeans made a mistake in code generation, what are the workarounds? 168 ContainerswithinContainers 171 BuildingComplexGUIs 171 10.JavaBeans Why Should I Make Beans? 173 CreatingJavaBeans 173 CreatingaGUIComponent 174 Converting a GUI Component into a Bean 176 Adding an Event Set to a Bean 179 GeneratingaBeanInfoClass 181 AddingaDesign-TimeIcon 183 ComponentPalette 183 Adding a Category to the Component Palette 183 Adding a Bean to the Component Palette 184 ComponentPaletteProblems 185 11.UsingJavadoc JavadocSupportinNetBeans 186 Mounting Javadocs in the Javadoc Repository 186 TheJavadocSearchTool 187 CreatingyourownJavadoc 190 TheAutoCommentTool 190 JavadocGeneration 193 12.WorkingwithXML InstallingXMLSupport 196 Overview 197 Templates 197 BrowsingandEditing 197 GeneratingDocumentation 197 AccessingwithJava 197 Where'sXMLSchemaSupport? 198 XML Editors—Tree Editor and Text Editor 198 BeyondEditingXML 201 CheckingandValidatingXML 201 SettingtheNodeView 202 Generating Separate DTD from Existing XML 203 Generating Documentation to Help Humans Understand XML 204 GeneratingCSSfromDTD 206 Generating Java Classes to Handle XML 206 Generating a SAX Document Handler 206 Generating a DOM Tree Scanner 209 13.DevelopingWebApplications Why the IDE Supports Web Application Development 214 How the IDE Provides Web Application Support 214 CreatingaWebApplication 214 TheFilesystemsView 216 TheWebProjectView 217 Working with JSP and HTML files 218 AdvancedWebApplicationsFeatures 221 ExecutingWebApplications 221 WorkingwithServlets 222 Packaging and Deploying Web Apps 223 DeployingWebApps 224 ConfiguringTomcat 224 A.Resources CVSResources 227 CVSHome 227 GNU/BSD/OtherOperatingSystems 227 CVSGUIClients 228 JavaEnvironments 228 JavaTools 228 ApacheSoftwareFoundation 229 SecureShell(SSH)Resources 229 CygwinforWindows 229 NewsgroupsandMailingLists 230 WebSites 230 Organization of main NetBeans website 230 Mirrors 230 SunSites 230 Open source projects coded using NetBeans which include NetBeans design forms in the distribution 231 Java-oriented IDE's other than NetBeans 231 Bibliography ExtendingNetBeans Foreword—byJamesGosling 1.Introduction Who Should Read this Book? 249 What’sDifferentaboutNetBeans? 250 The Core and the Open APIs 250 TheLicense 251 Open-Source 252 Thenetbeans.orgWebSite 252 NetBeansforBeanCounters 254 Getting and Installing the Open APIs Support Module 255 LifeisChange 256 Source code for the examples 256 2.HistoryofNetBeans HumbleBeginnings 257 FirstSuccesses,FirstCosts 258 SunMeetsNetBeans 259 Open-Source,Fire-DrillStyle 260 NetBeansToday 260 3. Understanding the NetBeans APIs DesignPhilosophyofNetBeans 261 Abstracting the Abstractions—the Open APIs 262 Modularity 262 Hierarchy,FilesandNodes 263 EverythingisaFile—Virtually 263 Mapping Files to Java Objects 264 TheSystemFilesystem 265 ModuleLayers 265 Layers in the System Filesystem 266 ExploringtheSystemFilesystem 267 Data Objects—Wrappers for Persistent Data 270 NetBeansandJavaBeans 270 Nodes—theApplicationasHierarchy 270 Presenting Nodes to the User—Explorer 271 User-LevelCustomization 273 Nodes in Action—Customizing the IDE without Writing Code 275 Modules—Overview 278 HowModulesAddFunctionality 278 How Modules Install Virtual Filesystem Layers 279 WhatModulesCanDo 279 DisablingModules 280 An Illustration—NetBeans with No Modules at All 280 Interacting with the IDE through Internal Execution 281 Setting the Status Bar Text 282 SettingtheCurrentWorkspace 283 4.TheOpenAPIs The IDE’s Architecture and the APIs 284 APIs versus Core versus Modules 285 Service Provider Interfaces and Client APIs 286 Overview of the APIs and Their Purposes 286 Modules 287 Lookup and the Services API 294 Nodes 296 Datasystems 299 Explorer 299 Actions 304 Options 305 Compiler 305 Editor 306 WindowingSystem 307 Cookies 309 Execution 310 JavaHierarchy 310 Filesystems 311 Modules, JARs, and Class Loaders 312 Threading, Deadlocks, and How to Avoid Them 317 5. Developing Modules—the New Module Wizard TheHelloWorldModule 319 Creating a Module Using the New Module Wizard 319 TheSourceFiles 320 6. Internals of the Running IDE TheActivatedNode(s) 323 Cookies 324 A Peek under the Hood—Examining the Activated Nodes with the CurrentNodeViewer 325 Touring NetBeans with the Bean Browser 325 Data Objects, Nodes and Cookies 327 FilesystemsandtheRepository 327 Services 328 Lookup 329 Options 330 UIComponents 331 TopComponents,ModesandWorkspaces 331 Actions 336 Presenters 337 CustomPropertyEditors 337 Localization 337 Wizards 338 Jumping-offPlaces 338 Special Folders in the System Filesystem 339 7. Creating the QuickPanel Module Abstractions Covered in this Chapter 342 Creating the Project Files Drop-Down 343 FilterNode—Filtering Which Children of a Node are Displayed 347 CreatingtheMethodsDrop-Down 349 ImprovingtheMethodsDrop-Down 350 CreatingtheModule 353 Creating a Container GUI Component 354 CreatingtheShowQuickPanelAction 354 Creating the XML Filesystem Layer 355 Creating and Populating the Module JAR 356 Building and Testing the Module 356 ALittleHomework 357 8.AMail-BasedFilesystem Building a Mail Reader in the NetBeans Paradigm 358 Implementing MailFileSystem Using AbstractFileSystem and JavaMail 359 Creating a New AbstractFileSystem Implementation 359 MailFilesystem:AbstractFileSystem.Info 360 MailFilesystem:AbstractFileSystem.List 361 MailFilesystem:AbstractFileSystem.Change 362 MailFilesystem:AbstractFileSystem.Attr 363 OtherPartsofAbstractFileSystem 363 Creating Folder Objects for Attachments 366 Using FileSystem.Status Annotations to Mark Unread Messages 367 BeanInfo—DisplayingFilesystemProperties 369 Using the Wizard Framework to Set Up Mail Accounts 371 CreatingWizardClasses 371 The IMAP Mail Server Template Wizard 372 9. Creating the User Interface for the Mail Client Creating a DataLoader for Messages 381 Displaying and Editing Simple Messages and Unnamed Attachments 382 HandlingMultipartMessages 386 Creating a Threaded Mail View Using Filter Nodes 387 Making a Basic Mail View 388 Making a Threaded Mail View as an Alternative 394 CreatingaMailWorkspace 400 10.ScoreFileSupport Overview—FunctionalitytobeImplemented 406 Creating the Minicomposer Module—First Things 406 CreatingtheManifest 406 CreatingtheLayer 407 Creating a JAR File Using Ant 408 Creating a UniFileLoader and MultiDataObject for *.score Files 408 Creating an Editor Support for Scores 411 Creating a Fixed ExecCookie to Play Scores 414 CreatingaSimpleTemplate 417 11. Creating a Structural View of the Score Creating a ScoreCookie to Represent a Sequence of Notes 419 Examples of State-Based Supports in the NetBeans APIs 420 CreatingaScoreSupport 421 Why a Document is Used 421 ImplementationofScoreSupport 422 LifecycleoftheScore 426 AnOpenSupport 426 CreatinganOpenCookieImplementation 427 Showing a GUI View of the ScoreCookie 429 Indicating Parse Errors on the Node 433 12.CompilingScores What Does NetBeans Mean by “Compilation”? 437 CreatingtheCompilersThemselves 437 Creating and Using the Compiler Cookie 441 Displaying an Out-of-Date Badge on Score Icons 445 13.ExecutingScores Execution Service Types—Internal and External 448 Creating the .au Player Executor 448 TheInternalPlayer 449 TheExternalPlayer 451 Registering the Players as Services 454 Creating Player Configuration Support (ExecSupport) 457 Creating a SystemOption for the Default Executor 461 14. Better Score Support in the Explorer TheClipLengthProperty 467 Clearing the Cache and Firing Changes 469 Adding the Property to the Property Sheet 470 Representing Notes as Subnodes Using Children.Keys 470 Using Keys to Model Children 471 Being Lazy and Cleaning Up 473 CreatingtheSubnodes 474 Attaching the Children to the Parent 475 Permitting Subnodes to be Renamed or Deleted 476 DeletionofNotes 476 RenamingofNotes 477 Permitting Subnodes to be Added 479 Making Read/Write Properties on Subnodes 481 ReorderingSubnodes 484 Data Transfer—Cut, Copy, and Paste of Notes and Sequences 489 OverviewoftheTransferables 490 CuttingandCopying 491 Pasting 492 Drag&Drop 495 Converting Score # Text, Text # Score, Several Scores # One 495 15. Tuning Modules for Performance & Memory Footprint Startup Performance vs. Runtime Performance 501 OperatingPrinciples 501 “Nobody Will Ever Use My Module” 501 What Does My Module Really Need to Do on Startup? 501 What are the Critical Paths? 502 Techniques 503 LazyInitialization 503 AvoidStaticInitializers 503 Avoid ModuleInstall Classes—Use XML Layers Instead 504 Partial Loading Considerations—InstanceCookie and InstanceDataObject 505 Use URLs Instead of CDATA Sections in XML Layers 505 Reduce the Number of Classes You Create 505 GUIComponents—WaitforaddNotify() 505 Using the addNotify() and removeNotify() Pattern Where Exposed by Non-GUI Classes 506 Use Weak and Soft References for Objects which May Not be Needed Forever 506 UseWeakListener 508 AvoidExcessiveEventFiring 508 AvoidOveruseofThreads 508 BatchingEvents 509 SwingPerformance 509 16. Producing Modules (Packaging & Distribution) Versioning 511 Version Numbers and What They Mean 511 SpecifyingDependencies 512 ManagingInter-ModuleDependencies 513 UpgradingUserSettings 516 Settings History and Physical Format 517 UpgradeScenariosforSettings 518 What Happens When a Module is Disabled? 520 UserDevelopmentData 521 BundlingExtensionLibraries 521 ReferencingLibrarieswithClass-Path 522 UsingAutoloadLibraryModules 523 Ad-Hoc Resources and Module Installer Validation 525 InternationalizationandAccessibility 526 I18NandL10N 526 A11Y 528 JavaHelp—WritingandDistributing 529 CreatingaHelpSet 529 Adding a Help Set to NetBeans 531 AddingContextHelp 534 SeparatingHelpfromCode 535 SupportingUser-LevelJavaAPIs 535 SupplyingaParserDatabase 535 BundlingJavadoc 536 Adding to the Default Classpath 537 Templates 538 BeanInstallation 539 Creating the Module JAR File within the IDE 540 Creating a Build Script Using Ant 540 Producingthe.nbmFile 541 [...]... 18 2 10 .4 The AddStrings Bean icon 18 3 10 .5 Creating a new component palette category 18 4 10 .6 The AddStrings Bean in the component palette 18 4 11 .1 The Javadoc Repository 18 6 11 .2 The Javadoc Search Tool 18 7 11 .3 Select the text to search for in Javadocs and hit Ctrl+F1 18 9 11 .4 The search tool starts... 11 6 7.8 Global key bindings 11 8 7.9 The fonts and colors editor 12 0 7 .10 The color picker 12 1 7 .11 The font picker 12 3 7 .12 Recording a macro 12 4 7 .13 Editing macros 12 5 7 .14 Indentation Engine 12 6 7 .15 IDE command line options 12 7 7 .16 The Auto Update... 10 5 6.8 Ant Help page 10 6 7 .1 The first pane of the Setup Wizard 10 9 7.2 An editor window with a filesystem explorer docked on the left 11 1 7.3 The second pane of the Setup Wizard 11 2 7.4 The third pane of the Setup Wizard 11 2 7.5 Toolbar options 11 5 7.6 Changing the toolbar button order 11 5... 16 2 9 .11 Generating an ExitItem event 16 5 9 .12 Selecting an event handler 16 5 9 .13 The AddStrings example running 16 6 9 .14 Adding post-creation code 16 7 9 .15 Creating a custom template category 16 9 10 .1 Copying AddStrings components 17 4 10 .2 Testing the AddStrings Bean 17 8 10 .3 The BeanInfo... 18 9 11 .5 The Javadoc Auto-Commenting Tool 19 1 11 .6 Adding Javadoc Links 19 4 12 .1 Installing modules for XML support 19 6 12 .2 The XML tree editor and text editor 19 8 12 .3 Adding a new attribute 19 9 12 .4 DTD and data nodes 202 12 .5 DTD separated from an XML document 203 13 .1 A web application... 10 8 Why Use Ant? 10 8 7 Customizing the environment The Setup Wizard 10 9 General NetBeans Settings 10 9 ModuleInstallation .11 2 UpdateCenter .11 2 The ToolsOptions Dialog 11 3 ConfiguringToolbars .11 4 ConfiguringMenus 11 6 ConfiguringEditors 11 7 Object... Center - Pane 1 12 8 7 .17 Installing modules from the web 12 9 7 .18 Completing Installation of modules for the web 13 0 7 .19 Installing modules manually 13 1 8 .1 Summary of how CVS extends RCS 13 4 8.2 The Version Explorer window 13 8 8.3 The GUI style CVS options dialog for an update 14 0 8.4 Browsing the CVS log... 209 12 .10 visitElement_Part method with all changes applied 210 12 .11 main method with all changes applied 211 12 .12 import statements for Transformer references 212 12 .13 Output from Inventory_InventoryScanner 212 13 .1 Source Listing for index.jsp 220 Chapter 1 Introduction Chapter 1 Introduction Table of Contents Is NetBeans For... 10 .1 Setting wizard properties for the AddStrings Bean 10 .2 Setting component directions 10 .3 Setting wizard properties for event listeners 11 .1 Javadoc Search Tool Buttons 11 .2 Method Filtering Buttons 11 .3 External Javadoc Executor 11 .4 External Javadoc Executor 11 .5 Additional... the IDE Platforms and Requirements 11 What are the system requirements to run NetBeans? 11 Getting and Installing a JDK 12 The Java Development Kit 12 Relationship of JDK to JRE 13 Obtaining the JDK 13 Which IDE Distribution? 14 Installing Binary Distributions 15 Building the . 10 9 GeneralNetBeansSettings 10 9 ModuleInstallation 11 2 UpdateCenter 11 2 TheToolsOptionsDialog 11 3 ConfiguringToolbars 11 4 ConfiguringMenus 11 6 ConfiguringEditors 11 7 ObjectTypeAssociations 11 7 EditorSettings. 10 9 GeneralNetBeansSettings 10 9 ModuleInstallation 11 2 UpdateCenter 11 2 TheToolsOptionsDialog 11 3 ConfiguringToolbars 11 4 ConfiguringMenus 11 6 ConfiguringEditors 11 7 ObjectTypeAssociations 11 7 EditorSettings. 15 7 WorkingwithBorders 15 8 Accessibility 15 8 CopyingaSourceObject 15 9 TheConnectionWizard 15 9 TheGridBagLayoutCustomizer 16 1 Addingeventhandlers 16 4 Using the Code Generation Properties 16 6 NetBeans

Ngày đăng: 12/08/2014, 21:20

Mục lục

  • NetBeans in a Nutshell

    • 1Introduction

      • Is NetBeans For You?

      • Is This Book For You?

      • NetBeans and Java

        • What are Java Beans?

        • The Core Concept of NetBeans

        • NetBeans as the "Visual JDK"

          • All The Usual Features

          • NetBeans as a tools platform

          • NetBeans as an open source community

            • A Steady Stream of Creativity

            • Contents of the Accompanying Sources

            • Licensing of the Code Examples in this Book

            • Writing Conventions in this Book

            • Comments and Questions

            • Acknowledgments

              • Reviewers

              • Simeon Greene

              • Vaughn Spurlin

              • Jack Woehr

              • Jesse Glick

              • Tim Boudreau

              • 2Getting and Installing the IDE

                • Platforms and Requirements

                  • What are the system requirements to run NetBeans?

                  • Getting and Installing a JDK

                    • The Java Development Kit

                    • Relationship of JDK to JRE

Tài liệu cùng người dùng

Tài liệu liên quan