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?