m@0: /*============================================================================= m@0: * File: InterBlockPanel.java m@0: * Author: Marcus Pearce m@0: * Created: <2008-01-08 15:39:18 marcusp> m@0: * Time-stamp: <2008-03-04 17:16:48 marcusp> m@0: *============================================================================= m@0: */ m@0: m@0: import java.awt.*; m@0: import java.awt.event.*; m@0: import javax.swing.*; m@0: m@0: public class InterBlockPanel extends JPanel { m@0: m@0: /* variables */ m@0: private JButton continueButton; m@0: private JLabel message; m@0: private String previousText; m@0: private String text = ""; m@0: private Experiment exp; m@0: m@0: /* accessors */ m@0: public JButton getContinueButton() { return continueButton; } m@0: public void setText() { m@0: previousText = text; m@0: text = exp.getCurrentBlock().getLabel(); m@0: } m@0: m@0: /* constructor */ m@0: public InterBlockPanel(Experiment e) { m@0: m@0: exp = e; m@0: setText(); m@0: m@0: continueButton = new JButton("Continue"); m@0: JPanel continuePane = new JPanel(); m@0: continuePane.add(continueButton); m@0: m@0: message = new JLabel(); m@0: message.setHorizontalAlignment(JLabel.CENTER); m@0: updateMessageDisplay(); m@0: JPanel messagePane = new JPanel(new FlowLayout(FlowLayout.CENTER)); m@0: messagePane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); m@0: messagePane.add(message); m@0: m@0: this.setLayout(new BorderLayout()); m@0: this.add(messagePane, BorderLayout.CENTER); m@0: this.add(continuePane, BorderLayout.SOUTH); m@0: } m@0: m@0: public void updateMessageDisplay() { m@0: message.setText(formatMessage()); m@0: } m@0: m@0: private String formatMessage() { m@0: StringBuffer sb = new StringBuffer(); m@0: sb.append("

"); m@0: sb.append("That is the end of the "); m@0: sb.append(previousText); m@0: sb.append(" block. "); m@0: sb.append("
"); m@0: sb.append("If you have any questions, you may ask them now."); m@0: sb.append("
"); m@0: sb.append("Otherwise, press the button below to continue on to the "); m@0: sb.append(text); m@0: sb.append(" block."); m@0: sb.append("

"); m@0: m@0: return sb.toString(); m@0: } m@0: m@0: public void addContinueButtonListener(ActionListener al) { m@0: continueButton.addActionListener(al); m@0: } m@0: }