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 private NumberValue numValue; 024 025 public HandBackSTFSContentCreator(NumberValue numValue) 026 { 027 this.numValue = numValue; 028 } 029 030 /** 031 * Add label and commit action to given FormSheet. 032 * @param fs <code>FormSheet</code> to be changed 033 */ 034 protected void createFormSheetContent(FormSheet fs) { 035 JComponent jc = new JPanel(); 036 jc.setLayout(new BoxLayout(jc, BoxLayout.Y_AXIS)); 037 jc.add(Box.createVerticalStrut(10)); 038 jc.add(new JLabel("You get back: " + VideoShop.getCurrency().toString(numValue))); 039 jc.add(Box.createVerticalStrut(10)); 040 jc.add(fs.getComponent()); 041 fs.setComponent(jc); 042 fs.removeButton(FormSheet.BTNID_CANCEL); 043 044 fs.getButton(FormSheet.BTNID_OK).setAction(new CommitAction()); 045 } 046 047 }