Pre-quiz 3-Spring 2007
Q1. Who's your grading TA? (Please circle your answer)
Mark Rory Sarah Derek Brian Ricardo Kristin Sam
Q2. What is the major difference between Stacks and Queues with respect to how elements are added and removed from each?
Q3. What is the difference between FlowLayout, GridLayout, and BorderLayout?
Q4. For this question you may find the following code helpful (hint: first try running this code and seeing what it does):
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PreQuiz3GUI extends JFrame{
JTextField txtInput;
public PreQuiz3GUI(){
setLayout (new GridLayout (2, 1));
txtInput = new JTextField("Type Something Here");
JButton btnSay = new JButton("Say Me");
btnSay.addActionREMOVEDstener(new ActionREMOVEDstener(){
public void actionPerformed(ActionEvent ae){
JOptionPane.showMessageDialog(null, txtInput.getText());
}
});
add(txtInput);
add(btnSay);
this.pack();
this.setVisible(true);
}
public static void main(String[]args){
PreQuiz3GUI prequiz = new PreQuiz3GUI();
}
}
You want to create a GUI that will have:
- a field where you can type a string
- two buttons ("Forward" and "Reverse")
- an output label where it will take the string and preform the action on it based on which button is pressed.
You have drawn it out on paper and want it to look like this:
A.) First draw the GUI Tree for the wanted StringReverseGUI.
B.) Second write the java code that will create the StringReverseGUI.
Questions? Comments? Post them on Pre-Quiz 3-Spring 2007 Questions
Link to this Page