Example usage for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED

List of usage examples for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED

Introduction

In this page you can find the example usage for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED.

Prototype

int VERTICAL_SCROLLBAR_AS_NEEDED

To view the source code for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED.

Click Source Link

Document

Used to set the vertical scroll bar policy so that vertical scrollbars are displayed only when needed.

Usage

From source file:com.mgmtp.jfunk.core.ui.JFunkFrame.java

private void setUpGui() {
    buildMenuBar();//www.  j  a v  a2s .  c  o m
    buildToolBar();
    buildPopup();
    buildTree();

    BufferedImage image = null;
    try {
        image = ImageIO.read(getClass().getResource("/jFunk.png"));
        setIconImage(image);
    } catch (Exception e) {
        log.warn("Could not read icon image, standard icon will be used. Exception was: " + e.getMessage());
    }

    setJMenuBar(menuBar);

    if (!readState()) {
        setSize(520, 600);
        setLocationRelativeTo(null);
    }

    final JScrollPane scrollPane = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    final Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(jPanelUtilities, BorderLayout.NORTH);
    contentPane.add(scrollPane, BorderLayout.CENTER);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            exit();
        }
    });
}

From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DViewExtensions.java

private void initComponents() {
    ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel();
    jtExtensions = new JKseTable(extensionsTableModel);

    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel);
    sorter.setComparator(2, new ObjectIdComparator());
    jtExtensions.setRowSorter(sorter);/*from  ww  w  . j a  va  2s.  c  o  m*/

    jtExtensions.setShowGrid(false);
    jtExtensions.setRowMargin(0);
    jtExtensions.getColumnModel().setColumnMargin(0);
    jtExtensions.getTableHeader().setReorderingAllowed(false);
    jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
    jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight()));

    for (int i = 0; i < jtExtensions.getColumnCount(); i++) {
        TableColumn column = jtExtensions.getColumnModel().getColumn(i);
        column.setHeaderRenderer(
                new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer()));
        column.setCellRenderer(new ExtensionsTableCellRend());
    }

    TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0);
    criticalCol.setResizable(false);
    criticalCol.setMinWidth(28);
    criticalCol.setMaxWidth(28);
    criticalCol.setPreferredWidth(28);

    ListSelectionModel selectionModel = jtExtensions.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectionModel.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                try {
                    CursorUtil.setCursorBusy(DViewExtensions.this);
                    updateExtensionValue();
                } finally {
                    CursorUtil.setCursorFree(DViewExtensions.this);
                }
            }
        }
    });

    jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground());

    jpExtensionsTable = new JPanel(new BorderLayout(5, 5));
    jpExtensionsTable.setPreferredSize(new Dimension(500, 200));
    jpExtensionsTable.add(jspExtensionsTable, BorderLayout.CENTER);

    jpExtensionValue = new JPanel(new BorderLayout(5, 5));

    jlExtensionValue = new JLabel(res.getString("DViewExtensions.jlExtensionValue.text"));

    jpExtensionValue.add(jlExtensionValue, BorderLayout.NORTH);

    jepExtensionValue = new JEditorPane();
    jepExtensionValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize()));
    jepExtensionValue.setEditable(false);
    jepExtensionValue.setToolTipText(res.getString("DViewExtensions.jtaExtensionValue.tooltip"));
    // JGoodies - keep uneditable color same as editable
    jepExtensionValue.putClientProperty("JTextArea.infoBackground", Boolean.TRUE);

    // for displaying URLs in extensions as clickable links
    jepExtensionValue.setContentType("text/html");
    jepExtensionValue.addHyperlinkListener(this);
    // use default font and foreground color from the component
    jepExtensionValue.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    jspExtensionValue = PlatformUtil.createScrollPane(jepExtensionValue,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    jpExtensionValueTextArea = new JPanel(new BorderLayout(5, 5));
    jpExtensionValueTextArea.setPreferredSize(new Dimension(500, 200));
    jpExtensionValueTextArea.add(jspExtensionValue, BorderLayout.CENTER);

    jpExtensionValue.add(jpExtensionValueTextArea, BorderLayout.CENTER);

    jbAsn1 = new JButton(res.getString("DViewExtensions.jbAsn1.text"));

    PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewExtensions.jbAsn1.mnemonic").charAt(0));
    jbAsn1.setToolTipText(res.getString("DViewExtensions.jbAsn1.tooltip"));
    jbAsn1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewExtensions.this);
                asn1DumpPressed();
            } finally {
                CursorUtil.setCursorFree(DViewExtensions.this);
            }
        }
    });

    jpExtensionValueAsn1 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    jpExtensionValueAsn1.add(jbAsn1);

    jpExtensionValue.add(jpExtensionValueAsn1, BorderLayout.SOUTH);

    jpExtensions = new JPanel(new GridLayout(2, 1, 5, 5));
    jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5),
            new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));

    jpExtensions.add(jpExtensionsTable);
    jpExtensions.add(jpExtensionValue);

    jbOK = new JButton(res.getString("DViewExtensions.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });

    jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false);

    extensionsTableModel.load(extensions);

    if (extensionsTableModel.getRowCount() > 0) {
        jtExtensions.changeSelection(0, 0, false, false);
    }

    getContentPane().add(jpExtensions, BorderLayout.CENTER);
    getContentPane().add(jpOK, BorderLayout.SOUTH);

    setResizable(false);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    getRootPane().setDefaultButton(jbOK);

    pack();

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            jbOK.requestFocus();
        }
    });
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java

