Vous êtes sur la page 1sur 26

LESSON-3 GETTING STARTED WITH PROGRAMMING USING IDE

INTRODUCING NETBEANS JAVA IDE

2/23/2012

Created By: Priyanka Pareek

II. Characteristics of Java


Write Once Run Anywhere (WORA) Light Weight Code Security Built-in-Graphics Object-oriented Language Supports Multimedia Platform Independent Open Product
2/23/2012 Created By: Priyanka Pareek 2

III. Rapid Application Development (RAD)


RAD is possible through RAD tools. RAD tools are the tools that enable one to create application in shorter times as compared to conventional language. A range of application can be created with RAD tools. Rapid Application Development (RAD): it describes a method of developing s/w through the use of pre-programmed tools or wizards. The pre-programmed tools or controls are simply dropped on a screen to visually design the interface of application RAD tools are used to develop or create Prototypes of the large application. A prototype is the first model that is made of something.

2/23/2012

Created By: Priyanka Pareek

IV. NetBeans Java IDE


NetBeans IDE is a free, open-source, cross-platform IDE (Integrated Development Environment) with buit-in support for Java Programming Language. The NetBeans runs anywhere theres a Java Virtual Machine (JVM) NetBeans offers many features for application development, such as:
Drag-and-drop GUI creation Excellent editing ((advanced source code editor) Web-services Excellent debugging Wizards, code generation and management tools and many more.

2/23/2012

Created By: Priyanka Pareek

Visual Tour of NetBeans

2/23/2012

Created By: Priyanka Pareek

Visual Tour of NetBeans


The NetBeans has many features. The various components of NetBeans IDE are as follows:  Title Bar: It displays the title of the application. By default NetBeans give names as Java Application1, java Application2. Etc. to the project.  Menu bar and Pull Down Menus: A menu bar is displayed directly below that title bar and includes a lot of options. Each option on the menu bar has drop-down list of items (known as Pull-Down Menus) that help you perform various tasks.  Toolbar: A toolbar is a bar that displays icons for commonly used tasks. The Standard Toolbar of NetBeans IDE displays icons for the most frequently used commands in NetBeans.

2/23/2012

Created By: Priyanka Pareek

2/23/2012

Created By: Priyanka Pareek

 GUI builder: also called as Design Space or Design Area. The design area is where user will visually construct GUI.  It is primary workspace within which GUI design takes place in the IDE.  The GUI Builder enables user to lay out forms by placing components where they are required. Click on an object to select it in the Design Area. For a multiple selection, hold down the Ctrl key while clicking on objects.  It has two views Source View and Design View. Design View is the default and Source view opens the code editor for user where addition or deletion for an application takes place.

2/23/2012

Created By: Priyanka Pareek

 Palette: it contains all of the components needed to create GUI applications. A customizable list of available components containing groups for Swing, AWT (Abstract Window Toolkit), Borders, and Beans components. This window enables user to create, remove, and rearrange the categories displayed in the palette using the customizer.  Frames: A frame is a window that typically had decorations such as a border, a title, and buttons for closing and iconifying itself. A GUI application typically uses at least one frame. Frames are used to display things like labels, text fields, buttons and other controls.  Controls: Controls are component object such as text fields, labels, list boxes etc. that are drawn on frame to get data input or to display output.
2/23/2012 Created By: Priyanka Pareek 9

 Inspector window: this window displays a tree hierarchy of all components contained in the currently opened form. Displayed items include visual components such buttons, labels menus and panels as well as non visual components such as timers and data sources. Properties window: This window displays the editable settings for the currently selected component. A display of the properties of the component currently selected in the GUI Builder, Inspector window, Projects window, or Files window.  Code Editor window: it is the window where user write Java Code for an application. It serves as an editor for entering application code. A separate code window is created for each top level frame that user create in application.

2/23/2012

Created By: Priyanka Pareek

10

2/23/2012

Created By: Priyanka Pareek

11

2/23/2012

Created By: Priyanka Pareek

12

V. Basics of GUI
 Introduction: GUI stands for Graphical User Interface. It refers to the windows, buttons, dialogs, menus and everything visual in modern application. It is not only GUI components. It also involves properties of its components, actions, events etc. Working of a GUI: when an action is performed, an event is generated. In Event-Driven Programming (EDP), that most GUI follow responds to an event. Working of Windows, Events and Messages:
 Windows: Many types of windows are present like document window, dialog box etc. Some other types are command button, icons, text boxes option buttons and menu bars. Win. OS manages all of these many windows by assigning unique id no. (called Window handle). Computers monitors for signs of activity or in other words events.  Events: An event refers to the occurrence of activity. Each time an event occurs, it causes a message to be sent to the operating system. Events can occur through user actions such as a mouse click or a key press, through programmatic control, Created By:as a result of another windows action. or even Priyanka Pareek 2/23/2012 13

1.

Working of a GUI:  Message: a message is the information/request sent to the application.

2.GUI in Java: In Java GUI features are supported by Java Foundation Classes (JFC), which encompasses a group of features for building GUI and adding rich graphics functionally and interactivity to Java applications.
  Major feature of JFC is Swing API, which includes everything from buttons to split panes to tables and any other functionality to create a GUI application. GUI programs are build by using Swing APIs features. GUI programs that will be create in Java will contain three tiers of s/w:

Graphical Components that make up the GUI. Each graphical component has certain Properties. A property is a characteristic of an object as its size, color, title etc.
  Event Listeners that get notified about the events and respond to them. Event Handler that do the work for the user in case the event occurs.
Created By: Priyanka Pareek 14

2/23/2012

VI. Java GUI Toolkit:


 Java GUI is created with three kinds of object: Components Events and Listeners.  Component is an object that defines a screen element such as a push button, text field, scroll bar, menu etc. The components which user uses to create GUI in Java are available through Swing API.  Types of Graphical Components: Container Control: it is a control that can hold controls within it. E.g a Panel (there can be multiple controls inside a Panel) or Panes or Frames. Child Controls: are the controls inside a Container is called a Child Controls. They exist completely inside a containers.  A control is also known as a Widget (short for window gadget).
2/23/2012 Created By: Priyanka Pareek 15

VI-A. Basic Graphical Controls of Swing


The Palette of graphical controls offered by Java Swing contains the tools that user draw controls on forms/window/frames. The area on the frame where GUI components are placed is called Content Pane. Common Controls of Swing Control Palette; JFrame (Frame): provides the basic attributes and behaviour of a window. A frame is displayed as a separate window with its own title bar. JLabel (Label): allows an un-editable text (i.e. that user cannot change or icons to be displayed. JTextField (Text area): allows user input, can also be used to display text. As it can be edited, it can be call as edit field. JButton: (Button) provides button capabilities. An Action Event is generated when buttonCreated By: Priyanka Pareek is pushed. 2/23/2012 16

Basic Graphical Controls of Swing

JLabel

JList

JButton JCheckBox

JPanel

JComboBox JRadioButton

2/23/2012

Created By: Priyanka Pareek

17

Basic Graphical Controls of Swing


JCheckBox: provides checkbox. Checkboxes are used to allow a user select multiple choice. JList: is a list of items from which a selection can be made. From a list, multiple elements can be selected. JComboBox: provides a drop-down list of items from which a selection can be made or new items can be added. It is a combination of list and a text field. JPanel: is a supporting container that cannot be displayed on its own but must be added to another container. Panels can be added to the content pane of a frame. They help to organize components in GUI. JRadioButton: provides radio buttons. Radio buttons are option buttons that can be turned on or off. The radio buttons provide mutually exclusive options
2/23/2012 Created By: Priyanka Pareek 18

VI-B. To draw control on Frame/Window


 Click on the desired controls icon on the Palette.  Now drag it to desired location in Frame/Window

VI-C. To remove a control from the Frame/Window


 Select the control to be deleted by, by clicking it. The controls appear selected, notice the rectangular boxes at corners and sides.  Press Del (or Delete) key. The selected control gets removed.

VI.-D. To Move/Resize a Control:


 To move a control drawn, click the object in the middle and drag it to the new location. Now, release the mouse button.  To resize a control, select it first and then use its sizing handle to resize it.
2/23/2012 Created By: Priyanka Pareek 19

Creation of an application

2/23/2012

Created By: Priyanka Pareek

20

2/23/2012

Created By: Priyanka Pareek

21

2/23/2012

Created By: Priyanka Pareek

22

Running of an application

2/23/2012

Created By: Priyanka Pareek

23

VII. Object naming Conventions


 Names are essential for naming the controls if it is not done by user then NetBeans IDE automatically gives name to it. For naming controls these things can be kept in mind:
Must begin with a letter Must contain only letters, numbers and underscore character(_); punctuation characters and spaces are not allowed. Omit the initial letter J in object names user may add its type at the end of it. e.g ReCalculateCheckBox for an object of class JCheckBox.

 Friendly names: when naming a control, the first letter of the friendly name is generally is in uppercase, so it is easily differentiate between the friendly name and the controls abbreviations e.g. ReadOnlyCheckBox  To name a control:
2/23/2012

 In Inspector window double-click the window too be named.  Type the new name
Created By: Priyanka Pareek

24

VIII.

Components, Events and Listeners

 To add functionality or behaviour to components, user must know about the events and listners. They 3 major players that add functionality to GUI are: The Events: an event is an object that gets generated when user does something such as mouse click, dragging, pressing a key etc. The Source of the Event: The component where event has occurred, is the source of the event. The Event Listener: An event listener is attached to a component and contains the method/functions that will be executed, in response to an event.
Listener Interface: An event listener stores all the methods, that it will implement in response to an events, inside the listener interface.

Focus: it is ability to receive input by a component.


2/23/2012 Created By: Priyanka Pareek 25

Some Common Events and Listener Interface:


Event: ActionEvent ItemEvent AdjustmentEvent ChangeEvent KeyEvent ListSelection MouseEvent FocusEvent Listener Interface ActionListener ItemListener AdjustmentListener ChangeListener KeyListener ListSelectionListener MouseListner FocusListner

2/23/2012

Created By: Priyanka Pareek

26

Vous aimerez peut-être aussi