annotate InterBlockPanel.java @ 0:4031cbb02f08

Initial import. Ignore-this: 87317e384f22bde48db996355191fa5f
author Marcus Pearce <m.pearce@gold.ac.uk>
date Tue, 18 May 2010 11:37:10 +0100
parents
children be66ee2fe9fe
rev   line source
m@0 1 /*=============================================================================
m@0 2 * File: InterBlockPanel.java
m@0 3 * Author: Marcus Pearce <m.pearce@gold.ac.uk>
m@0 4 * Created: <2008-01-08 15:39:18 marcusp>
m@0 5 * Time-stamp: <2008-03-04 17:16:48 marcusp>
m@0 6 *=============================================================================
m@0 7 */
m@0 8
m@0 9 import java.awt.*;
m@0 10 import java.awt.event.*;
m@0 11 import javax.swing.*;
m@0 12
m@0 13 public class InterBlockPanel extends JPanel {
m@0 14
m@0 15 /* variables */
m@0 16 private JButton continueButton;
m@0 17 private JLabel message;
m@0 18 private String previousText;
m@0 19 private String text = "";
m@0 20 private Experiment exp;
m@0 21
m@0 22 /* accessors */
m@0 23 public JButton getContinueButton() { return continueButton; }
m@0 24 public void setText() {
m@0 25 previousText = text;
m@0 26 text = exp.getCurrentBlock().getLabel();
m@0 27 }
m@0 28
m@0 29 /* constructor */
m@0 30 public InterBlockPanel(Experiment e) {
m@0 31
m@0 32 exp = e;
m@0 33 setText();
m@0 34
m@0 35 continueButton = new JButton("Continue");
m@0 36 JPanel continuePane = new JPanel();
m@0 37 continuePane.add(continueButton);
m@0 38
m@0 39 message = new JLabel();
m@0 40 message.setHorizontalAlignment(JLabel.CENTER);
m@0 41 updateMessageDisplay();
m@0 42 JPanel messagePane = new JPanel(new FlowLayout(FlowLayout.CENTER));
m@0 43 messagePane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
m@0 44 messagePane.add(message);
m@0 45
m@0 46 this.setLayout(new BorderLayout());
m@0 47 this.add(messagePane, BorderLayout.CENTER);
m@0 48 this.add(continuePane, BorderLayout.SOUTH);
m@0 49 }
m@0 50
m@0 51 public void updateMessageDisplay() {
m@0 52 message.setText(formatMessage());
m@0 53 }
m@0 54
m@0 55 private String formatMessage() {
m@0 56 StringBuffer sb = new StringBuffer();
m@0 57 sb.append("<html><font size=\"+1\" face=\"sans\"><p align=center>");
m@0 58 sb.append("That is the end of the ");
m@0 59 sb.append(previousText);
m@0 60 sb.append(" block. ");
m@0 61 sb.append("<br>");
m@0 62 sb.append("If you have any questions, you may ask them now.");
m@0 63 sb.append("<br>");
m@0 64 sb.append("Otherwise, press the button below to continue on to the ");
m@0 65 sb.append(text);
m@0 66 sb.append(" block.");
m@0 67 sb.append("</p></html>");
m@0 68
m@0 69 return sb.toString();
m@0 70 }
m@0 71
m@0 72 public void addContinueButtonListener(ActionListener al) {
m@0 73 continueButton.addActionListener(al);
m@0 74 }
m@0 75 }