/**
 * Creates a Pane for editing a Workbench as a form.
 * @param workbenchPane the workbench pane to be parented into
 * @param workbench the workbench//from  ww  w . java2  s  .c o  m
 */
public FormPane(final WorkbenchPaneSS workbenchPane, final Workbench workbench, final boolean readOnly) {
    setLayout(null);

    this.workbenchPane = workbenchPane;
    this.workbench = workbench;
    this.readOnly = readOnly;
    dropFlavors.add(InputPanel.INPUTPANEL_FLAVOR);

    docListener = new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            stateChange();
        }

    };

    changeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            stateChange();
        }
    };

    buildUI();

    scrollPane = new JScrollPane(this, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

}

From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java

/**
  * /*from www  .  j ava2s.  co  m*/
  */
protected void buildSpreadsheet() {

    this.setShowGrid(true);

    int numRows = model.getRowCount();

    scrollPane = new JScrollPane(this, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    final SpreadSheet ss = this;
    JButton cornerBtn = UIHelper.createIconBtn("Blank", IconManager.IconSize.Std16, "SelectAll",
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    ss.selectAll();
                }
            });
    cornerBtn.setEnabled(true);
    scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, cornerBtn);

    // Allows row and collumn selections to exit at the same time
    setCellSelectionEnabled(true);

    setRowSelectionAllowed(true);
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    addMouseListener(new MouseAdapter() {
        /* (non-Javadoc)
         * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent)
         */
        @SuppressWarnings("synthetic-access")
        @Override
        public void mouseReleased(MouseEvent e) {
            // XXX For Java 5 Bug
            prevRowSelInx = getSelectedRow();
            prevColSelInx = getSelectedColumn();

            if (e.getClickCount() == 2) {
                int rowIndexStart = getSelectedRow();
                int colIndexStart = getSelectedColumn();

                ss.editCellAt(rowIndexStart, colIndexStart);
                if (ss.getEditorComponent() != null && ss.getEditorComponent() instanceof JTextComponent) {
                    ss.getEditorComponent().requestFocus();

                    final JTextComponent txtComp = (JTextComponent) ss.getEditorComponent();
                    String txt = txtComp.getText();
                    FontMetrics fm = txtComp.getFontMetrics(txtComp.getFont());
                    int x = e.getPoint().x - ss.getEditorComponent().getBounds().x - 1;
                    int prevWidth = 0;
                    for (int i = 0; i < txt.length(); i++) {

                        int width = fm.stringWidth(txt.substring(0, i));
                        int basePlusHalf = prevWidth + (int) (((width - prevWidth) / 2) + 0.5);
                        //System.out.println(prevWidth + " X[" + x + "] " + width+" ["+txt.substring(0, i)+"] " + i + " " + basePlusHalf);
                        //System.out.println(" X[" + x + "] " + prevWidth + " - "+ basePlusHalf+" - " + width+" ["+txt.substring(0, i)+"] " + i);
                        if (x < width) {
                            // Clearing the selection is needed for Window for some reason
                            final int inx = i + (x <= basePlusHalf ? -1 : 0);
                            SwingUtilities.invokeLater(new Runnable() {
                                @SuppressWarnings("synthetic-access")
                                public void run() {
                                    txtComp.setSelectionStart(0);
                                    txtComp.setSelectionEnd(0);
                                    txtComp.setCaretPosition(inx > 0 ? inx : 0);
                                }
                            });
                            break;
                        }
                        prevWidth = width;
                    }
                }
            }
        }
    });

    // Create a row-header to display row numbers.
    // This row-header is made of labels whose Borders,
    // Foregrounds, Backgrounds, and Fonts must be
    // the one used for the table column headers.
    // Also ensure that the row-header labels and the table
    // rows have the same height.

    //i have no idea WHY this has to be called.  i rearranged
    //the table and find replace panel, 
    // i started getting an array index out of
    //bounds on the column header ON MAC ONLY.  
    //tried firing this off, first and it fixed the problem.//meg
    this.getModel().fireTableStructureChanged();

    /*
     * Create the Row Header Panel
     */
    rowHeaderPanel = new JPanel((LayoutManager) null);

    if (getColumnModel().getColumnCount() > 0) {
        TableColumn column = getColumnModel().getColumn(0);
        TableCellRenderer renderer = getTableHeader().getDefaultRenderer();
        if (renderer == null) {
            renderer = column.getHeaderRenderer();
        }

        Component cellRenderComp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false,
                false, -1, 0);
        cellFont = cellRenderComp.getFont();

    } else {
        cellFont = (new JLabel()).getFont();
    }

    // Calculate Row Height
    cellBorder = (Border) UIManager.getDefaults().get("TableHeader.cellBorder");
    Insets insets = cellBorder.getBorderInsets(tableHeader);
    FontMetrics metrics = getFontMetrics(cellFont);

    rowHeight = insets.bottom + metrics.getHeight() + insets.top;
    rowLabelWidth = metrics.stringWidth("9999") + insets.right + insets.left;

    Dimension dim = new Dimension(rowLabelWidth, rowHeight * numRows);
    rowHeaderPanel.setPreferredSize(dim); // need to call this when no layout manager is used.

    rhCellMouseAdapter = new RHCellMouseAdapter(this);

    // Adding the row header labels
    for (int ii = 0; ii < numRows; ii++) {
        addRow(ii, ii + 1, false);
    }

    JViewport viewPort = new JViewport();
    dim.height = rowHeight * numRows;
    viewPort.setViewSize(dim);
    viewPort.setView(rowHeaderPanel);
    scrollPane.setRowHeader(viewPort);

    // Experimental from the web, but I think it does the trick.
    addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (!ss.isEditing() && !e.isActionKey() && !e.isControlDown() && !e.isMetaDown() && !e.isAltDown()
                    && e.getKeyCode() != KeyEvent.VK_SHIFT && e.getKeyCode() != KeyEvent.VK_TAB
                    && e.getKeyCode() != KeyEvent.VK_ENTER) {
                log.error("Grabbed the event as input");

                int rowIndexStart = getSelectedRow();
                int colIndexStart = getSelectedColumn();

                if (rowIndexStart == -1 || colIndexStart == -1)
                    return;

                ss.editCellAt(rowIndexStart, colIndexStart);
                Component c = ss.getEditorComponent();
                if (c instanceof JTextComponent)
                    ((JTextComponent) c).setText("");
            }
        }
    });

    resizeAndRepaint();

    // Taken from a JavaWorld Example (But it works)
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
            false);
    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
            false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);

    Action ssAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SpreadSheet.this.actionPerformed(e);
        }
    };

    getInputMap().put(cut, "Cut");
    getActionMap().put("Cut", ssAction);

    getInputMap().put(copy, "Copy");
    getActionMap().put("Copy", ssAction);

    getInputMap().put(paste, "Paste");
    getActionMap().put("Paste", ssAction);

    ((JMenuItem) UIRegistry.get(UIRegistry.COPY)).addActionListener(this);
    ((JMenuItem) UIRegistry.get(UIRegistry.CUT)).addActionListener(this);
    ((JMenuItem) UIRegistry.get(UIRegistry.PASTE)).addActionListener(this);

    setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED);
}

