GUI Flashcards

1
Q

What is GUI

A

• Graphical User Interface, abbreviated GUI, is a type of
interface that takes advantage of a computer’s graphic ability to allow users to interact with electronic devices through graphical icons and visual indicators.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two packages that generate GUI components in Java

A
  • java.awt

* javax.swing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Compare and contrast AWT and SWING

A

AWT
• Heavyweight components
• Associated with native components called peers
• Same behaviour, but platform-dependent look
• Package java.awt

Swing
• Lightweight components, i.e., no peer components
• Same look and feel across platforms
• Support pluggable look and feel
• Package javax.swing

*See doc for pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe a container, a top level container and give examples

A

In Java, all GUI objects go into a Container.
• A top level container can stand alone in a web
browser or in an operating system. The two most common top-level containers are:
• JFrame
• JApplet
• Some containers may only be added to other containers.
• JPanel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe layout managers and their role

A

• Associated with containers
• Automate the layout of elements
• When elements are added to the container
• When the window is resized
• automatically adjust the positions and sizes of the
elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the hierarchy of layout managers?

A

Container- Layout Manager-

  1. Border layout, Card Layout, FlowLayout, GridLayout
  2. LayoutManager2-GridBagLayout

*See doc for pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can you identify the design pattern used

here?(Border layout, Card Layout, FlowLayout, GridLayout)

A

*See doc for pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe events

A
  • A way for GUI components to communicate with the rest of application
  • Implemented as event classes (e.g., ActionEvent)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe event sources

A
  • Components generating events

* Examples: buttons, check boxes, combo boxes, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe event listeners/ handlers

A

• Objects that receives and processes events
• Must implement an appropriate listener
interface
• Must inform the source its interest in handling a
certain type of events (by registering)
• May listen to several sources and different
types of events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give an example to show how events, event sources and even handlers work together

A
[create a button]
JButton button = new JButton(“Increment”);
[register an action listener]
button.addActionListener(new ButtonActionListener());
[Action listener class]
class ButtonActionListener implements ActionListener {

public void actionPerformed(ActionEvent e) {
[ handle the event e …]
System.out.println(“Increment button pressed!”);
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Give examples of events and their respective listeners

A
ActionEvent - ActionListener
ComponentEvent -ComponentListener
,ComponentAdapter
FocusEvent-FocusListener ,FocusAdapter
KeyEvent-KeyListener ,KeyAdapter
MouseEvent- MouseListener ,MouseAdapter
MouseMotionListener-MouseMotionAdapter
WindowEvent-WindowListener ,WindowAdapter
ItemEvent- ItemListener
TextEvent- TextListener
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Explain what a JOptionPane is.

A

The JOptionPane class is used to provide standard dialog boxes such as message dialog box, confirm dialog box and input dialog box. These dialog boxes are used to display information or get input from the user. The JOptionPane class inherits JComponent class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the syntax of using a JOptionPane

A
import javax.swing.*;  
public class OptionPaneExample {  
JFrame f;  
OptionPaneExample(){  
    f=new JFrame();  
    JOptionPane.showMessageDialog(f,"Hello, Welcome to Javatpoint.");  
}  
public static void main(String[] args) {  
    new OptionPaneExample();  
}  
}  
Ou
How well did you know this?
1
Not at all
2
3
4
5
Perfectly