 Hello and welcome to the series of video lectures on the subject Java programming. I am Dr. Srisail Sharad Kashbar and in this video lecture we are going to introduce to graphical user interface programming using swing package. At the end of this session you will be able to understand the basics of creating Java application with the graphical user interface. You will also be able to create a simple graphical user interface frame using swing package. Now let us first understand what is the graphical user interface application or GUI application. So a GUI application is an application where users interact with a set of visual controls to make an application do its required task. Now in this case the visual controls can be the buttons, labels, text boxes, toolbars, menu items etc. And for example a calculator application that you may find in Windows operating system is a good example of a graphical user interface or a word application in Windows is also a graphical user interface application. Now in this case whenever you open a calculator application, now in this case a user can interactively talk with this application for performing the arithmetic operations etc. So now in this case you can see it consists of a frame and in this frame you can see various controls are there like minimize, closing operation etc. And here you can see the buttons also which have certain numbers associated with it. And whenever user presses some key the particular key value will be displayed on this screen. So it's a text area where the users can see the output. So this is a good example of a graphical user interface. So using Java swing package you can create such kind of applications. So in the context of graphical user programming using Java it provides two sets of components for GUI programming. The first is classes which are available in java.awt package whereas you can also make use of the classes which are available in the java.x.swing package. So awt stands for abstract window toolkit whereas the swing is a later version than the awt and it's an enhanced version. So here you can see the name as java x here x stands for extended version. Now both these packages are part of java foundation classes that is jfcs. What are the jfcs? jfcs contain the suit of libraries for creating the graphical user interface using the java language. So in this video lectures we are going to make use of the swing package for creating the graphical user interface. So a java GUI application are basically event driven meaning nothing happens until application is called upon to respond to some event. The event in this case can be button pressing, menu selection etc. So basically for each event you are going to write the event methods and these event methods will be listened by the event listener. We are going to talk about this in more detail in the later videos. So typical structure of a java GUI application is as follows. It consists of a frame which is like a container for the controls and here you can see the basic control options and here you can also find out the code also. The code is used to implement the various events which may happen whenever the user interacts with these control buttons. So in the context of the calculator application which we have discussed in the last slide the outer window is called the frame. So this frame basically consists of the name of this window and this minimize, close these buttons. So this is a frame in java. The controls in this case can be the buttons which you can see here. It can be the buttons and it can be the text area which you can see here. So all these are the controls and this is a frame. So a java graphical user interface application is made up of frame. So what is the frame? Frame is a window that you create for user interface. Now there can be controls as I mentioned. Now what are the controls? The controls are the graphical features positioned on frame to allow user interaction. And these controls can be text boxes, labels, scroll bars, buttons etc. Now in the context of java the frames and controls are all objects. Now for the frames and controls there can be properties. Now every characteristic of a frame or control is specified by a property. Now the property can be a color. It can be size, names, position, contents etc. Now in a java GUI application there can be methods also. The methods are the built-in procedures that can be invoked to impart some action to or change or determine property of a particular object. Now there can be event methods also which is nothing but a code related to some object or control. This is the code that is executed when a certain event occurs. Now there can be general methods also which are not related to objects. Now pause the video for 2 minutes and write down the answer of the given question. I hope you have written the answer. The correct answer is the java foundation classes are a suit of libraries for building portable java-based graphical user interfaces. The two packages awt and swing both are part of the JFCs. Now let us understand the main steps in java GUI programming. Now these are the broad steps that we are going to implement for creating a java graphical user interface application. The first step is we are going to import the awt and swing packages which will contain the necessary classes, interfaces and methods which we will use for creating the application. Then we are going to set up a top-level container. Now what is the container? As its name suggests it is the element which will hold the different components. The top-level container in our case will be the frame. Then we are going to fill the container with the graphical user interface components such as buttons, text box, etc. Then we are going to install listeners for GUI components. And finally we are going to display the container. So let us see in detail different swing components. So broadly there are two kinds of swing components. The first is containers and second is basic controls. The containers basically contain and manage other components. There are broadly two types of containers, top-level container and internal containers. The jframe class in swing package is a top-level container whereas the jscroll pane, jpanel are the internal containers. The basic controls are nothing but the atomic components which are used for showing output and getting some input. These basic controls basically inherit the j component class in Java. And the various examples are jbutton, jlabel, jtextarea, jtable, jlist, etc. So these are the top-level containers. So there are three top-level containers shown here. The j dialog is a top-level container class. Then there is a jfileChooser and the most widely used class or the most widely used top-level container class is a jframe class which basically is nothing but a frame window. And in this frame window you can put different GUI components to create your own application. So these are the different controls or components which are available in swing package. So there are jbutton. So these are the classes which correspond to a particular component. So the classes are jbutton, jcheckbox, jcombobox, jlist, jmenu, jradiobutton, jslider, etc. Now let us create in Java a simplest GUI example which is nothing but a frame window application. So here we are going to write the class simple GUI and in this case we are going to define the public static wide main method. The jframe class is in the swing package. So let us import that package first. So import javax.swing.jframe. So we are going to make use of this one. So jframe class. So let us create an object of the jframe class. Then we are going to call a method frame.set visible and this set visible method takes the Boolean variable. So I am going to put it as a true. So now in order to close it properly, write it. So frame.set default close operation and in this case we are going to pass a constant and the constant in this case is a static. So we are going to call it as jframe.exit on close. And now after this line we are able to close this graphical user interface application properly. So let us check this one. Now here you can see a small window here and if I close it then it is properly closed. Now the problem here is the frame is very very small. So now let us expand the size of this frame. Now in order to expand the size of this one we can write a method. We can call a method called as frame.setSize. Now the setSize method takes two arguments width, height. So width here I can provide as 300 and let us provide the height as 200. Now let us check that it is compiled properly and let us run it. Now here you can see a frame which is created and the title in this case is simple GUI and here this is the frame window the width is 300 whereas the height is 200 and in this case you can close this one also. If I close it it is properly closed. So this is how you can create a simple graphical user interface application which is nothing but a frame in this case using Java. So this is the reference. Thank you very much.