Mercurial > hg > mep
view EndBlockPanel.java @ 47:be66ee2fe9fe
Added abstract class EndBlockPanel to deliver end of block messages (e.g. end of practice block).
Added and implemented EndTestPanel which gives "thank you for participating" etc message at end of test.
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Thu, 13 Jun 2013 18:33:34 +0100 |
parents | |
children |
line wrap: on
line source
/*============================================================================= * File: EndBlockPanel.java * Author: Carl Bussey <c.bussey@se10.qmul.ac.uk> * Created: <2013-06-13 17:32> *============================================================================= */ import java.awt.*; import java.awt.event.*; import javax.swing.*; abstract class EndBlockPanel extends JPanel { /* variables */ protected JButton continueButton; protected String continueButtonText; protected JLabel message; protected Experiment exp; protected StringBuffer sb; /* accessors */ public JButton getContinueButton() { return continueButton; } /* constructor */ public EndBlockPanel(Experiment e) { exp = e; sb = new StringBuffer(); } public void updateMessageDisplay() { message.setText(formatMessage()); } abstract protected String formatMessage(); public void addContinueButtonListener(ActionListener al) { continueButton.addActionListener(al); } public void setUp(String buttonText){ continueButton = new JButton(buttonText); 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); } }