Logo F2FInterview

Swing Interview Questions

Q   |   QA

Serialization is used when an object extends the Jcomponent class. The object's data in this case points out to the stream that is written or serialized and gives an output stream. This output stream can be sent through then network and it can be saved in the file if required. The serialized file can be de-serialized in the memory. This will allow the operation to continue to perform the original state functions that were getting used. The serialization used in object allows easy retrieval of the object data and easy transmission of state data from one place to another. This can also be placed in custom made storage files that provide the transfer of the components to be fast and it uses the concept of virtual machine that transfers from one machine to another machine. It uses the remote method invocation to allow the use of distributed computing that provide with some exceptions to the use of transient keyword. The components can be serialized using the classes that can pass the reference to an object using the writeObject() method of the ObjectOutputStream object this way it calls the serialization function recursively.

Layout manager is an object that is used to implement an interface which determines the size and position of the component that is used inside a container. Components can provide the size and the alignments regarding the container's layout. The main layouts that are used in the layout managers are given as:

  • BorderLayout: this layout is used by every content panel. It places all the components in all the five areas given top, bottom, left, right, and center. This layout can be created by using the JtoolBar.
  • BoxLayout: this layout consists of the components that are represented using the single row or column.
  • CardLayout: this layout is used to implement the area that consists of many other components used at different times. This layout is controlled using the combo box.
  • FlowLayout: it is the default layout for every Jpanel and it displays the components in a single row that starts with a new row.
  • GridBagLayout: it allows the component to be placed and aligned by keeping them in a grid of cells.
  • GridLayout: it allows the components to be of equal size and display equal number of rows and columns.
  • GroupLayout: it uses the user interface builder tools that allows the work can be done by using the vertical and horizontal layouts. The dimensions are defined independently. 

The layout managers uses Jpanels and content panes to initializes the object that is to be used with the FlowLayout by default and it can be changed by defining a different layout. Content panes uses border layout by default and it uses appropriate tools that can be used to code the appropriate object that has to be used. The panel layout manger can be setup by using the Jpanel constructor and it can be shown by an example given as:

JPanel panel = new JPanel(new BorderLayout());

The setLayout method is used to set the layout manager after the container is being created.

Container contentPane = frame.getContentPane();
contentPane.setLayout(new FlowLayout());

The container's layout property can be changed to NULL to allow the absolute positioning to take place where the specification is given in the form of size and positon of each component that is used inside the container. 

There are few components that are used to show the container used to define the visual properties of it. The components are given below:

  • The layout manager: it is the manager of all the layouts or the structure that automatically provide the functionality in between the components. This is the only manager that does that. It also provides the spacing between each component and provides support for it as well.
  • Invisible components: This is used to create lightweight components that allow performing no user interface functionality but it provides the space in the graphical user interface. This component is contained or controlled by the BoxLayout.
  • Empty borders: the space between the components can be affected by adding the empty borders to the components that are defined within the block. This uses the borders that are having no border at all like panels and labels. 

Internal frame allow one window to be displayed within another window. Adding of internal frame can be used to the desktop pane or the content pane. The user interface allows choosing the base of the application that is surrounded around the frames. The frames can be switched and other frames can be chosen over the other one. This internal frame has the same function that is provided in the normal Frame object, this object is confined inside the visible area of the container. The internal frame can have icons that can be used inside the application frame and have the properties of maximize and minimize so that the frame consists of main application frame. It closes the frame using the standard controls that is given for a popup window. Internal frame can be given in a layer that uses the display function to display the relative to the other internal frames.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: