Mercurial > hg > mep
view InterBlockPanel.java @ 11:85b03f084d63
Fix incorrect info about zero-indexing in README.
Ignore-this: ed7a491d54fa129a7e2e9bb08c20f17a
author | Marcus Pearce <m.pearce@gold.ac.uk> |
---|---|
date | Fri, 04 Nov 2011 18:21:49 +0000 |
parents | 4031cbb02f08 |
children | be66ee2fe9fe |
line wrap: on
line source
/*============================================================================= * File: InterBlockPanel.java * Author: Marcus Pearce <m.pearce@gold.ac.uk> * Created: <2008-01-08 15:39:18 marcusp> * Time-stamp: <2008-03-04 17:16:48 marcusp> *============================================================================= */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class InterBlockPanel extends JPanel { /* variables */ private JButton continueButton; private JLabel message; private String previousText; private String text = ""; private Experiment exp; /* accessors */ public JButton getContinueButton() { return continueButton; } public void setText() { previousText = text; text = exp.getCurrentBlock().getLabel(); } /* constructor */ public InterBlockPanel(Experiment e) { exp = e; setText(); continueButton = new JButton("Continue"); JPanel continuePane = new JPanel(); continuePane.add(continueButton); message = new JLabel(); message.setHorizontalAlignment(JLabel.CENTER); updateMessageDisplay(); JPanel messagePane = new JPanel(new FlowLayout(FlowLayout.CENTER)); messagePane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); messagePane.add(message); this.setLayout(new BorderLayout()); this.add(messagePane, BorderLayout.CENTER); this.add(continuePane, BorderLayout.SOUTH); } public void updateMessageDisplay() { message.setText(formatMessage()); } private String formatMessage() { StringBuffer sb = new StringBuffer(); sb.append("<html><font size=\"+1\" face=\"sans\"><p align=center>"); sb.append("That is the end of the "); sb.append(previousText); sb.append(" block. "); sb.append("<br>"); sb.append("If you have any questions, you may ask them now."); sb.append("<br>"); sb.append("Otherwise, press the button below to continue on to the "); sb.append(text); sb.append(" block."); sb.append("</p></html>"); return sb.toString(); } public void addContinueButtonListener(ActionListener al) { continueButton.addActionListener(al); } }