Java Swing AWT Question:
Download Questions PDF

What is the process of setting the layout manager?

Swing AWT Interview Question
Swing AWT Interview Question

Answer:

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.

Download Swing AWT Interview Questions And Answers PDF

Previous QuestionNext Question
What are the different types of layout managers used in Swing?What are the different components that are used to show a container?