Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.

Similar presentations


Presentation on theme: "Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along."— Presentation transcript:

1 Ajmer Singh PGT(IP) JAVA IDE Programming - I

2 Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along with text, to interact with user. In Java, GUI Programming is done through Swing API. The Swing toolkit, includes a rich set of graphical components for building GUIs.

3 Ajmer Singh PGT(IP) Types of Swing Components 1.Components : A Swing Component is a self contained entity that can be customized and inserted into application. e.g JLabel, JTextField, Jbutton, JCheckBox etc. 2.Containers : A container is a special type component that can hold other components. e.g. Jpanel, JFrame etc.

4 Ajmer Singh PGT(IP) Component It ia an object that defines a screen element such as a button, textfield, scroll bar, menu etc.

5 Ajmer Singh PGT(IP) Types of Containers Top Level Containers: It can be used directly. Top Level Containers: It can be used directly. Non-Top Level Containers: It requires another Top Level Container for its use. Non-Top Level Containers: It requires another Top Level Container for its use.

6 Ajmer Singh PGT(IP) Layout Managers Layout Managers enable to control the ways in which visual components are arranged in GUI forms by determining the size and position of components within containers. Different Layout Managers are FlowLayout, GridLayout, CardLayout, SpringLayout, BorderLayout, GridBagLayout, BoxLayout

7 Ajmer Singh PGT(IP) Frame It is a top-level window with a title and border.

8 Ajmer Singh PGT(IP) COMMONLY USED PROPERTY OF FRAME  title: It sets the title of the frame which is displayed on the title bar of the frame.

9 Ajmer Singh PGT(IP) Panel It is a type of container that’s designed to hold a group of components so they can be displayed on the frame.

10 Ajmer Singh PGT(IP) Adding components to Panel  Click Panel under the Swing Container section of the Palette and drag and drop over the frame.  Select the other components from the palette that you want to add to the panel and drag and drop over the panel.

11 Ajmer Singh PGT(IP) COMMONLY USED PROPERTIES OF PANEL  background: It sets the background color of the Panel.  border: It lets you specify the type of border that will surround the Panel.

12 Ajmer Singh PGT(IP) WORKING WITH BUTTONS

13 Ajmer Singh PGT(IP) PUSH BUTTONS OR SIMPLY BUTTONS Buttons are action components i.e., these can be programmed for action. When user clicks on a button during runtime corresponding action takes place. It is created through JButton class of Swing API.

14 Ajmer Singh PGT(IP) COMMONLY USED PROPERTIES OF BUTTON  background: It sets the background color of the button.  border: It lets you specify the type of border that will surround the button.  font: It sets the font for the text of the button.  foreground: It sets the foreground color of the button.

15 Ajmer Singh PGT(IP) COMMONLY USED PROPERTIES OF BUTTON  text: It sets the text of the button.  enabled: This property determines whether the button is active or not.  mnemonic: It lets you specify the shortcut key or the access key for the button that you can combine with Alt to invoke the button during runtime.

16 Ajmer Singh PGT(IP) COMMONLY USED METHODS OF BUTTON void setText(String): It sets the text displayed by the button to the String value specified in parenthesis. String getText(): It returns the text displayed by the button. void setSelected(boolean): Sets the button to appear as selected. boolean isSelected(): It returns the state whether the button is selected or not.

17 Ajmer Singh PGT(IP) MOST COMMON EVENTS OF BUTTON The most common event is Action Event which is handled by the actionPerformed method of event listener ActionListener.

18 Ajmer Singh PGT(IP) Creating an EXIT button EXIT button is used to close an application. To create an EXIT button you need to perform the following steps: 1.Add a Button to your application. 2.Set its text property to “Exit”. 3.Type the following code to actionPerformed() method. Sytem.exit(0);


Download ppt "Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along."

Similar presentations


Ads by Google