From source file:edu.ku.brc.specify.ui.SelectPrepsDlg.java

@Override
public void createUI() {
    applyLabel = getResourceString("SELECTALL");//$NON-NLS-1$

    super.createUI();

    Vector<ColObjInfo> coList = new Vector<ColObjInfo>(coToPrepHash.values());
    Collections.sort(coList, new Comparator<ColObjInfo>() {
        @Override//www.j  ava2  s.  c  o m
        public int compare(ColObjInfo o1, ColObjInfo o2) {
            return o1.getCatNo().compareTo(o2.getCatNo());
        }
    });

    int cnt = 0;
    Vector<ColObjInfo> coFilteredList = new Vector<ColObjInfo>();
    for (ColObjInfo colObjInfo : coList) {
        if (StringUtils.isNotEmpty(colObjInfo.getCatNo()) && colObjInfo.getPreps() != null
                && colObjInfo.getPreps().size() > 0) {
            coFilteredList.add(colObjInfo);
            cnt += colObjInfo.getPreps().size();
        }
    }

    String rowDef = UIHelper.createDuplicateJGoodiesDef("p", "1px,p,4px", (cnt * 2) - 1) + ",10px,p"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    PanelBuilder pbuilder = new PanelBuilder(new FormLayout("f:p:g", rowDef)); //$NON-NLS-1$
    CellConstraints cc = new CellConstraints();

    ActionListener al = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            doEnableOKBtn();
        }
    };

    ChangeListener cl = new ChangeListener() {
        public void stateChanged(ChangeEvent ae) {
            doEnableOKBtn();
        }
    };

    DBTableInfo colObjTI = DBTableIdMgr.getInstance().getInfoById(CollectionObject.getClassTableId());
    DBFieldInfo colObjFI = colObjTI.getFieldByColumnName("CatalogNumber");

    int i = 0;
    int y = 1;
    for (ColObjInfo colObjInfo : coFilteredList) {
        if (i > 0) {
            pbuilder.addSeparator("", cc.xy(1, y)); //$NON-NLS-1$
        }
        y += 2;

        colObjInfo.setCatNo((String) colObjFI.getFormatter().formatToUI(colObjInfo.getCatNo()));
        ColObjPanel panel = new ColObjPanel(this, colObjInfo);
        colObjPanels.add(panel);
        panel.addActionListener(al, cl);
        pbuilder.add(panel, cc.xy(1, y));
        y += 2;
        i++;
    }

    applyBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            selectAllItems();
        }
    });

    JPanel tPanel = new JPanel(new BorderLayout());
    summaryLabel = createLabel(""); //$NON-NLS-1$
    tPanel.setBorder(BorderFactory.createEmptyBorder(5, 1, 5, 1));
    tPanel.add(summaryLabel, BorderLayout.NORTH);

    JScrollPane sp = new JScrollPane(pbuilder.getPanel(), ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    tPanel.add(sp, BorderLayout.CENTER);

    contentPanel = tPanel;
    mainPanel.add(contentPanel, BorderLayout.CENTER);

    pack();

    doEnableOKBtn();

    Dimension size = getPreferredSize();
    size.width += 20;
    size.height = size.height > 500 ? 500 : size.height;
    setSize(size);
}

From source file:org.esa.snap.rcp.statistics.ChartPagePanel.java

