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 import data.stdforms.SingleTableFormSheet; 011 012 import sale.FormSheet; 013 import sale.FormSheetContentCreator; 014 import videoautomat.VideoShop; 015 import videoautomat.contentcreator.stdactions.CommitAction; 016 017 /** 018 * Content creator to add label with get back money and to add commit action. 019 * @author Alexander Herrmann 020 * 021 */ 022 public class HandBackSTFSContentCreator extends FormSheetContentCreator { 023 024 private NumberValue numValue; 025 026 public HandBackSTFSContentCreator(NumberValue numValue) 027 { 028 this.numValue = numValue; 029 } 030 031 /** 032 * Add label and commit action to given FormSheet. 033 * @param fs <code>FormSheet</code> to be changed 034 */ 035 protected void createFormSheetContent(FormSheet fs) { 036 SingleTableFormSheet stfs = (SingleTableFormSheet) fs; 037 JComponent jc = new JPanel(); 038 jc.setLayout(new BoxLayout(jc, BoxLayout.Y_AXIS)); 039 jc.add(Box.createVerticalStrut(10)); 040 jc.add(new JLabel("You get back: " + VideoShop.getCurrency().toString(numValue))); 041 jc.add(Box.createVerticalStrut(10)); 042 jc.add(fs.getComponent()); 043 fs.setComponent(jc); 044 fs.removeButton(FormSheet.BTNID_CANCEL); 045 046 fs.getButton(FormSheet.BTNID_OK).setAction(new CommitAction()); 047 } 048 049 }