001 package videoautomat.contentcreator; 002 003 import javax.swing.Box; 004 import javax.swing.BoxLayout; 005 import javax.swing.JComponent; 006 import javax.swing.JLabel; 007 import javax.swing.JPanel; 008 009 import data.NumberValue; 010 011 import sale.FormSheet; 012 import sale.FormSheetContentCreator; 013 import videoautomat.VideoShop; 014 import videoautomat.contentcreator.stdactions.CommitAction; 015 016 /** 017 * Content creator to add label with get back money and to add commit action. 018 * @author Alexander Herrmann 019 * 020 */ 021 public class HandBackSTFSContentCreator extends FormSheetContentCreator { 022 023 /** 024 * ID for Serialization. 025 */ 026 private static final long serialVersionUID = -9131000547028180757L; 027 028 private NumberValue numValue; 029 030 public HandBackSTFSContentCreator(NumberValue numValue) 031 { 032 this.numValue = numValue; 033 } 034 035 /** 036 * Add label and commit action to given FormSheet. 037 * @param fs <code>FormSheet</code> to be changed 038 */ 039 protected void createFormSheetContent(FormSheet fs) { 040 JComponent jc = new JPanel(); 041 jc.setLayout(new BoxLayout(jc, BoxLayout.Y_AXIS)); 042 jc.add(Box.createVerticalStrut(10)); 043 jc.add(new JLabel("You get back: " + VideoShop.getCurrency().toString(numValue))); 044 jc.add(Box.createVerticalStrut(10)); 045 jc.add(fs.getComponent()); 046 fs.setComponent(jc); 047 fs.removeButton(FormSheet.BTNID_CANCEL); 048 049 fs.getButton(FormSheet.BTNID_OK).setAction(new CommitAction()); 050 } 051 052 }