protected void createUI(final ChartPanel chartPanel, final JPanel optionsPanel, BindingContext bindingContext) {
    roiMaskSelector = new RoiMaskSelector(bindingContext);

    final JPanel extendedOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints(
            "insets.left=4,insets.right=2,anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "gridy=0");
    GridBagUtils.addToPanel(extendedOptionsPanel, roiMaskSelector.createPanel(),
            extendedOptionsPanelConstraints, "gridy=1,insets.left=-4");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JPanel(), extendedOptionsPanelConstraints,
            "gridy=1,insets.left=-4");
    GridBagUtils.addToPanel(extendedOptionsPanel, optionsPanel, extendedOptionsPanelConstraints,
            "insets.left=0,insets.right=0,gridy=2,fill=VERTICAL,fill=HORIZONTAL,weighty=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints,
            "insets.left=4,insets.right=2,gridy=5,anchor=SOUTHWEST");

    final SimpleScrollPane optionsScrollPane = new SimpleScrollPane(extendedOptionsPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    optionsScrollPane.setBorder(null);/*from w  ww  .java2s. c  om*/
    optionsScrollPane.getVerticalScrollBar().setUnitIncrement(20);

    final JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(createTopPanel(), BorderLayout.NORTH);
    rightPanel.add(optionsScrollPane, BorderLayout.CENTER);
    rightPanel.add(createChartBottomPanel(chartPanel), BorderLayout.SOUTH);

    final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
    final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
    final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
    final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);

    hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
    hideAndShowButton.setToolTipText("Collapse Options Panel");
    hideAndShowButton.setName("switchToChartButton");
    hideAndShowButton.addActionListener(new ActionListener() {

        public boolean rightPanelShown;

        @Override
        public void actionPerformed(ActionEvent e) {
            rightPanel.setVisible(rightPanelShown);
            if (rightPanelShown) {
                hideAndShowButton.setIcon(collapseIcon);
                hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
                hideAndShowButton.setToolTipText("Collapse Options Panel");
            } else {
                hideAndShowButton.setIcon(expandIcon);
                hideAndShowButton.setRolloverIcon(expandRolloverIcon);
                hideAndShowButton.setToolTipText("Expand Options Panel");
            }
            rightPanelShown = !rightPanelShown;
        }
    });

    backgroundPanel = new JPanel(new BorderLayout());
    backgroundPanel.add(chartPanel, BorderLayout.CENTER);
    backgroundPanel.add(rightPanel, BorderLayout.EAST);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.add(backgroundPanel, new Integer(0));
    layeredPane.add(hideAndShowButton, new Integer(1));
    add(layeredPane);
}

From source file:forge.gui.ImportDialog.java

