Пример #1
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();
    }
Пример #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";
      }
    }