Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Pre-Quiz3-Summer 2007

PDF VERSION

A. Short Answer
a. What is the difference between FlowLayout and BorderLayout?



b. What does an ActionREMOVEDstener do? What happens in a GUI without one?



c. What is the difference between a JTextArea and JTextField?



B. Tree Traversals (Interactive tutorial on tree traversals)

tree.JPG


1. What is the pre-order traversal of this tree?



2. What is the in-order traversal of this tree?



3. What is the post-order traversal of this tree?




tree2.JPG


1. What is the pre-order traversal of this tree?



2. What is the in-order traversal of this tree?



3. What is the post-order traversal of this tree?





C. GUI Trees
Consider the following code:
import javax.swing.*;
import java.awt.*; 

public class GUITree extends JFrame {
  JButton button1, button2, button3, button4, button5, button6, button7;
  JTextField inputField;
  
  public GUITree(){
    super("Non-functioning calculator");
    this.getContentPane().setLayout(new BorderLayout());
    
    button1 = new JButton("+"); button2 = new JButton("-");
    button3 = new JButton("/"); button4 = new JButton("*");
    button5 = new JButton("Clear"); button6 = new JButton("%");
    button7 = new JButton("!"); inputField = new JTextField(10);
    
    JPanel panel1 = new JPanel();
    panel1.add(button1); panel1.add(button2); 
    panel1.add(button6);
    this.getContentPane().add(panel1,BorderLayout.NORTH);
    
    JPanel panel2 = new JPanel();
    panel2.add(button3); panel2.add(button4);
    panel2.add(button7);
    this.getContentPane().add(panel2,BorderLayout.CENTER);
    
    JPanel panel3 = new JPanel();
    panel3.add(inputField); panel3.add(button5);
    this.getContentPane().add(panel3,BorderLayout.SOUTH);
    
    this.pack();
    this.setVisible(true);
  }
}


1. What does the GUI look like when we run the line GUITree tree = new GUITree(); in the Interactions Pane?






2. What does the tree representation of the GUI look like?








ADT question in the works. (Sorry, but this was never posted - Colin Potts. Just make sure that you know about lists, sets, stacks and queues and that you know how queues, stacks or sets might be implemented using linked lists but hide that implementation from users. Consult the code on the syllabus page for more information.)




Questions? Answers? Post them on Questions on Pre-Quiz3-Summer 2007

Links to this Page