示例#1
0
    private void PicButtonActionPerformed(ActionEvent evt) {
      OKButton.setEnabled(true);
      javax.swing.Icon test = PicButton.getIcon();
      if (test instanceof ImageIcon) {
        if (isBIFpic) {
          String BIFFILENAME = "po_" + tmpname + "l.tga";
          try {
            InfoText.setText(BIFFILENAME);

            File tempImage = RESFAC.TempImageFile(BIFFILENAME);
            if (tempImage != null) {
              TargaImage curtga = new TargaImage(tempImage);
              CurrentPortrait.setIcon(new ImageIcon(curtga.getImage()));
              BICPortraitname = "po_" + tmpname;
              CURRENTPORTRAIT = tempImage.getParent() + FileDelim + baseFilename;
              OKButton.setEnabled(true);
            }
          } catch (IOException err) {
            JOptionPane.showMessageDialog(
                null,
                "Fatal Error - " + BIFFILENAME + " not found. Your data files might be corrupt.",
                "Error",
                0);
            System.exit(0);
          }
        } else {
          String PORTRAIT = qualifiedName;
          if (qualifiedName.toUpperCase().endsWith("M.TGA")) {
            CURRENTPORTRAIT = PORTRAIT;
            PORTRAIT = qualifiedName.substring(0, qualifiedName.length() - 5) + "l.tga";
          }

          ImageIcon icon = null;
          try {
            icon = new ImageIcon(new TargaImage(new File(PORTRAIT)).getImage());
          } catch (IOException e) {
            System.out.println("Invalid Icon: " + PORTRAIT);
            icon = null;
          }

          CurrentPortrait.setIcon(icon);
          BICPortraitname = baseFilename.substring(0, baseFilename.length() - 4);
          InfoText.setText(PORTRAIT.substring(PORTRAIT.lastIndexOf(FileDelim) + 1));
          if (BICPortraitname.toLowerCase().endsWith("m")
              || BICPortraitname.toLowerCase().endsWith("l")
              || BICPortraitname.toLowerCase().endsWith("h")
              || BICPortraitname.toLowerCase().endsWith("s")
              || BICPortraitname.toLowerCase().endsWith("t")) {
            BICPortraitname = BICPortraitname.substring(0, BICPortraitname.length() - 1);
          }
          OKButton.setEnabled(true);
        }
      }
    }
示例#2
0
    public Portrait(String dir, String imageFilename, boolean isBifpic, String pretmpname) {
      baseFilename = imageFilename;
      qualifiedName = dir + imageFilename;
      tmpname = pretmpname;
      isBIFpic = isBifpic;

      CreateButton();

      try {
        File targetfile = new File(qualifiedName);
        TargaImage tgapic = new TargaImage(targetfile);
        Dimension tgasize = tgapic.getSize();
        double tmpsize =
            (new Float(tgasize.height)).doubleValue() * (new Float(0.78125D)).doubleValue();
        tgapic.setHeight((int) tmpsize);
        PicButton.setIcon(new ImageIcon(tgapic.getImage()));
      } catch (IOException e) {
        System.out.println("Invalid image: " + qualifiedName);
        qualifiedName = "null";
      }
    }
示例#3
0
    public void CreateButton() {
      PicButton = new JButton();
      add(PicButton);
      setLayout(new BorderLayout());
      PicButton.setName("PicButton");
      setAutoscrolls(true);
      PicButton.setIcon(new ImageIcon("/resource/blank.jpg"));
      PicButton.setHorizontalAlignment(2);
      PicButton.setMargin(new Insets(0, 0, 0, 0));
      PicButton.setVerticalAlignment(1);
      PicButton.setVerticalTextPosition(1);
      PicButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              PicButtonActionPerformed(evt);
            }
          });
      int num = getComponentCount();
      String stuff = getComponent(0).getName();
    }