@SuppressWarnings("serial")
public ImportDialog(final String forcedSrcDir, final Runnable onDialogClose) {
    this.forcedSrcDir = forcedSrcDir;

    _topPanel = new FPanel(new MigLayout("insets dialog, gap 0, center, wrap, fill"));
    _topPanel.setOpaque(false);/*from ww w .j ava 2s .co  m*/
    _topPanel.setBackgroundTexture(FSkin.getIcon(FSkinProp.BG_TEXTURE));

    isMigration = !StringUtils.isEmpty(forcedSrcDir);

    // header
    _topPanel.add(new FLabel.Builder().text((isMigration ? "Migrate" : "Import") + " profile data").fontSize(15)
            .build(), "center");

    // add some help text if this is for the initial data migration
    if (isMigration) {
        final FPanel blurbPanel = new FPanel(new MigLayout("insets panel, gap 10, fill"));
        blurbPanel.setOpaque(false);
        final JPanel blurbPanelInterior = new JPanel(
                new MigLayout("insets dialog, gap 10, center, wrap, fill"));
        blurbPanelInterior.setOpaque(false);
        blurbPanelInterior.add(new FLabel.Builder().text("<html><b>What's this?</b></html>").build(),
                "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder()
                .text("<html>Over the last several years, people have had to jump through a lot of hoops to"
                        + " update to the most recent version.  We hope to reduce this workload to a point where a new"
                        + " user will find that it is fairly painless to update.  In order to make this happen, Forge"
                        + " has changed where it stores your data so that it is outside of the program installation directory."
                        + "  This way, when you upgrade, you will no longer need to import your data every time to get things"
                        + " working.  There are other benefits to having user data separate from program data, too, and it"
                        + " lays the groundwork for some cool new features.</html>")
                .build(), "growx, w 50:50:");
        blurbPanelInterior.add(
                new FLabel.Builder().text("<html><b>So where's my data going?</b></html>").build(),
                "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder().text(
                "<html>Forge will now store your data in the same place as other applications on your system."
                        + "  Specifically, your personal data, like decks, quest progress, and program preferences will be"
                        + " stored in <b>" + ForgeConstants.USER_DIR
                        + "</b> and all downloaded content, such as card pictures,"
                        + " skins, and quest world prices will be under <b>" + ForgeConstants.CACHE_DIR
                        + "</b>.  If, for whatever"
                        + " reason, you need to set different paths, cancel out of this dialog, exit Forge, and find the <b>"
                        + ForgeConstants.PROFILE_TEMPLATE_FILE
                        + "</b> file in the program installation directory.  Copy or rename" + " it to <b>"
                        + ForgeConstants.PROFILE_FILE
                        + "</b> and edit the paths inside it.  Then restart Forge and use"
                        + " this dialog to move your data to the paths that you set.  Keep in mind that if you install a future"
                        + " version of Forge into a different directory, you'll need to copy this file over so Forge will know"
                        + " where to find your data.</html>")
                .build(), "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder().text(
                "<html><b>Remember, your data won't be available until you complete this step!</b></html>")
                .build(), "growx, w 50:50:");

        final FScrollPane blurbScroller = new FScrollPane(blurbPanelInterior, true,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        blurbPanel.add(blurbScroller, "hmin 150, growy, growx, center, gap 0 0 5 5");
        _topPanel.add(blurbPanel, "gap 10 10 20 0, growy, growx, w 50:50:");
    }

    // import source widgets
    final JPanel importSourcePanel = new JPanel(new MigLayout("insets 0, gap 10"));
    importSourcePanel.setOpaque(false);
    importSourcePanel.add(new FLabel.Builder().text("Import from:").build());
    _txfSrc = new FTextField.Builder().readonly().build();
    importSourcePanel.add(_txfSrc, "pushx, growx");
    _btnChooseDir = new FLabel.ButtonBuilder().text("Choose directory...").enabled(!isMigration).build();
    final JFileChooser _fileChooser = new JFileChooser();
    _fileChooser.setMultiSelectionEnabled(false);
    _fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    _btnChooseDir.setCommand(new UiCommand() {
        @Override
        public void run() {
            // bring up a file open dialog and, if the OK button is selected, apply the filename
            // to the import source text field
            if (JFileChooser.APPROVE_OPTION == _fileChooser.showOpenDialog(JOptionPane.getRootFrame())) {
                final File f = _fileChooser.getSelectedFile();
                if (!f.canRead()) {
                    FOptionPane.showErrorDialog("Cannot access selected directory (Permission denied).");
                } else {
                    _txfSrc.setText(f.getAbsolutePath());
                }
            }
        }
    });
    importSourcePanel.add(_btnChooseDir, "h pref+8!, w pref+12!");

    // add change handler to the import source text field that starts up a
    // new analyzer.  it also interacts with the current active analyzer,
    // if any, to make sure it cancels out before the new one is initiated
    _txfSrc.getDocument().addDocumentListener(new DocumentListener() {
        boolean _analyzerActive; // access synchronized on _onAnalyzerDone
        String prevText;

        private final Runnable _onAnalyzerDone = new Runnable() {
            @Override
            public synchronized void run() {
                _analyzerActive = false;
                notify();
            }
        };

        @Override
        public void removeUpdate(final DocumentEvent e) {
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
        }

        @Override
        public void insertUpdate(final DocumentEvent e) {
            // text field is read-only, so the only time this will get updated
            // is when _btnChooseDir does it
            final String text = _txfSrc.getText();
            if (text.equals(prevText)) {
                // only restart the analyzer if the directory has changed
                return;
            }
            prevText = text;

            // cancel any active analyzer
            _cancel = true;

            if (!text.isEmpty()) {
                // ensure we don't get two instances of this function running at the same time
                _btnChooseDir.setEnabled(false);

                // re-disable the start button.  it will be enabled if the previous analyzer has
                // already successfully finished
                _btnStart.setEnabled(false);

                // we have to wait in a background thread since we can't block in the GUI thread
                final SwingWorker<Void, Void> analyzerStarter = new SwingWorker<Void, Void>() {
                    @Override
                    protected Void doInBackground() throws Exception {
                        // wait for active analyzer (if any) to quit
                        synchronized (_onAnalyzerDone) {
                            while (_analyzerActive) {
                                _onAnalyzerDone.wait();
                            }
                        }
                        return null;
                    }

                    // executes in gui event loop thread
                    @Override
                    protected void done() {
                        _cancel = false;
                        synchronized (_onAnalyzerDone) {
                            // this will populate the panel with data selection widgets
                            final _AnalyzerUpdater analyzer = new _AnalyzerUpdater(text, _onAnalyzerDone,
                                    isMigration);
                            analyzer.run();
                            _analyzerActive = true;
                        }
                        if (!isMigration) {
                            // only enable the directory choosing button if this is not a migration dialog
                            // since in that case we're permanently locked to the starting directory
                            _btnChooseDir.setEnabled(true);
                        }
                    }
                };
                analyzerStarter.execute();
            }
        }
    });
    _topPanel.add(importSourcePanel, "gaptop 20, pushx, growx");

    // prepare import selection panel (will be cleared and filled in later by an analyzer)
    _selectionPanel = new JPanel();
    _selectionPanel.setOpaque(false);
    _topPanel.add(_selectionPanel, "growx, growy, gaptop 10");

    // action button widgets
    final Runnable cleanup = new Runnable() {
        @Override
        public void run() {
            SOverlayUtils.hideOverlay();
        }
    };
    _btnStart = new FButton("Start import");
    _btnStart.setEnabled(false);
    _btnCancel = new FButton("Cancel");
    _btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            _cancel = true;
            cleanup.run();
            if (null != onDialogClose) {
                onDialogClose.run();
            }
        }
    });

    final JPanel southPanel = new JPanel(new MigLayout("ax center"));
    southPanel.setOpaque(false);
    southPanel.add(_btnStart, "center, w pref+144!, h pref+12!");
    southPanel.add(_btnCancel, "center, w pref+144!, h pref+12!, gap 72");
    _topPanel.add(southPanel, "growx");
}

