private ChoiceButton createButton(Element xmlButton, Game window) { String label = xmlButton.getAttribute("label"); String target = xmlButton.getAttribute("target"); ChoiceButton button; if (xmlButton.hasAttribute("image")) { try { BufferedImage img = ImageIO.read(getClass().getResource(xmlButton.getAttribute("image"))); ImageIcon image = new ImageIcon(img.getScaledInstance(150, 150, Image.SCALE_SMOOTH)); button = new ChoiceButton(image, label, target, window); } catch (IOException ex) { button = new ChoiceButton(label, target, window); Logger.getLogger(StoryModel.class.getName()).log(Level.SEVERE, null, ex); } } else { button = new ChoiceButton(label, target, window); } NodeList actions = xmlButton.getElementsByTagName("action"); for (int i = 0; i < actions.getLength(); i++) { Element xmlAction = (Element) actions.item(i); Action action = actionFactory.createAction(xmlAction.getAttribute("type")); action.createFromXML(xmlAction); button.addAction(action); } button.addActionListener(button); return button; }