Пример #1
0
  private void init(EditorPatternButton imgBtn, JLabel msgApplied) {
    _imgBtn = imgBtn;
    JLabel lblPath = new JLabel(_I("lblPath"));
    JLabel lblFilename = new JLabel(_I("lblFilename"));

    String filename = _imgBtn.getFilename();
    File f = new File(filename);
    String fullpath = f.getParent();
    filename = getFilenameWithoutExt(f);
    _oldFilename = filename;

    BufferedImage thumb = _imgBtn.createThumbnailImage(THUMB_MAX_HEIGHT);
    Border border = LineBorder.createGrayLineBorder();
    JLabel lblThumb = new JLabel(new ImageIcon(thumb));
    lblThumb.setBorder(border);

    _txtPath = new JTextField(fullpath, TXT_FILENAME_LENGTH);
    _txtPath.setEditable(false);
    _txtPath.setEnabled(false);

    String[] candidates = new String[] {filename};
    // <editor-fold defaultstate="collapsed" desc="OCR --- not used">
    /*
    String ocrText = getFilenameFromImage(thumb);
    if(ocrText.length()>0 && !ocrText.equals(filename))
    candidates = new String[] {filename, ocrText};
    */
    // </editor-fold>
    _txtFilename = new AutoCompleteCombo(candidates);

    _txtFileExt = new JTextField(getFileExt(f), TXT_FILE_EXT_LENGTH);
    _txtFileExt.setEditable(false);
    _txtFileExt.setEnabled(false);

    GridBagConstraints c = new GridBagConstraints();

    c.gridy = 0;
    c.insets = new Insets(100, 0, 0, 0);
    this.add(new JLabel(""), c);

    c = new GridBagConstraints();
    c.fill = 0;
    c.gridwidth = 3;
    c.gridy = 1;
    c.insets = new Insets(0, 10, 20, 10);
    this.add(lblThumb, c);

    c = new GridBagConstraints();
    c.fill = 1;
    c.gridy = 2;
    this.add(lblPath, c);
    c.gridx = 1;
    c.gridwidth = 2;
    this.add(_txtPath, c);

    c = new GridBagConstraints();
    c.gridy = 3;
    c.fill = 0;
    this.add(lblFilename, c);
    this.add(_txtFilename, c);
    this.add(_txtFileExt, c);

    c = new GridBagConstraints();
    c.gridy = 4;
    c.gridx = 1;
    c.insets = new Insets(200, 0, 0, 0);
    this.add(msgApplied, c);
  }