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