Java Swing Question and Answers

5. What is Event Driven Thread (EDT) is Swing?
 
  • Event Driven Thread or EDT is a special thread in Swing and AWT. Event Driven Thread is used to draw graphics and listen for events in Swing.
  • You will get a bonus point if you able to highlight that time consuming operations like connecting to database, opening a file or connecting to network should not be done on EDT thread because it could lead to freezing GUI because of blocking and time consuming nature of these operations instead they should be done on separate thread and EDT can just be used o spawn those thread on a button click or mouse click.
 
Your Name Your Email-ID
Your Answer
6. What is a layout manager and what are different types of layout managers available in Java Swing?
  A layout manager is an object that is used to organize components in a container.
  • FlowLayout: The elements of a Flow Layout are organized in a top to bottom, left to right fashion.
  • Border Layout: The elements of a BorderLayout are organized at the borders(North, South East and West) and the center of a container.
  • Card Layout: The elements of a CardLayout are stacked, on top of the other, like a deck of cards.
  • Grid Layout: The elements of a GridLayout are of equal size and laid out using the square of a grid.
  • Grid Bag Layout: The elements of a GridBagLayout are organized according to a grid. However, the elements may be different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.
 
Your Name Your Email-ID
Your Answer
7. What is the difference between a Window and a Frame?
  The Frame extends Window to define a main application window that can have a menu bar.
 
Your Name Your Email-ID
Your Answer
8. What is the difference between the paint() and repaint() methods?
 
  • The paint() method supports painting via a Graphics object.
  • The repaint() method is used to cause paint() to be invoked by the AWT painting thread.
 
Your Name Your Email-ID
Your Answer
123456789 Page 2 of 9