import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Ch14TextFrame1 extends JFrame implements ActionListener{
private static final int FRAME_WIDTH = 1024;
private static final int FRAME_HEIGHT= 768;
private static final int FRAME_X_ORIGIN = 0;
private static final int FRAME_Y_ORIGIN = 0;
private static final int BUTTON_WIDTH = 80;
private static final int BUTTON_HEIGHT = 30;
private JLabel prompt;
private JTextField inputLine;
public static void main(String[] args){
Ch14TextFrame1 frame = new Ch14TextFrame1();
frame.setVisible(true);
}
public Ch14TextFrame1(){
Container contentPane;
JButton button1, button2, button3, button4, button5;
setSize (FRAME_WIDTH, FRAME_HEIGHT);
setResizable (true);
setTitle ("Program Ch14TextFrame3");
setLocation (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
contentPane = getContentPane();
contentPane.setLayout(null);
button1 = new JButton("Finish");
button1.setBounds(650,600,200,50);
button1.setFont(new Font("Arial", Font.BOLD, 30));
button1.setBorder(BorderFactory.createRaisedBevelBorder());
button1.setBackground (Color.pink);
button1.setForeground (Color.blue);
prompt = new JLabel( );
prompt.setText("Plate Tectonics Quiz");
prompt.setSize(900,50);
prompt.setLocation(300,30);
prompt.setFont(new Font("Times New Roman", Font.BOLD, 40));
prompt.setForeground(Color.red);
contentPane.add(prompt);
prompt = new JLabel( );
prompt.setText(" 1)When the continents were joined together they were called a) Hellenic b) Pangaea c) Mariana");
prompt.setSize(900,70);
prompt.setLocation(10,90);
prompt.setFont(new Font("Times New Roman", Font.BOLD, 14));
prompt.setForeground(Color.black);
contentPane.add(prompt);
inputLine = new JTextField();
inputLine.setSize(100,20);
inputLine.setLocation(625,115);
contentPane.add(inputLine);
inputLine.addActionListener(this);
prompt = new JLabel( );
prompt.setText(" 2) When continents move towards each other they are called a) Constructive b) Destructive c) Conservative");
prompt.setSize(900,70);
prompt.setLocation(10,120);
prompt.setFont(new Font("Times New Roman", Font.BOLD, 14));
prompt.setForeground(Color.black);
contentPane.add(prompt);
inputLine = new JTextField();
inputLine.setSize(100,20);
inputLine.setLocation(700,145);
contentPane.add(inputLine);
inputLine.addActionListener(this);
prompt = new JLabel( );
prompt.setText(" 3) At what depth does a subducted plate melt? a) 100km b) 300km c) 20km");
prompt.setSize(900,70);
prompt.setLocation(10,150);
prompt.setFont(new Font("Times New Roman", Font.BOLD, 14));
prompt.setForeground(Color.black);
contentPane.add(prompt);
inputLine = new JTextField();
inputLine.setSize(100,20);
inputLine.setLocation(500,175);
contentPane.add(inputLine);
inputLine.addActionListener(this);
contentPane.add(button1);
button1.addActionListener(this);
button1.setActionCommand("b1");
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent event) {
if(event.getSource() instanceof JButton) {
JButton clickedButton = (JButton) event.getSource();
String buttonText = clickedButton.getText();
setTitle("You clicked" + buttonText);
String ac = event.getActionCommand();
if (ac.equals("b1")) {
}
}
}
}