/** Creates new form PortraitMenu1 */ public PortraitMenu() { menucreate = TLKFactory.getCreateMenu(); TLKFAC = menucreate.getTLKFactory(); RESFAC = menucreate.getResourceFactory(); Preferences prefs = Preferences.userRoot().node("/CharacterCreator"); String NWNDir = prefs.get("GameDir", null); FileDelim = prefs.get("FileDelim", null); directory = NWNDir + "portraits" + FileDelim; menucreate.BlockWindow(true); initComponents(); PortraitScrollPane.setViewportView(PortraitsWindow); OKButton.setEnabled(false); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if ((screenSize.getWidth() > getContentPane().getWidth()) && (screenSize.getHeight() > getContentPane().getHeight())) { int intwidth = new Double(((screenSize.getWidth() - getContentPane().getWidth()) / 2)).intValue(); int intheight = new Double(((screenSize.getHeight() - getContentPane().getHeight()) / 2)).intValue(); setLocation(intwidth, intheight); } else setLocation(0, 0); try { portraitmap = RESFAC.getResourceAs2DA("portraits"); } catch (IOException err) { JOptionPane.showMessageDialog( null, "Fatal Error - portraits.2da not found. Your data files might be corrupt.", "Error", 0); System.exit(0); } CURRENTPORTRAIT = "resource/portrait.jpg"; java.net.URL targurl = getClass().getResource(CURRENTPORTRAIT); CurrentPortrait.setIcon(new ImageIcon(targurl)); menucreate = TLKFactory.getCreateMenu(); sexlock = true; racelock = true; RedoPortraits(-1); pack(); }
private void OKButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_OKButtonActionPerformed try { TargaImage deftg = new TargaImage(new File(CURRENTPORTRAIT)); System.out.println("Filename according to the bic: " + BICPortraitname); Dimension tgasize = deftg.getSize(); double tmpsize = (new Float(tgasize.height)).doubleValue() * (new Float(0.78125D)).doubleValue(); deftg.setHeight((int) tmpsize); java.awt.Image tempportimage = deftg.getImage(); menucreate.CharPortrait.setIcon(new ImageIcon(tempportimage)); menucreate.MainCharData[2] = new HashMap(); menucreate.MainCharData[2].put(new Integer(0), BICPortraitname); menucreate.BlockWindow(false); setVisible(false); dispose(); // Add your handling code here: CreateMenu menucreate = TLKFactory.getCreateMenu(); menucreate.ClassButton.setEnabled(true); } catch (IOException e) { System.out.println("Invalid Image: " + CURRENTPORTRAIT); } } // GEN-LAST:event_OKButtonActionPerformed