From source file:org.esa.beam.visat.toolviews.stat.ChartPagePanel.java

protected void createUI(final ChartPanel chartPanel, final JPanel optionsPanel, BindingContext bindingContext) {
    roiMaskSelector = new RoiMaskSelector(bindingContext);

    final JPanel extendedOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints(
            "insets.left=4,insets.right=2,anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints, "gridy=0");
    GridBagUtils.addToPanel(extendedOptionsPanel, roiMaskSelector.createPanel(),
            extendedOptionsPanelConstraints, "gridy=1,insets.left=-4");
    GridBagUtils.addToPanel(extendedOptionsPanel, optionsPanel, extendedOptionsPanelConstraints,
            "insets.left=0,insets.right=0,gridy=2,fill=VERTICAL,fill=HORIZONTAL,weighty=1");
    GridBagUtils.addToPanel(extendedOptionsPanel, new JSeparator(), extendedOptionsPanelConstraints,
            "insets.left=4,insets.right=2,gridy=5,anchor=SOUTHWEST");

    final JScrollPane optionsScrollPane = new SimpleScrollPane(extendedOptionsPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    optionsScrollPane.setBorder(null);//from w w  w . j  a v a2s. c o  m

    final JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(createTopPanel(), BorderLayout.NORTH);
    rightPanel.add(optionsScrollPane, BorderLayout.CENTER);
    rightPanel.add(createChartBottomPanel(chartPanel), BorderLayout.SOUTH);

    final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
    final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
    final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
    final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);

    hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
    hideAndShowButton.setToolTipText("Collapse Options Panel");
    hideAndShowButton.setName("switchToChartButton");
    hideAndShowButton.addActionListener(new ActionListener() {

        public boolean rightPanelShown;

        @Override
        public void actionPerformed(ActionEvent e) {
            rightPanel.setVisible(rightPanelShown);
            if (rightPanelShown) {
                hideAndShowButton.setIcon(collapseIcon);
                hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
                hideAndShowButton.setToolTipText("Collapse Options Panel");
            } else {
                hideAndShowButton.setIcon(expandIcon);
                hideAndShowButton.setRolloverIcon(expandRolloverIcon);
                hideAndShowButton.setToolTipText("Expand Options Panel");
            }
            rightPanelShown = !rightPanelShown;
        }
    });

    backgroundPanel = new JPanel(new BorderLayout());
    backgroundPanel.add(chartPanel, BorderLayout.CENTER);
    backgroundPanel.add(rightPanel, BorderLayout.EAST);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.add(backgroundPanel, new Integer(0));
    layeredPane.add(hideAndShowButton, new Integer(1));
    add(layeredPane);
}

From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java

/**
 * Customization of external program paths.
 *
 * @param prefs a <code>JabRefPreferences</code> value
 *//*from  ww w  .j  a  v  a  2 s.co m*/
public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
    this.prefs = prefs;
    this.frame = frame;
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return rowCount;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            int internalRow = row;
            if (internalRow == 0) {
                return column == 0 ? InternalBibtexFields.NUMBER_COL : String.valueOf(ncWidth);
            }
            internalRow--;
            if (internalRow >= tableRows.size()) {
                return "";
            }
            Object rowContent = tableRows.get(internalRow);
            if (rowContent == null) {
                return "";
            }
            TableRow tr = (TableRow) rowContent;
            // Only two columns
            if (column == 0) {
                return tr.getName();
            } else {
                return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : "";
            }
        }

        @Override
        public String getColumnName(int col) {
            return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width");
        }

        @Override
        public Class<?> getColumnClass(int column) {
            if (column == 0) {
                return String.class;
            }
            return Integer.class;
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return !((row == 0) && (col == 0));
        }

        @Override
        public void setValueAt(Object value, int row, int col) {
            tableChanged = true;
            // Make sure the vector is long enough.
            while (row >= tableRows.size()) {
                tableRows.add(new TableRow("", -1));
            }

            if ((row == 0) && (col == 1)) {
                ncWidth = Integer.parseInt(value.toString());
                return;
            }

            TableRow rowContent = tableRows.get(row - 1);

            if (col == 0) {
                rowContent.setName(value.toString());
                if ("".equals(getValueAt(row, 1))) {
                    setValueAt(String.valueOf(BibtexSingleField.DEFAULT_FIELD_LENGTH), row, 1);
                }
            } else {
                if (value == null) {
                    rowContent.setLength(-1);
                } else {
                    rowContent.setLength(Integer.parseInt(value.toString()));
                }
            }
        }

    };

    colSetup = new JTable(tm);
    TableColumnModel cm = colSetup.getColumnModel();
    cm.getColumn(0).setPreferredWidth(140);
    cm.getColumn(1).setPreferredWidth(80);

    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();
    JPanel tabPanel = new JPanel();
    tabPanel.setLayout(new BorderLayout());
    JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200));
    sp.setMinimumSize(new Dimension(250, 300));
    tabPanel.add(sp, BorderLayout.CENTER);
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setFloatable(false);
    AddRowAction addRow = new AddRowAction();
    DeleteRowAction deleteRow = new DeleteRowAction();
    MoveRowUpAction moveUp = new MoveRowUpAction();
    MoveRowDownAction moveDown = new MoveRowDownAction();
    toolBar.setBorder(null);
    toolBar.add(addRow);
    toolBar.add(deleteRow);
    toolBar.addSeparator();
    toolBar.add(moveUp);
    toolBar.add(moveDown);
    tabPanel.add(toolBar, BorderLayout.EAST);

    fileColumn = new JCheckBox(Localization.lang("Show file column"));
    urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column"));
    preferUrl = new JRadioButton(Localization.lang("Show URL first"));
    preferDoi = new JRadioButton(Localization.lang("Show DOI first"));
    ButtonGroup preferUrlDoiGroup = new ButtonGroup();
    preferUrlDoiGroup.add(preferUrl);
    preferUrlDoiGroup.add(preferDoi);

    urlColumn.addChangeListener(arg0 -> {
        preferUrl.setEnabled(urlColumn.isSelected());
        preferDoi.setEnabled(urlColumn.isSelected());
    });
    arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column"));

    Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection();
    String[] fileTypeNames = new String[fileTypes.size()];
    int i = 0;
    for (ExternalFileType fileType : fileTypes) {
        fileTypeNames[i++] = fileType.getName();
    }
    listOfFileColumns = new JList<>(fileTypeNames);
    JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns);
    listOfFileColumns.setVisibleRowCount(3);
    extraFileColumns = new JCheckBox(Localization.lang("Show extra columns"));
    extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected()));

    /*** begin: special table columns and special fields ***/

    JButton helpButton = new HelpAction(Localization.lang("Help on special fields"), HelpFile.SPECIAL_FIELDS)
            .getHelpButton();

    rankingColumn = new JCheckBox(Localization.lang("Show rank"));
    qualityColumn = new JCheckBox(Localization.lang("Show quality"));
    priorityColumn = new JCheckBox(Localization.lang("Show priority"));
    relevanceColumn = new JCheckBox(Localization.lang("Show relevance"));
    printedColumn = new JCheckBox(Localization.lang("Show printed status"));
    readStatusColumn = new JCheckBox(Localization.lang("Show read status"));

    // "sync keywords" and "write special" fields may be configured mutually exclusive only
    // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense)
    // To avoid confusion, we opted to make the setting mutually exclusive
    syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords"));
    writeSpecialFields = new JRadioButton(
            Localization.lang("Write values of special fields as separate fields to BibTeX"));
    ButtonGroup group = new ButtonGroup();
    group.add(syncKeywords);
    group.add(writeSpecialFields);

    specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields"));
    specialFieldsEnabled.addChangeListener(event -> {
        boolean isEnabled = specialFieldsEnabled.isSelected();
        rankingColumn.setEnabled(isEnabled);
        qualityColumn.setEnabled(isEnabled);
        priorityColumn.setEnabled(isEnabled);
        relevanceColumn.setEnabled(isEnabled);
        printedColumn.setEnabled(isEnabled);
        readStatusColumn.setEnabled(isEnabled);
        syncKeywords.setEnabled(isEnabled);
        writeSpecialFields.setEnabled(isEnabled);
    });

    builder.appendSeparator(Localization.lang("Special table columns"));
    builder.nextLine();
    builder.append(pan);

    DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder(
            new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow",
                    "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"));
    CellConstraints cc = new CellConstraints();

    specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3));
    specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2));
    specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2));
    specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2));
    specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2));
    specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2));
    specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2));
    specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2));
    specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2));
    specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2));

    specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2));
    specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2));
    specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3));
    specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4));
    specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2));

    specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2));
    specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6));

    builder.append(specialTableColumnsBuilder.getPanel());
    builder.nextLine();

    /*** end: special table columns and special fields ***/

    builder.appendSeparator(Localization.lang("Entry table columns"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();
    builder.append(pan);
    JButton buttonWidth = new JButton(new UpdateWidthsAction());
    JButton buttonOrder = new JButton(new UpdateOrderAction());
    builder.append(buttonWidth);
    builder.nextLine();
    builder.append(pan);
    builder.append(buttonOrder);
    builder.nextLine();
    builder.append(pan);
    builder.nextLine();
    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.ImageFrame.java

/**
 * Constructor. //  w  ww  . java 2 s  .com
 */
public ImageFrame(final int mapSize, final WorkbenchPaneSS wbPane, final Workbench workbench,
        final Taskable task, final boolean isReadOnly) {
    this.wbPane = wbPane;
    this.workbench = workbench;

    try {
        this.workbenchTask = (WorkbenchTask) task;
    } catch (ClassCastException e) {
        this.workbenchTask = null;
    }

    this.allowCloseWindow = true;
    this.defaultThumbIcon = IconManager.getIcon("image", IconSize.Std32);

    setIconImage(IconManager.getImage("AppIcon").getImage());

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            if (allowCloseWindow) {
                wbPane.toggleImageFrameVisible();
            }
        }
    });

    Dimension minSize = new Dimension(mapSize, mapSize);
    cardImageLabel.setHorizontalTextPosition(SwingConstants.CENTER);

    PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g,c:p,f:p:g", "f:p:g,p,5px,p,f:p:g"));
    CellConstraints cc = new CellConstraints();

    loadImgBtn = createButton(getResourceString("WB_LOAD_NEW_IMAGE"));

    builder.add(createLabel(getResourceString("WB_NO_IMAGE_ROW"), SwingConstants.CENTER), cc.xy(2, 2));
    builder.add(loadImgBtn, cc.xy(2, 4));
    loadImgBtn.setVisible(!isReadOnly);

    noCardImageMessagePanel = builder.getPanel();
    noCardImageMessagePanel.setPreferredSize(minSize);
    noCardImageMessagePanel.setSize(minSize);

    builder = new PanelBuilder(new FormLayout("f:p:g,c:p,f:p:g", "f:p:g,c:p,f:p:g"));
    builder.add(createLabel(getResourceString("WB_NO_ROW_SELECTED"), SwingConstants.CENTER), cc.xy(2, 2));

    noRowSelectedMessagePanel = builder.getPanel();
    noRowSelectedMessagePanel.setPreferredSize(minSize);
    noRowSelectedMessagePanel.setSize(minSize);

    mainPane = new JPanel(new BorderLayout());
    mainPane.setSize(minSize);
    mainPane.setPreferredSize(minSize);
    mainPane.setMinimumSize(minSize);

    mainPane.add(cardImageLabel, BorderLayout.CENTER);
    scrollPane = new JScrollPane(mainPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    statusBar = new JStatusBar();

    thumbnailer = new ImageThumbnailGenerator();
    thumbnailer.setMaxSize(256, 256);
    thumbnailer.setQuality(1);

    tray = new ThumbnailTray();
    tray.getModel().removeAllElements();
    tray.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }

            setImageIndex(tray.getSelectedIndex());
        }
    });

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new BorderLayout());

    //southPanel.add(indexSlider,BorderLayout.NORTH);
    southPanel.add(tray, BorderLayout.CENTER);
    southPanel.add(statusBar, BorderLayout.SOUTH);

    JPanel basePanel = new JPanel();
    basePanel.setLayout(new BorderLayout());
    basePanel.add(scrollPane, BorderLayout.CENTER);
    basePanel.add(southPanel, BorderLayout.SOUTH);

    setContentPane(basePanel);

    JMenuBar menuBar = new JMenuBar();

    String title = "FileMenu";
    String mneu = "FileMneu";
    JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu);
    title = "WB_IMPORT_CARDS_TO_DATASET";
    mneu = "WB_IMPORT_CARDS_MNEU";

    if (!isReadOnly) {
        JMenuItem importImagesMI = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, null);
        importImagesMI.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {

                importImages();
            }
        });
    }

    /*        title = "ImageFrame.CLOSE";
            mneu = "ImageFrame.CloseMneu";
            closeMI = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu,  "", true, null);
            closeMI.addActionListener(new ActionListener()
            {
    public void actionPerformed(ActionEvent ae)
    {
        ImageFrame.this.setVisible(false);
    }
            });*/

    title = "ImageFrame.View";
    mneu = "ImageFrame.ViewMneu";
    viewMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu);
    reduceMI = UIHelper.createRadioButtonMenuItem(viewMenu, "WB_REDUCED_SIZE", "ImageFrame.ReducedSizeMneu", "",
            true, null);
    reduceMI.setSelected(true);
    reduceMI.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (row == null) {
                return;
            }

            // simply 'remember' that we want to show reduced images for this row
            rowToImageSizeHash.put(row.hashCode(), REDUCED_SIZE);
            // then 'reshow' the current image
            showImage();
        }
    });

    origMI = UIHelper.createRadioButtonMenuItem(viewMenu, "WB_ORIG_SIZE", "ImageFrame.OrigMneu", "", true,
            null);
    origMI.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (row == null) {
                return;
            }

            // simply 'remember' that we want to show fill size images for this row
            rowToImageSizeHash.put(row.hashCode(), FULL_SIZE);
            // then 'reshow' the current image
            showImage();
        }
    });

    ButtonGroup btnGrp = new ButtonGroup();
    btnGrp.add(reduceMI);
    btnGrp.add(origMI);

    viewMenu.addSeparator();

    alwaysOnTopMI = UIHelper.createCheckBoxMenuItem(viewMenu, "WB_ALWAYS_ON_TOP", null, "", true, null);
    alwaysOnTopMI.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            ImageFrame.this.setAlwaysOnTop(alwaysOnTopMI.isSelected());
        }
    });

    addPropertyChangeListener("alwaysOnTop", this);

    if (!isReadOnly) {
        ActionListener deleteImg = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                deleteImage();
            }
        };

        ActionListener replaceImg = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                replaceImage();
            }
        };

        ActionListener addImg = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                addImages();
            }
        };

        title = "ImageFrame.Image";
        mneu = "ImageFrame.ImageMneu";
        imageMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu);

        title = "WB_ADD_IMG";
        mneu = "WB_ADD_IMG_MNEM";
        addMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, addImg);

        title = "WB_REPLACE_IMG";
        mneu = "WB_REPLACE_IMG_MNEU";
        replaceMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, replaceImg);

        title = "WB_DEL_IMG_LINK";
        mneu = "WB_DEL_IMG_LINK_MNEU";
        deleteMI = UIHelper.createLocalizedMenuItem(imageMenu, title, mneu, "", true, deleteImg);

        loadImgBtn.addActionListener(addImg);
    }

    JMenu helpMenu = new JMenu(getResourceString("HELP"));
    menuBar.add(HelpMgr.createHelpMenuItem(helpMenu, getResourceString("WB_IMAGE_WINDOW")));

    enableMenus(false);

    setJMenuBar(menuBar);

    pack();

    HelpMgr.setHelpID(this, "WorkbenchWorkingWithImages");
}