Search in sources :

Example 26 with JProgressBar

use of javax.swing.JProgressBar in project MtgDesktopCompanion by nicho92.

the class CollectionPanelGUI method initGUI.

public void initGUI() throws IOException, SQLException, ClassNotFoundException {
    logger.info("init collection GUI");
    MagicEditionsTableModel model;
    JProgressBar progressBar;
    JTabbedPane tabbedPane;
    TypeRepartitionPanel typeRepartitionPanel;
    ManaRepartitionPanel manaRepartitionPanel;
    RarityRepartitionPanel rarityRepartitionPanel;
    MagicCardDetailPanel magicCardDetailPanel;
    CardStockPanel statsPanel;
    JLabel lblTotal;
    // //////INIT COMPONENTS
    JPanel panneauHaut = new JPanel();
    JButton btnAdd = new JButton(MTGConstants.ICON_NEW);
    JButton btnRefresh = new JButton(MTGConstants.ICON_REFRESH);
    JButton btnRemove = new JButton(MTGConstants.ICON_DELETE);
    JButton btnAddAllSet = new JButton(MTGConstants.ICON_CHECK);
    JButton btnExport = new JButton(MTGConstants.ICON_EXPORT);
    JButton btnMassCollection = new JButton(MTGConstants.ICON_IMPORT);
    JButton btnExportPriceCatalog = new JButton(MTGConstants.ICON_EURO);
    JButton btnGenerateWebSite = new JButton(MTGConstants.ICON_WEBSITE);
    JScrollPane scrollPaneCollections = new JScrollPane();
    JScrollPane scrollPrices = new JScrollPane();
    JSplitPane splitListPanel = new JSplitPane();
    JSplitPane splitPane = new JSplitPane();
    JPanel panneauGauche = new JPanel();
    JScrollPane scrollPane = new JScrollPane();
    JPanel panelTotal = new JPanel();
    JPanel panneauDroite = new JPanel();
    MagicCollectionTableCellRenderer render = new MagicCollectionTableCellRenderer();
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    progressBar = new JProgressBar();
    lblTotal = new JLabel();
    magicEditionDetailPanel = new MagicEditionDetailPanel(true, false);
    magicCardDetailPanel = new MagicCardDetailPanel();
    typeRepartitionPanel = new TypeRepartitionPanel();
    manaRepartitionPanel = new ManaRepartitionPanel();
    rarityRepartitionPanel = new RarityRepartitionPanel();
    statsPanel = new CardStockPanel();
    historyPricesPanel = new HistoryPricesPanel();
    jsonPanel = new JSONPanel();
    tree = new LazyLoadingTree();
    tableEditions = new JXTable();
    // //////MODELS
    model = new MagicEditionsTableModel();
    DefaultRowSorter sorterEditions = new TableRowSorter<DefaultTableModel>(model);
    modelPrices = new CardsPriceTableModel();
    tablePrices = new JXTable(modelPrices);
    model.init(provider.loadEditions());
    tableEditions.setModel(model);
    new TableFilterHeader(tableEditions, AutoChoices.ENABLED);
    // ///////CONFIGURE COMPONENTS
    splitListPanel.setDividerLocation(0.5);
    splitListPanel.setResizeWeight(0.5);
    progressBar.setVisible(false);
    btnRemove.setEnabled(true);
    btnExport.setEnabled(false);
    btnExportPriceCatalog.setEnabled(false);
    splitPane.setResizeWeight(0.5);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    scrollPaneCollections.setMinimumSize(new Dimension(0, 0));
    tree.setCellRenderer(new MagicCardsTreeCellRenderer());
    tablePrices.setColumnControlVisible(true);
    magicCardDetailPanel.setPreferredSize(new Dimension(0, 0));
    magicCardDetailPanel.enableThumbnail(true);
    tableEditions.setDefaultRenderer(Object.class, render);
    tableEditions.setDefaultRenderer(String.class, render);
    tableEditions.setDefaultRenderer(Integer.class, render);
    tableEditions.setDefaultRenderer(double.class, render);
    tableEditions.setRowHeight(25);
    tableEditions.setRowSorter(sorterEditions);
    // ///////LAYOUT
    setLayout(new BorderLayout(0, 0));
    panneauDroite.setLayout(new BorderLayout());
    panneauGauche.setLayout(new BorderLayout(0, 0));
    // ///////ADD PANELS
    add(panneauHaut, BorderLayout.NORTH);
    panneauHaut.add(btnAdd);
    panneauHaut.add(btnRefresh);
    panneauHaut.add(btnRemove);
    panneauHaut.add(btnAddAllSet);
    panneauHaut.add(btnMassCollection);
    panneauHaut.add(btnExport);
    panneauHaut.add(btnExportPriceCatalog);
    panneauHaut.add(btnGenerateWebSite);
    panneauHaut.add(progressBar);
    add(splitListPanel, BorderLayout.CENTER);
    splitListPanel.setRightComponent(panneauDroite);
    panneauDroite.add(splitPane, BorderLayout.CENTER);
    splitPane.setLeftComponent(scrollPaneCollections);
    scrollPaneCollections.setViewportView(tree);
    splitPane.setRightComponent(tabbedPane);
    scrollPrices.setViewportView(tablePrices);
    splitListPanel.setLeftComponent(panneauGauche);
    panneauGauche.add(scrollPane);
    scrollPane.setViewportView(tableEditions);
    panneauGauche.add(panelTotal, BorderLayout.SOUTH);
    panelTotal.add(lblTotal);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("DETAILS"), null, magicCardDetailPanel, null);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("CARD_EDITIONS"), null, magicEditionDetailPanel, null);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("PRICES"), null, scrollPrices, null);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("CARD_TYPES"), null, typeRepartitionPanel, null);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("CARD_MANA"), null, manaRepartitionPanel, null);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("CARD_RARITY"), null, rarityRepartitionPanel, null);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("STOCK_MODULE"), null, statsPanel, null);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("PRICE_VARIATIONS"), null, historyPricesPanel, null);
    if (MTGControler.getInstance().get("debug-json-panel").equalsIgnoreCase("true"))
        tabbedPane.addTab("Json", null, jsonPanel, null);
    // ///////Labels
    lblTotal.setText("Total : " + model.getCountDefaultLibrary() + "/" + model.getCountTotal());
    btnAdd.setToolTipText(MTGControler.getInstance().getLangService().get("COLLECTION_ADD"));
    btnRefresh.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("COLLECTION_REFRESH"));
    btnRemove.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("ITEM_SELECTED_REMOVE"));
    btnAddAllSet.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("COLLECTION_SET_FULL"));
    btnExport.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("EXPORT_AS"));
    btnMassCollection.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("COLLECTION_IMPORT"));
    btnExportPriceCatalog.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("COLLECTION_EXPORT_PRICES"));
    btnGenerateWebSite.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("GENERATE_WEBSITE"));
    List<SortKey> keys = new ArrayList<>();
    // column index 2
    SortKey sortKey = new SortKey(3, SortOrder.DESCENDING);
    keys.add(sortKey);
    sorterEditions.setSortKeys(keys);
    tableEditions.packAll();
    initPopupCollection();
    tableEditions.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            int row = tableEditions.getSelectedRow();
            MagicEdition ed = (MagicEdition) tableEditions.getValueAt(row, 1);
            magicEditionDetailPanel.setMagicEdition(ed);
            historyPricesPanel.init(null, ed, ed.getSet());
            jsonPanel.show(ed);
        }
    });
    btnAdd.addActionListener(e -> {
        String name = JOptionPane.showInputDialog(MTGControler.getInstance().getLangService().getCapitalize("NAME") + " ?");
        MagicCollection collectionAdd = new MagicCollection();
        collectionAdd.setName(name);
        try {
            dao.saveCollection(collectionAdd);
            ((LazyLoadingTree.MyNode) getJTree().getModel().getRoot()).add(new DefaultMutableTreeNode(collectionAdd));
            getJTree().refresh();
            initPopupCollection();
        } catch (Exception ex) {
            logger.error(ex);
            JOptionPane.showMessageDialog(null, ex, MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
        }
    });
    btnRefresh.addActionListener(e -> ThreadManager.getInstance().execute(() -> {
        progressBar.setVisible(true);
        tree.refresh();
        try {
            model.calculate();
            lblTotal.setText("Total : " + model.getCountDefaultLibrary() + "/" + model.getCountTotal());
        } catch (Exception ex) {
            logger.error(ex);
        }
        model.fireTableDataChanged();
        progressBar.setVisible(false);
    }, "update Tree"));
    btnExport.addActionListener(ae -> {
        JPopupMenu menu = new JPopupMenu();
        for (final MTGCardsExport exp : MTGControler.getInstance().getEnabledDeckExports()) {
            JMenuItem it = new JMenuItem();
            it.setIcon(exp.getIcon());
            it.setText(exp.getName());
            it.addActionListener(arg0 -> ThreadManager.getInstance().execute(() -> {
                try {
                    DefaultMutableTreeNode curr = (DefaultMutableTreeNode) path.getLastPathComponent();
                    JFileChooser jf = new JFileChooser();
                    MagicCollection mc = null;
                    MagicEdition ed = null;
                    if (curr.getUserObject() instanceof MagicEdition) {
                        ed = (MagicEdition) curr.getUserObject();
                        mc = (MagicCollection) ((DefaultMutableTreeNode) curr.getParent()).getUserObject();
                    } else {
                        mc = (MagicCollection) curr.getUserObject();
                    }
                    jf.setSelectedFile(new File(mc.getName() + exp.getFileExtension()));
                    int result = jf.showSaveDialog(null);
                    File f = jf.getSelectedFile();
                    exp.addObserver((Observable o, Object arg) -> progressBar.setValue((int) arg));
                    if (result == JFileChooser.APPROVE_OPTION) {
                        progressBar.setVisible(true);
                        if (ed == null)
                            exp.export(dao.listCardsFromCollection(mc), f);
                        else
                            exp.export(dao.listCardsFromCollection(mc, ed), f);
                        progressBar.setVisible(false);
                        JOptionPane.showMessageDialog(null, MTGControler.getInstance().getLangService().combine("EXPORT", "FINISHED"), MTGControler.getInstance().getLangService().getCapitalize("FINISHED"), JOptionPane.INFORMATION_MESSAGE);
                    }
                } catch (Exception e) {
                    logger.error(e);
                    progressBar.setVisible(false);
                    JOptionPane.showMessageDialog(null, e, MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
                }
            }, "export collection with " + exp));
            menu.add(it);
        }
        Component b = (Component) ae.getSource();
        Point p = b.getLocationOnScreen();
        menu.show(b, 0, 0);
        menu.setLocation(p.x, p.y + b.getHeight());
    });
    splitPane.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentShown(ComponentEvent componentEvent) {
            splitPane.setDividerLocation(.5);
            removeComponentListener(this);
        }
    });
    tablePrices.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            if (ev.getClickCount() == 2 && !ev.isConsumed()) {
                ev.consume();
                try {
                    String url = tablePrices.getValueAt(tablePrices.getSelectedRow(), CardsPriceTableModel.ROW_URL).toString();
                    Desktop.getDesktop().browse(new URI(url));
                } catch (Exception e) {
                    logger.error(e);
                }
            }
        }
    });
    tree.addTreeSelectionListener(tse -> {
        path = tse.getPath();
        final DefaultMutableTreeNode curr = (DefaultMutableTreeNode) path.getLastPathComponent();
        if (curr.getUserObject() instanceof String) {
            btnExport.setEnabled(false);
            btnExportPriceCatalog.setEnabled(false);
            statsPanel.enabledAdd(false);
        }
        if (curr.getUserObject() instanceof MagicCollection) {
            btnExport.setEnabled(true);
            btnExportPriceCatalog.setEnabled(true);
            selectedcol = (MagicCollection) curr.getUserObject();
            statsPanel.enabledAdd(false);
            btnExport.setEnabled(true);
            btnExportPriceCatalog.setEnabled(true);
        }
        if (curr.getUserObject() instanceof MagicEdition) {
            magicEditionDetailPanel.setMagicEdition((MagicEdition) curr.getUserObject());
            btnExport.setEnabled(true);
            btnExportPriceCatalog.setEnabled(false);
            statsPanel.enabledAdd(false);
            ThreadManager.getInstance().execute(() -> {
                try {
                    MagicCollection collec = (MagicCollection) ((DefaultMutableTreeNode) curr.getParent()).getUserObject();
                    List<MagicCard> list = dao.listCardsFromCollection(collec, (MagicEdition) curr.getUserObject());
                    rarityRepartitionPanel.init(list);
                    typeRepartitionPanel.init(list);
                    manaRepartitionPanel.init(list);
                    historyPricesPanel.init(null, (MagicEdition) curr.getUserObject(), curr.getUserObject().toString());
                    jsonPanel.show(curr.getUserObject());
                } catch (Exception e) {
                    logger.error(e);
                }
            }, "Refresh Collection");
        }
        if (curr.getUserObject() instanceof MagicCard) {
            final MagicCard card = (MagicCard) ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
            btnExport.setEnabled(false);
            btnExportPriceCatalog.setEnabled(false);
            magicCardDetailPanel.setMagicCard((MagicCard) curr.getUserObject());
            magicEditionDetailPanel.setMagicEdition(card.getEditions().get(0));
            magicCardDetailPanel.enableThumbnail(true);
            jsonPanel.show(curr.getUserObject());
            ThreadManager.getInstance().execute(() -> {
                statsPanel.initMagicCardStock(card, (MagicCollection) ((DefaultMutableTreeNode) curr.getParent().getParent()).getUserObject());
                statsPanel.enabledAdd(true);
            }, "Update Collection");
            if (tabbedPane.getSelectedIndex() == 2) {
                loadPrices(card);
            }
            ThreadManager.getInstance().execute(() -> {
                try {
                    historyPricesPanel.init(card, null, card.getName());
                } catch (Exception e) {
                    logger.error(e);
                }
            }, "update history");
        }
    });
    tabbedPane.addChangeListener(e -> {
        if ((tabbedPane.getSelectedIndex() == 2) && ((DefaultMutableTreeNode) tree.getLastSelectedPathComponent()).getUserObject() instanceof MagicCard)
            loadPrices((MagicCard) ((DefaultMutableTreeNode) tree.getLastSelectedPathComponent()).getUserObject());
    });
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                int row = tree.getClosestRowForLocation(e.getX(), e.getY());
                tree.setSelectionRow(row);
                final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
                if (node.getUserObject() instanceof MagicEdition) {
                    popupMenuEdition.show(e.getComponent(), e.getX(), e.getY());
                }
                if (node.getUserObject() instanceof MagicCard) {
                    popupMenuCards.show(e.getComponent(), e.getX(), e.getY());
                }
                if (node.getUserObject() instanceof MagicCollection) {
                    JPopupMenu p = new JPopupMenu();
                    JMenuItem it = new JMenuItem("Mass movement");
                    p.add(it);
                    it.addActionListener(ae -> {
                        MassMoverDialog d = new MassMoverDialog((MagicCollection) node.getUserObject(), null);
                        d.setVisible(true);
                        logger.debug("closing mass import with change =" + d.hasChange());
                    });
                    p.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }
    });
    btnMassCollection.addActionListener(ae -> {
        MassCollectionImporterDialog diag = new MassCollectionImporterDialog();
        diag.setVisible(true);
        try {
            model.calculate();
        } catch (Exception e) {
            logger.error(e);
        }
        model.fireTableDataChanged();
    });
    btnExportPriceCatalog.addActionListener(ae -> ThreadManager.getInstance().execute(() -> {
        try {
            PriceCatalogExportDialog diag = new PriceCatalogExportDialog(selectedcol);
            diag.setVisible(true);
            if (diag.value()) {
                progressBar.setVisible(true);
                progressBar.setStringPainted(true);
                progressBar.setMinimum(0);
                progressBar.setMaximum(dao.getCardsCount(selectedcol, null));
                CSVExport exp = new CSVExport();
                exp.addObserver((Observable o, Object arg) -> progressBar.setValue((int) arg));
                exp.exportPriceCatalog(dao.listCardsFromCollection(selectedcol), diag.getDest(), diag.getPriceProviders());
                JOptionPane.showMessageDialog(null, MTGControler.getInstance().getLangService().combine("EXPORT", "FINISHED"));
                progressBar.setVisible(false);
            }
        } catch (Exception e) {
            logger.error(e);
        }
    }, "btnExportPriceCatalog export Prices"));
    btnGenerateWebSite.addActionListener(ae -> ThreadManager.getInstance().execute(() -> {
        try {
            WebSiteGeneratorDialog diag = new WebSiteGeneratorDialog(dao.getCollections());
            diag.setVisible(true);
            if (diag.value()) {
                progressBar.setVisible(true);
                progressBar.setStringPainted(true);
                progressBar.setMinimum(0);
                int max = 0;
                for (MagicCollection col : diag.getSelectedCollections()) max += dao.getCardsCount(col, null);
                progressBar.setMaximum(max);
                progressBar.setValue(0);
                MagicWebSiteGenerator gen = new MagicWebSiteGenerator(diag.getTemplate(), diag.getDest().getAbsolutePath());
                gen.addObserver((Observable o, Object arg) -> progressBar.setValue((int) arg));
                gen.generate(diag.getSelectedCollections(), diag.getPriceProviders());
                int res = JOptionPane.showConfirmDialog(null, MTGControler.getInstance().getLangService().getCapitalize("WEBSITE_CONFIRMATION_VIEW"));
                if (res == JOptionPane.YES_OPTION) {
                    Path p = Paths.get(diag.getDest().getAbsolutePath() + "/index.htm");
                    Desktop.getDesktop().browse(p.toUri());
                }
                progressBar.setVisible(false);
            }
        } catch (Exception e) {
            logger.error("error generating website", e);
            progressBar.setVisible(false);
            JOptionPane.showMessageDialog(null, e, MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
        }
    }, "btnGenerateWebSite generate website"));
    btnAddAllSet.addActionListener(evt -> {
        MagicEdition ed = (MagicEdition) tableEditions.getValueAt(tableEditions.getSelectedRow(), 1);
        int res = JOptionPane.showConfirmDialog(null, MTGControler.getInstance().getLangService().getCapitalize("CONFIRM_COLLECTION_ITEM_ADDITION", ed, MTGControler.getInstance().get("default-library")));
        if (res == JOptionPane.YES_OPTION)
            try {
                List<MagicCard> list = provider.searchCardByCriteria("set", ed.getId(), null, false);
                logger.debug("save " + list.size() + " cards from " + ed.getId());
                for (MagicCard mc : list) {
                    MagicCollection col = new MagicCollection();
                    col.setName(MTGControler.getInstance().get("default-library"));
                    dao.saveCard(mc, col);
                }
                model.calculate();
                model.fireTableDataChanged();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e.getMessage(), MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
                logger.error(e);
            }
    });
    btnRemove.addActionListener(evt -> {
        MagicCollection col = (MagicCollection) ((DefaultMutableTreeNode) path.getPathComponent(1)).getUserObject();
        int res = 0;
        DefaultMutableTreeNode curr = (DefaultMutableTreeNode) path.getLastPathComponent();
        if (curr.getUserObject() instanceof MagicCard) {
            MagicCard card = (MagicCard) ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
            try {
                res = JOptionPane.showConfirmDialog(null, MTGControler.getInstance().getLangService().getCapitalize("CONFIRM_COLLECTION_ITEM_DELETE", card, col));
                if (res == JOptionPane.YES_OPTION) {
                    dao.removeCard(card, col);
                    curr.removeFromParent();
                }
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(null, e.getMessage(), MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
            }
        }
        if (curr.getUserObject() instanceof MagicEdition) {
            MagicEdition me = (MagicEdition) ((DefaultMutableTreeNode) path.getPathComponent(2)).getUserObject();
            try {
                res = JOptionPane.showConfirmDialog(null, MTGControler.getInstance().getLangService().getCapitalize("CONFIRM_COLLECTION_ITEM_DELETE", me, col));
                if (res == JOptionPane.YES_OPTION) {
                    dao.removeEdition(me, col);
                    curr.removeFromParent();
                }
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(null, e.getMessage(), MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
            }
        }
        if (curr.getUserObject() instanceof MagicCollection) {
            try {
                res = JOptionPane.showConfirmDialog(null, MTGControler.getInstance().getLangService().getCapitalize("CONFIRM_COLLECTION_DELETE", col, dao.getCardsCount(col, null)));
                if (res == JOptionPane.YES_OPTION) {
                    dao.removeCollection(col);
                    curr.removeFromParent();
                }
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(null, e.getMessage(), MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
            }
        }
        if (res == JOptionPane.YES_OPTION) {
            try {
                model.calculate();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e.getMessage(), MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
            }
            tree.refresh();
        }
    });
}
Also used : MagicCollection(org.magic.api.beans.MagicCollection) Point(java.awt.Point) MTGDao(org.magic.api.interfaces.MTGDao) RarityRepartitionPanel(org.magic.gui.components.charts.RarityRepartitionPanel) Logger(org.apache.log4j.Logger) TableFilterHeader(net.coderazzi.filters.gui.TableFilterHeader) MouseAdapter(java.awt.event.MouseAdapter) URI(java.net.URI) JFileChooser(javax.swing.JFileChooser) PriceCatalogExportDialog(org.magic.gui.components.dialog.PriceCatalogExportDialog) WebSiteGeneratorDialog(org.magic.gui.components.dialog.WebSiteGeneratorDialog) BorderLayout(java.awt.BorderLayout) Path(java.nio.file.Path) CSVExport(org.magic.api.exports.impl.CSVExport) MTGCardsProvider(org.magic.api.interfaces.MTGCardsProvider) TypeRepartitionPanel(org.magic.gui.components.charts.TypeRepartitionPanel) DefaultTableModel(javax.swing.table.DefaultTableModel) TreePath(javax.swing.tree.TreePath) MagicCardsTreeCellRenderer(org.magic.gui.renderer.MagicCardsTreeCellRenderer) JMenu(javax.swing.JMenu) ComponentEvent(java.awt.event.ComponentEvent) Component(java.awt.Component) TableRowSorter(javax.swing.table.TableRowSorter) JXTable(org.jdesktop.swingx.JXTable) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CardsPriceTableModel(org.magic.gui.models.CardsPriceTableModel) HistoryPricesPanel(org.magic.gui.components.charts.HistoryPricesPanel) Dimension(java.awt.Dimension) List(java.util.List) MagicEdition(org.magic.api.beans.MagicEdition) MagicCard(org.magic.api.beans.MagicCard) MagicCardDetailPanel(org.magic.gui.components.MagicCardDetailPanel) JPanel(javax.swing.JPanel) DefaultRowSorter(javax.swing.DefaultRowSorter) JSplitPane(javax.swing.JSplitPane) MassCollectionImporterDialog(org.magic.gui.components.dialog.MassCollectionImporterDialog) Observable(org.utils.patterns.observer.Observable) MTGControler(org.magic.services.MTGControler) SortKey(javax.swing.RowSorter.SortKey) CardStockPanel(org.magic.gui.components.CardStockPanel) MagicEditionDetailPanel(org.magic.gui.components.MagicEditionDetailPanel) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) SwingUtilities(javax.swing.SwingUtilities) JMenuItem(javax.swing.JMenuItem) JTabbedPane(javax.swing.JTabbedPane) JProgressBar(javax.swing.JProgressBar) JSONPanel(org.magic.gui.components.JSONPanel) MagicCollectionTableCellRenderer(org.magic.gui.renderer.MagicCollectionTableCellRenderer) ManaRepartitionPanel(org.magic.gui.components.charts.ManaRepartitionPanel) Desktop(java.awt.Desktop) LazyLoadingTree(org.magic.gui.components.LazyLoadingTree) MTGLogger(org.magic.services.MTGLogger) JButton(javax.swing.JButton) JPopupMenu(javax.swing.JPopupMenu) MTGCardsExport(org.magic.api.interfaces.MTGCardsExport) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) CardSearchPanel(org.magic.gui.components.CardSearchPanel) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) ComponentAdapter(java.awt.event.ComponentAdapter) JScrollPane(javax.swing.JScrollPane) SortOrder(javax.swing.SortOrder) MagicWebSiteGenerator(org.magic.services.MagicWebSiteGenerator) Paths(java.nio.file.Paths) JLabel(javax.swing.JLabel) ThreadManager(org.magic.services.ThreadManager) AutoChoices(net.coderazzi.filters.gui.AutoChoices) MagicEditionsTableModel(org.magic.gui.models.MagicEditionsTableModel) MassMoverDialog(org.magic.gui.components.dialog.MassMoverDialog) MTGConstants(org.magic.services.MTGConstants) JPanel(javax.swing.JPanel) ArrayList(java.util.ArrayList) MagicEdition(org.magic.api.beans.MagicEdition) CardsPriceTableModel(org.magic.gui.models.CardsPriceTableModel) WebSiteGeneratorDialog(org.magic.gui.components.dialog.WebSiteGeneratorDialog) MassMoverDialog(org.magic.gui.components.dialog.MassMoverDialog) BorderLayout(java.awt.BorderLayout) CardStockPanel(org.magic.gui.components.CardStockPanel) PriceCatalogExportDialog(org.magic.gui.components.dialog.PriceCatalogExportDialog) List(java.util.List) ArrayList(java.util.ArrayList) MagicCollection(org.magic.api.beans.MagicCollection) MassCollectionImporterDialog(org.magic.gui.components.dialog.MassCollectionImporterDialog) JXTable(org.jdesktop.swingx.JXTable) MagicCardDetailPanel(org.magic.gui.components.MagicCardDetailPanel) ManaRepartitionPanel(org.magic.gui.components.charts.ManaRepartitionPanel) JFileChooser(javax.swing.JFileChooser) ComponentEvent(java.awt.event.ComponentEvent) JSplitPane(javax.swing.JSplitPane) File(java.io.File) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SQLException(java.sql.SQLException) JTabbedPane(javax.swing.JTabbedPane) MTGCardsExport(org.magic.api.interfaces.MTGCardsExport) JProgressBar(javax.swing.JProgressBar) JButton(javax.swing.JButton) MagicEditionDetailPanel(org.magic.gui.components.MagicEditionDetailPanel) SortKey(javax.swing.RowSorter.SortKey) URI(java.net.URI) HistoryPricesPanel(org.magic.gui.components.charts.HistoryPricesPanel) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) TableRowSorter(javax.swing.table.TableRowSorter) ComponentAdapter(java.awt.event.ComponentAdapter) JScrollPane(javax.swing.JScrollPane) Path(java.nio.file.Path) TreePath(javax.swing.tree.TreePath) MouseEvent(java.awt.event.MouseEvent) MagicCollectionTableCellRenderer(org.magic.gui.renderer.MagicCollectionTableCellRenderer) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) RarityRepartitionPanel(org.magic.gui.components.charts.RarityRepartitionPanel) LazyLoadingTree(org.magic.gui.components.LazyLoadingTree) DefaultRowSorter(javax.swing.DefaultRowSorter) CSVExport(org.magic.api.exports.impl.CSVExport) TableFilterHeader(net.coderazzi.filters.gui.TableFilterHeader) Dimension(java.awt.Dimension) MagicCardsTreeCellRenderer(org.magic.gui.renderer.MagicCardsTreeCellRenderer) Point(java.awt.Point) MagicEditionsTableModel(org.magic.gui.models.MagicEditionsTableModel) TypeRepartitionPanel(org.magic.gui.components.charts.TypeRepartitionPanel) SQLException(java.sql.SQLException) IOException(java.io.IOException) JPopupMenu(javax.swing.JPopupMenu) Observable(org.utils.patterns.observer.Observable) Point(java.awt.Point) MagicCard(org.magic.api.beans.MagicCard) MagicWebSiteGenerator(org.magic.services.MagicWebSiteGenerator) JSONPanel(org.magic.gui.components.JSONPanel)

Example 27 with JProgressBar

use of javax.swing.JProgressBar in project MtgDesktopCompanion by nicho92.

the class MassCollectionImporterDialog method initGUI.

private void initGUI() throws SQLException {
    getContentPane().setLayout(new BorderLayout(0, 0));
    deck = new MagicDeck();
    JPanel panelCollectionInput = new JPanel();
    getContentPane().add(panelCollectionInput, BorderLayout.NORTH);
    JLabel lblImport = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("IMPORT") + " ");
    panelCollectionInput.add(lblImport);
    List<MagicEdition> list = new ArrayList<>();
    try {
        list = MTGControler.getInstance().getEnabledProviders().loadEditions();
    } catch (IOException e2) {
        MTGLogger.printStackTrace(e2);
    }
    final JComboBox cboEditions = new JComboBox(list.toArray());
    cboEditions.setRenderer(new MagicEditionListRenderer());
    panelCollectionInput.add(cboEditions);
    List<MagicCollection> lc = MTGControler.getInstance().getEnabledDAO().getCollections();
    JLabel lblNewLabel = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("BY"));
    panelCollectionInput.add(lblNewLabel);
    final JComboBox<String> cboByType = new JComboBox<>();
    cboByType.setModel(new DefaultComboBoxModel<String>(new String[] { "number", "name" }));
    panelCollectionInput.add(cboByType);
    JLabel lblIn = new JLabel("in");
    panelCollectionInput.add(lblIn);
    final JComboBox cboCollections = new JComboBox(lc.toArray());
    panelCollectionInput.add(cboCollections);
    JPanel panneauBas = new JPanel();
    getContentPane().add(panneauBas, BorderLayout.SOUTH);
    final JProgressBar progressBar = new JProgressBar();
    progressBar.setStringPainted(true);
    final JCheckBox checkNewOne = new JCheckBox(MTGControler.getInstance().getLangService().getCapitalize("IMPORT_OTHER_SERIE"));
    JButton btnInverse = new JButton("Inverse");
    btnInverse.addActionListener(e -> {
        MagicEdition ed = (MagicEdition) cboEditions.getSelectedItem();
        int max = ed.getCardCount();
        List<String> elements = Arrays.asList(txtNumbersInput.getText().replaceAll("\n", " ").replaceAll("  ", " ").trim().split(" "));
        List<String> edList = new ArrayList<>();
        for (int i = 1; i <= max; i++) edList.add(String.valueOf(i));
        edList.removeAll(elements);
        StringBuilder temp = new StringBuilder();
        for (String s : edList) temp.append(s).append(" ");
        txtNumbersInput.setText(temp.toString());
    });
    panneauBas.add(btnInverse);
    panneauBas.add(checkNewOne);
    JButton btnImport = new JButton(MTGControler.getInstance().getLangService().getCapitalize("IMPORT"));
    btnImport.addActionListener(e -> {
        final MagicEdition ed = (MagicEdition) cboEditions.getSelectedItem();
        final MagicCollection col = (MagicCollection) cboCollections.getSelectedItem();
        if (cboByType.getSelectedItem().equals("number"))
            ids = txtNumbersInput.getText().replaceAll("\n", " ").replaceAll("  ", " ").trim().split(" ");
        else
            ids = txtNumbersInput.getText().split("\n");
        progressBar.setMaximum(ids.length);
        ThreadManager.getInstance().execute(() -> {
            int i = 1;
            for (String id : ids) {
                try {
                    MagicCard mc = null;
                    if (cboByType.getSelectedItem().toString().equalsIgnoreCase("number"))
                        mc = MTGControler.getInstance().getEnabledProviders().getCardByNumber(id, ed);
                    else
                        mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", id.replaceAll("\n", " ").replaceAll("  ", " ").trim(), (MagicEdition) cboEditions.getSelectedItem(), true).get(0);
                    deck.add(mc);
                    MTGControler.getInstance().getEnabledDAO().saveCard(mc, col);
                    progressBar.setValue(i++);
                } catch (Exception e1) {
                    MTGLogger.printStackTrace(e1);
                }
            }
            JOptionPane.showMessageDialog(null, MTGControler.getInstance().getLangService().getCapitalize("X_ITEMS_IMPORTED", ids.length), MTGControler.getInstance().getLangService().getCapitalize("FINISHED"), JOptionPane.INFORMATION_MESSAGE);
            if (!checkNewOne.isSelected()) {
                setVisible(false);
                progressBar.setValue(0);
            }
        }, "btnImport importCards");
    });
    panneauBas.add(btnImport);
    panneauBas.add(progressBar);
    txtNumbersInput = new JTextPane();
    JScrollPane scrollPane = new JScrollPane();
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    scrollPane.setViewportView(txtNumbersInput);
    setModal(true);
    setLocationRelativeTo(null);
}
Also used : JPanel(javax.swing.JPanel) MagicEdition(org.magic.api.beans.MagicEdition) ArrayList(java.util.ArrayList) JProgressBar(javax.swing.JProgressBar) JButton(javax.swing.JButton) JTextPane(javax.swing.JTextPane) BorderLayout(java.awt.BorderLayout) MagicCollection(org.magic.api.beans.MagicCollection) MagicDeck(org.magic.api.beans.MagicDeck) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) IOException(java.io.IOException) SQLException(java.sql.SQLException) IOException(java.io.IOException) JCheckBox(javax.swing.JCheckBox) MagicCard(org.magic.api.beans.MagicCard) MagicEditionListRenderer(org.magic.gui.renderer.MagicEditionListRenderer)

Example 28 with JProgressBar

use of javax.swing.JProgressBar in project gate-core by GateNLP.

the class MainFrame method initGuiComponents.

protected void initGuiComponents() {
    this.getContentPane().setLayout(new BorderLayout());
    Integer width = Gate.getUserConfig().getInt(GateConstants.MAIN_FRAME_WIDTH, 1024);
    Integer height = Gate.getUserConfig().getInt(GateConstants.MAIN_FRAME_HEIGHT, 768);
    Rectangle maxDimensions = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
    this.setSize(new Dimension(Math.min(width, maxDimensions.width), Math.min(height, maxDimensions.height)));
    if (Gate.getUserConfig().getBoolean(GateConstants.MAIN_FRAME_MAXIMIZED))
        setExtendedState(JFrame.MAXIMIZED_BOTH);
    setIconImages(Arrays.asList(new Image[] { new GATEVersionIcon(256, 256).getImage(), new GATEVersionIcon(128, 128).getImage(), new GATEVersionIcon(64, 64).getImage(), new GATEVersionIcon(48, 48).getImage(), new GATEVersionIcon(32, 32).getImage(), new GATEIcon(22, 22).getImage(), new GATEIcon(16, 16).getImage() }));
    resourcesTree = new ResourcesTree();
    resourcesTree.setModel(resourcesTreeModel);
    resourcesTree.setRowHeight(0);
    resourcesTree.setEditable(true);
    ResourcesTreeCellRenderer treeCellRenderer = new ResourcesTreeCellRenderer();
    resourcesTree.setCellRenderer(treeCellRenderer);
    resourcesTree.setCellEditor(new ResourcesTreeCellEditor(resourcesTree, treeCellRenderer));
    resourcesTree.setInvokesStopCellEditing(true);
    resourcesTree.setRowHeight(0);
    // expand all nodes
    resourcesTree.expandRow(0);
    resourcesTree.expandRow(1);
    resourcesTree.expandRow(2);
    resourcesTree.expandRow(3);
    resourcesTree.expandRow(4);
    resourcesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    resourcesTree.setEnabled(true);
    ToolTipManager.sharedInstance().registerComponent(resourcesTree);
    resourcesTreeScroll = new JScrollPane(resourcesTree);
    resourcesTree.setDragEnabled(true);
    resourcesTree.setTransferHandler(new TransferHandler() {

        // drag and drop that export a list of the selected documents
        @Override
        public int getSourceActions(JComponent c) {
            return COPY;
        }

        @Override
        protected Transferable createTransferable(JComponent c) {
            TreePath[] paths = resourcesTree.getSelectionPaths();
            if (paths == null) {
                return new StringSelection("");
            }
            Handle handle;
            List<String> documentsNames = new ArrayList<String>();
            for (TreePath path : paths) {
                if (path != null) {
                    Object value = path.getLastPathComponent();
                    value = ((DefaultMutableTreeNode) value).getUserObject();
                    if (value instanceof Handle) {
                        handle = (Handle) value;
                        if (handle.getTarget() instanceof Document) {
                            documentsNames.add(((Document) handle.getTarget()).getName());
                        }
                    }
                }
            }
            return new StringSelection("ResourcesTree" + Arrays.toString(documentsNames.toArray()));
        }

        @Override
        protected void exportDone(JComponent c, Transferable data, int action) {
        }

        @Override
        public boolean canImport(JComponent c, DataFlavor[] flavors) {
            return false;
        }

        @Override
        public boolean importData(JComponent c, Transferable t) {
            return false;
        }
    });
    lowerScroll = new JScrollPane();
    JPanel lowerPane = new JPanel();
    lowerPane.setLayout(new OverlayLayout(lowerPane));
    JPanel animationPane = new JPanel();
    animationPane.setOpaque(false);
    animationPane.setLayout(new BoxLayout(animationPane, BoxLayout.X_AXIS));
    JPanel vBox = new JPanel();
    vBox.setLayout(new BoxLayout(vBox, BoxLayout.Y_AXIS));
    vBox.setOpaque(false);
    JPanel hBox = new JPanel();
    hBox.setLayout(new BoxLayout(hBox, BoxLayout.X_AXIS));
    hBox.setOpaque(false);
    vBox.add(Box.createVerticalGlue());
    vBox.add(animationPane);
    hBox.add(vBox);
    hBox.add(Box.createHorizontalGlue());
    lowerPane.add(hBox);
    lowerPane.add(lowerScroll);
    animator = new CartoonMinder(animationPane);
    Thread thread = new Thread(Thread.currentThread().getThreadGroup(), animator, "MainFrame animation");
    thread.setDaemon(true);
    thread.setPriority(Thread.MIN_PRIORITY);
    thread.start();
    leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, resourcesTreeScroll, lowerPane);
    leftSplit.setResizeWeight(0.7);
    leftSplit.setContinuousLayout(true);
    leftSplit.setOneTouchExpandable(true);
    // Create a new logArea and redirect the Out and Err output to it.
    logArea = new LogArea();
    // Out has been redirected to the logArea
    Out.prln("GATE " + Main.version + " build " + Main.build + " started at " + new Date().toString());
    Out.prln("and using Java " + System.getProperty("java.version") + " " + System.getProperty("java.vendor") + " on " + System.getProperty("os.name") + " " + System.getProperty("os.arch") + " " + System.getProperty("os.version") + ".");
    mainTabbedPane = new XJTabbedPane(JTabbedPane.TOP);
    mainTabbedPane.insertTab("Messages", null, logArea.getComponentToDisplay(), "GATE log", 0);
    logHighlighter = new TabHighlighter(mainTabbedPane, logArea.getComponentToDisplay(), Color.red);
    mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, mainTabbedPane);
    mainSplit.setDividerLocation(leftSplit.getPreferredSize().width + 10);
    this.getContentPane().add(mainSplit, BorderLayout.CENTER);
    mainSplit.setContinuousLayout(true);
    mainSplit.setOneTouchExpandable(true);
    // status and progress bars
    statusBar = new JLabel("Welcome to GATE!");
    statusBar.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    UIManager.put("ProgressBar.cellSpacing", 0);
    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorder(BorderFactory.createEmptyBorder());
    progressBar.setForeground(new Color(150, 75, 150));
    progressBar.setStringPainted(false);
    globalProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    globalProgressBar.setBorder(BorderFactory.createEmptyBorder());
    globalProgressBar.setForeground(new Color(150, 75, 150));
    globalProgressBar.setStringPainted(true);
    JPanel southBox = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    southBox.add(statusBar, gbc);
    gbc.insets = new Insets(0, 3, 0, 3);
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 0;
    southBox.add(progressBar, gbc);
    southBox.add(globalProgressBar, gbc);
    this.getContentPane().add(southBox, BorderLayout.SOUTH);
    progressBar.setVisible(false);
    globalProgressBar.setVisible(false);
    // extra stuff
    newResourceDialog = new NewResourceDialog(this, "Resource parameters", true);
    // build the Help->About dialog
    JPanel splashBox = new JPanel();
    splashBox.setBackground(Color.WHITE);
    splashBox.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.weightx = 1;
    constraints.insets = new Insets(2, 2, 2, 2);
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.BOTH;
    JLabel gifLbl = new JLabel(getIcon("splash"));
    splashBox.add(gifLbl, constraints);
    constraints.gridy = 2;
    constraints.gridwidth = 2;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    String splashHtml;
    try {
        splashHtml = Files.getGateResourceAsString("splash.html");
    } catch (IOException e) {
        splashHtml = "GATE";
        log.error("Couldn't get splash.html resource.", e);
    }
    JLabel htmlLbl = new JLabel(splashHtml);
    htmlLbl.setHorizontalAlignment(SwingConstants.CENTER);
    splashBox.add(htmlLbl, constraints);
    constraints.gridy = 3;
    htmlLbl = new JLabel("<HTML><FONT color=\"blue\">Version <B>" + Main.version + "</B></FONT>" + ", <FONT color=\"red\">build <B>" + Main.build + "</B></FONT>" + "<P><B>JVM version</B>: " + System.getProperty("java.version") + " from " + System.getProperty("java.vendor") + "</HTML>");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    splashBox.add(htmlLbl, constraints);
    constraints.gridy = 4;
    constraints.gridwidth = 2;
    constraints.fill = GridBagConstraints.NONE;
    final JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            splash.setVisible(false);
        }
    });
    okButton.setBackground(Color.white);
    splashBox.add(okButton, constraints);
    splash = new Splash(this, splashBox);
    // make Enter and Escape keys closing the splash window
    splash.getRootPane().setDefaultButton(okButton);
    InputMap inputMap = ((JComponent) splash.getContentPane()).getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = ((JComponent) splash.getContentPane()).getActionMap();
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "Apply");
    actionMap.put("Apply", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            okButton.doClick();
        }
    });
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "Cancel");
    actionMap.put("Cancel", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            okButton.doClick();
        }
    });
    // MENUS
    menuBar = new JMenuBar();
    JMenu fileMenu = new XJMenu("File", null, this);
    fileMenu.setMnemonic(KeyEvent.VK_F);
    LiveMenu newAPPMenu = new LiveMenu(LiveMenu.APP);
    newAPPMenu.setText("New Application");
    newAPPMenu.setIcon(getIcon("applications"));
    fileMenu.add(newAPPMenu);
    LiveMenu newLRMenu = new LiveMenu(LiveMenu.LR);
    newLRMenu.setText("New Language Resource");
    newLRMenu.setIcon(getIcon("lrs"));
    fileMenu.add(newLRMenu);
    LiveMenu newPRMenu = new LiveMenu(LiveMenu.PR);
    newPRMenu.setText("New Processing Resource");
    newPRMenu.setIcon(getIcon("prs"));
    fileMenu.add(newPRMenu);
    final JMenu dsMenu = new XJMenu("Datastores", "Repositories for large data", this);
    dsMenu.setIcon(getIcon("datastores"));
    dsMenu.add(new XJMenuItem(new NewDSAction(), this));
    dsMenu.add(new XJMenuItem(new OpenDSAction(), this));
    fileMenu.add(dsMenu);
    fileMenu.addSeparator();
    fileMenu.add(new ReadyMadeMenu());
    fileMenu.add(new XJMenuItem(new LoadResourceFromFileAction(), this));
    RecentAppsMenu recentAppsMenu = new RecentAppsMenu();
    fileMenu.add(recentAppsMenu);
    /*final JMenu loadANNIEMenu = new XJMenu("Load ANNIE System",
      "Application that adds morphosyntaxic and semantic annotations", this);
    loadANNIEMenu.setIcon(getIcon("annie-application"));
    loadANNIEMenu.add(new XJMenuItem(new LoadANNIEWithDefaultsAction(), this));
    loadANNIEMenu
      .add(new XJMenuItem(new LoadANNIEWithoutDefaultsAction(), this));
    fileMenu.add(loadANNIEMenu);

    // LingPipe action
    fileMenu.add(new XJMenuItem(new LoadApplicationAction(
            "Load LingPipe System", "LingPipe", "resources/lingpipe.gapp"),
            this));

    // OpenNLP action
    fileMenu.add(new XJMenuItem(new LoadApplicationAction(
            "Load OpenNLP System", "OpenNLP", "resources/opennlp.gapp"), this));
*/
    fileMenu.add(new XJMenuItem(new ManagePluginsAction(), this));
    if (!Gate.runningOnMac()) {
        fileMenu.addSeparator();
        fileMenu.add(new XJMenuItem(new ExitGateAction(), this));
    }
    menuBar.add(fileMenu);
    JMenu optionsMenu = new XJMenu("Options", null, this);
    optionsMenu.setMnemonic(KeyEvent.VK_O);
    boolean optionsMenuHasEntries = false;
    optionsDialog = new OptionsDialog(MainFrame.this);
    if (!Gate.runningOnMac()) {
        optionsMenu.add(new XJMenuItem(new AbstractAction("Configuration") {

            private static final long serialVersionUID = 1L;

            {
                putValue(SHORT_DESCRIPTION, "Edit GATE options");
            }

            @Override
            public void actionPerformed(ActionEvent evt) {
                optionsDialog.showDialog();
                optionsDialog.dispose();
            }
        }, this));
        optionsMenuHasEntries = true;
    }
    if (optionsMenuHasEntries) {
        menuBar.add(optionsMenu);
    }
    ToolsMenu toolsMenu = new ToolsMenu("Tools", null, this);
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    toolsMenu.add(new XJMenuItem(new NewAnnotDiffAction(), this));
    try {
        // Check if log4j is present on the classpath, in order to avoid failures
        // in cases when running the GATE GUI in the same JVM with a system which
        // uses SLF4J and the log4j bridge.
        // The log4j-over-slf4j bridge does not include org.apache.log4j.Appender, so
        // if the class is not present we assume the lack of a log4j jar in the classpath
        // and do not populate the menu.
        Class.forName("org.apache.log4j.Appender");
        final JMenuItem reportClearMenuItem = new XJMenuItem(new AbstractAction("Clear Profiling History") {

            {
                putValue(SHORT_DESCRIPTION, "Clear profiling history otherwise the report is cumulative.");
            }

            @Override
            public void actionPerformed(ActionEvent evt) {
                // create a new log file
                File logFile = new File(System.getProperty("java.io.tmpdir"), "gate-benchmark-log.txt");
                logFile.deleteOnExit();
                if (logFile.exists() && !logFile.delete()) {
                    log.info("Error when deleting the file:\n" + logFile.getAbsolutePath());
                }
            }
        }, this);
        JMenu reportMenu = new XJMenu("Profiling Reports", "Generates profiling reports from processing resources", this);
        reportMenu.setIcon(getIcon("gazetteer"));
        reportMenu.add(new XJMenuItem(new AbstractAction("Start Profiling Applications") {

            {
                putValue(SHORT_DESCRIPTION, "Toggles the profiling of processing resources");
            }

            // stores the value held by the benchmarking switch before we started
            // this profiling run.
            boolean benchmarkWasEnabled;

            @Override
            public void actionPerformed(ActionEvent evt) {
                if (getValue(NAME).equals("Start Profiling Applications")) {
                    reportClearMenuItem.setEnabled(false);
                    // store old value of benchmark switch
                    benchmarkWasEnabled = Benchmark.isBenchmarkingEnabled();
                    Benchmark.setBenchmarkingEnabled(true);
                    Layout layout = new PatternLayout("%m%n");
                    File logFile = new File(System.getProperty("java.io.tmpdir"), "gate-benchmark-log.txt");
                    logFile.deleteOnExit();
                    Appender appender;
                    try {
                        appender = new FileAppender(layout, logFile.getAbsolutePath(), true);
                    } catch (IOException e) {
                        e.printStackTrace();
                        return;
                    }
                    appender.setName("gate-benchmark");
                    Benchmark.logger.addAppender(appender);
                    putValue(NAME, "Stop Profiling Applications");
                } else {
                    // reset old value of benchmark switch - i.e. if benchmarking was
                    // disabled before the user selected "start profiling" then we
                    // disable it again now, but if it was already enabled before they
                    // started profiling then we assume it was turned on explicitly and
                    // leave it alone.
                    Benchmark.setBenchmarkingEnabled(benchmarkWasEnabled);
                    Benchmark.logger.removeAppender("gate-benchmark");
                    putValue(NAME, "Start Profiling Applications");
                    reportClearMenuItem.setEnabled(true);
                }
            }
        }, this));
        reportMenu.add(reportClearMenuItem);
        reportMenu.add(new XJMenuItem(new AbstractAction("Help on this tool") {

            @Override
            public void actionPerformed(ActionEvent e) {
                showHelpFrame("chap:profiling", "Profiling Processing Resources");
            }
        }, this));
        reportMenu.addSeparator();
        final JCheckBoxMenuItem reportZeroTimesCheckBox = new JCheckBoxMenuItem();
        reportZeroTimesCheckBox.setAction(new AbstractAction("Report Zero Time Entries") {

            @Override
            public void actionPerformed(ActionEvent evt) {
                Gate.getUserConfig().put(MainFrame.class.getName() + ".reportzerotime", reportZeroTimesCheckBox.isSelected());
            }
        });
        reportZeroTimesCheckBox.setSelected(Gate.getUserConfig().getBoolean(MainFrame.class.getName() + ".reportzerotimes"));
        ButtonGroup group = new ButtonGroup();
        final JRadioButtonMenuItem reportSortExecution = new JRadioButtonMenuItem();
        reportSortExecution.setAction(new AbstractAction("Sort by Execution") {

            @Override
            public void actionPerformed(ActionEvent evt) {
                Gate.getUserConfig().put(MainFrame.class.getName() + ".reportsorttime", false);
            }
        });
        reportSortExecution.setSelected(!Gate.getUserConfig().getBoolean(MainFrame.class.getName() + ".reportsorttime"));
        group.add(reportSortExecution);
        final JRadioButtonMenuItem reportSortTime = new JRadioButtonMenuItem();
        reportSortTime.setAction(new AbstractAction("Sort by Time") {

            @Override
            public void actionPerformed(ActionEvent evt) {
                Gate.getUserConfig().put(MainFrame.class.getName() + ".reportsorttime", true);
            }
        });
        reportSortTime.setSelected(Gate.getUserConfig().getBoolean(MainFrame.class.getName() + ".reportsorttime"));
        group.add(reportSortTime);
        reportMenu.add(new XJMenuItem(new AbstractAction("Report on Processing Resources") {

            {
                putValue(SHORT_DESCRIPTION, "Report time taken by each processing resource");
            }

            @Override
            public void actionPerformed(ActionEvent evt) {
                PRTimeReporter report = new PRTimeReporter();
                report.setBenchmarkFile(new File(System.getProperty("java.io.tmpdir"), "gate-benchmark-log.txt"));
                report.setSuppressZeroTimeEntries(!reportZeroTimesCheckBox.isSelected());
                report.setSortOrder(reportSortTime.isSelected() ? PRTimeReporter.SORT_TIME_TAKEN : PRTimeReporter.SORT_EXEC_ORDER);
                try {
                    report.executeReport();
                } catch (BenchmarkReportException e) {
                    e.printStackTrace();
                    return;
                }
                showHelpFrame("file://" + report.getReportFile(), "processing times report");
            }
        }, this));
        reportMenu.add(reportZeroTimesCheckBox);
        reportMenu.add(reportSortTime);
        reportMenu.add(reportSortExecution);
        reportMenu.addSeparator();
        reportMenu.add(new XJMenuItem(new AbstractAction("Report on Documents Processed") {

            {
                putValue(SHORT_DESCRIPTION, "Report most time consuming documents");
            }

            @Override
            public void actionPerformed(ActionEvent evt) {
                DocTimeReporter report = new DocTimeReporter();
                report.setBenchmarkFile(new File(System.getProperty("java.io.tmpdir"), "gate-benchmark-log.txt"));
                String maxDocs = Gate.getUserConfig().getString(MainFrame.class.getName() + ".reportmaxdocs");
                if (maxDocs != null) {
                    report.setMaxDocumentInReport((maxDocs.equals("All")) ? DocTimeReporter.ALL_DOCS : Integer.parseInt(maxDocs));
                }
                String prRegex = Gate.getUserConfig().getString(MainFrame.class.getName() + ".reportprregex");
                if (prRegex != null) {
                    report.setPRMatchingRegex((prRegex.equals("")) ? DocTimeReporter.MATCH_ALL_PR_REGEX : prRegex);
                }
                try {
                    report.executeReport();
                } catch (BenchmarkReportException e) {
                    e.printStackTrace();
                    return;
                }
                showHelpFrame("file://" + report.getReportFile(), "documents time report");
            }
        }, this));
        String maxDocs = Gate.getUserConfig().getString(MainFrame.class.getName() + ".reportmaxdocs");
        if (maxDocs == null) {
            maxDocs = "10";
        }
        reportMenu.add(new XJMenuItem(new AbstractAction("Set Max Documents (" + maxDocs + ")") {

            @Override
            public void actionPerformed(ActionEvent evt) {
                Object response = JOptionPane.showInputDialog(instance, "Set the maximum of documents to report", "Report options", JOptionPane.QUESTION_MESSAGE, null, new Object[] { "All", "10", "20", "30", "40", "50", "100" }, "10");
                if (response != null) {
                    Gate.getUserConfig().put(MainFrame.class.getName() + ".reportmaxdocs", response);
                    putValue(NAME, "Set Max Documents (" + response + ")");
                }
            }
        }, this));
        String prRegex = Gate.getUserConfig().getString(MainFrame.class.getName() + ".reportprregex");
        if (prRegex == null || prRegex.equals("")) {
            prRegex = "All";
        }
        reportMenu.add(new XJMenuItem(new AbstractAction("Set PR Matching Regex (" + prRegex + ")") {

            @Override
            public void actionPerformed(ActionEvent evt) {
                Object response = JOptionPane.showInputDialog(instance, "Set the processing resource regex filter\n" + "Leave empty to not filter", "Report options", JOptionPane.QUESTION_MESSAGE);
                if (response != null) {
                    Gate.getUserConfig().put(MainFrame.class.getName() + ".reportprregex", response);
                    if (response.equals("")) {
                        response = "All";
                    }
                    putValue(NAME, "Set PR Matching Regex (" + response + ")");
                }
            }
        }, this));
        toolsMenu.add(reportMenu);
    } catch (ClassNotFoundException e) {
        log.warn("log4j.jar not found on the classpath, disabling profiling reports.");
    }
    toolsMenu.add(new XJMenuItem(new NewBootStrapAction(), this));
    final JMenu corpusEvalMenu = new XJMenu("Corpus Benchmark", "Compares processed and human-annotated annotations", this);
    corpusEvalMenu.setIcon(getIcon("corpus-benchmark"));
    toolsMenu.add(corpusEvalMenu);
    corpusEvalMenu.add(new XJMenuItem(new NewCorpusEvalAction(), this));
    corpusEvalMenu.addSeparator();
    corpusEvalMenu.add(new XJMenuItem(new GenerateStoredCorpusEvalAction(), this));
    corpusEvalMenu.addSeparator();
    corpusEvalMenu.add(new XJMenuItem(new StoredMarkedCorpusEvalAction(), this));
    corpusEvalMenu.add(new XJMenuItem(new CleanMarkedCorpusEvalAction(), this));
    corpusEvalMenu.addSeparator();
    verboseModeItem = new JCheckBoxMenuItem(new VerboseModeCorpusEvalToolAction());
    corpusEvalMenu.add(verboseModeItem);
    toolsMenu.staticItemsAdded();
    menuBar.add(toolsMenu);
    JMenu helpMenu = new XJMenu("Help", null, MainFrame.this);
    helpMenu.setMnemonic(KeyEvent.VK_H);
    helpMenu.add(new XJMenuItem(new HelpUserGuideAction(), this));
    helpMenu.add(new XJMenuItem(new HelpUserGuideInContextAction(), this));
    helpMenu.add(new XJMenuItem(new AbstractAction("Keyboard Shortcuts") {

        @Override
        public void actionPerformed(ActionEvent e) {
            showHelpFrame("sec:developer:keyboard", "shortcuts");
        }
    }, this));
    helpMenu.addSeparator();
    helpMenu.add(new XJMenuItem(new AbstractAction("Using GATE Developer") {

        {
            this.putValue(Action.SHORT_DESCRIPTION, "To read first");
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            showHelpFrame("chap:developer", "Using GATE Developer");
        }
    }, this));
    helpMenu.add(new XJMenuItem(new AbstractAction("Demo Movies") {

        {
            this.putValue(Action.SHORT_DESCRIPTION, "Movie tutorials");
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            showHelpFrame("http://gate.ac.uk/demos/developer-videos/", "movies");
        }
    }, this));
    helpMenu.add(new XJMenuItem(new HelpMailingListAction(), this));
    helpMenu.addSeparator();
    JCheckBoxMenuItem toggleToolTipsCheckBoxMenuItem = new JCheckBoxMenuItem(new ToggleToolTipsAction());
    javax.swing.ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
    if (Gate.getUserConfig().getBoolean(MainFrame.class.getName() + ".hidetooltips")) {
        toolTipManager.setEnabled(false);
        toggleToolTipsCheckBoxMenuItem.setSelected(false);
    } else {
        toolTipManager.setEnabled(true);
        toggleToolTipsCheckBoxMenuItem.setSelected(true);
    }
    helpMenu.add(toggleToolTipsCheckBoxMenuItem);
    helpMenu.add(new XJMenuItem(new AbstractAction("What's New") {

        {
            this.putValue(Action.SHORT_DESCRIPTION, "List new features and important changes");
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            showHelpFrame("chap:changes", "changes");
        }
    }, this));
    if (!Gate.runningOnMac()) {
        helpMenu.add(new XJMenuItem(new HelpAboutAction(), this));
    }
    menuBar.add(helpMenu);
    this.setJMenuBar(menuBar);
    // popups
    lrsPopup = new XJPopupMenu();
    LiveMenu lrsMenu = new LiveMenu(LiveMenu.LR);
    lrsMenu.setText("New");
    lrsPopup.add(lrsMenu);
    guiRoots.add(lrsPopup);
    guiRoots.add(lrsMenu);
    prsPopup = new XJPopupMenu();
    LiveMenu prsMenu = new LiveMenu(LiveMenu.PR);
    prsMenu.setText("New");
    prsPopup.add(prsMenu);
    guiRoots.add(prsPopup);
    guiRoots.add(prsMenu);
    dssPopup = new XJPopupMenu();
    dssPopup.add(new NewDSAction());
    dssPopup.add(new OpenDSAction());
    guiRoots.add(dssPopup);
    // TOOLBAR
    toolbar = new JToolBar(JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    JButton button = new JButton(new LoadResourceFromFileAction());
    button.setToolTipText(button.getText());
    button.setText("");
    toolbar.add(button);
    toolbar.addSeparator();
    try {
        JButton annieMenu = new JButton(new LoadApplicationAction("ANNIE", "annie-application", new ResourceReference(new URI("creole://uk.ac.gate.plugins;annie;" + gate.Main.version + "/resources/" + ANNIEConstants.DEFAULT_FILE))));
        annieMenu.setText("");
        annieMenu.setToolTipText("Load ANNIE");
        toolbar.add(annieMenu);
        toolbar.addSeparator();
    } catch (URISyntaxException e) {
    // should be impossible
    }
    LiveMenu tbNewLRMenu = new LiveMenu(LiveMenu.LR);
    JMenuButton menuButton = new JMenuButton(tbNewLRMenu);
    menuButton.setToolTipText("New Language Resource");
    menuButton.setIcon(getIcon("lrs"));
    toolbar.add(menuButton);
    LiveMenu tbNewPRMenu = new LiveMenu(LiveMenu.PR);
    menuButton = new JMenuButton(tbNewPRMenu);
    menuButton.setToolTipText("New Processing Resource");
    menuButton.setIcon(getIcon("prs"));
    toolbar.add(menuButton);
    LiveMenu tbNewAppMenu = new LiveMenu(LiveMenu.APP);
    menuButton = new JMenuButton(tbNewAppMenu);
    menuButton.setToolTipText("New Application");
    menuButton.setIcon(getIcon("applications"));
    toolbar.add(menuButton);
    toolbar.addSeparator();
    JPopupMenu tbDsMenu = new JPopupMenu();
    tbDsMenu.add(new NewDSAction());
    tbDsMenu.add(new OpenDSAction());
    menuButton = new JMenuButton(tbDsMenu);
    menuButton.setToolTipText("Datastores");
    menuButton.setIcon(getIcon("datastores"));
    toolbar.add(menuButton);
    toolbar.addSeparator();
    button = new JButton(new ManagePluginsAction());
    button.setToolTipText(button.getText());
    button.setText("");
    toolbar.add(button);
    toolbar.addSeparator();
    button = new JButton(new NewAnnotDiffAction());
    button.setToolTipText(button.getText());
    button.setText("");
    toolbar.add(button);
    toolbar.add(Box.createHorizontalGlue());
    this.getContentPane().add(toolbar, BorderLayout.NORTH);
}
Also used : JPanel(javax.swing.JPanel) Rectangle(java.awt.Rectangle) Image(java.awt.Image) Document(gate.Document) XJMenu(gate.swing.XJMenu) BenchmarkReportException(gate.util.reporting.exceptions.BenchmarkReportException) FileAppender(org.apache.log4j.FileAppender) ToolTipManager(javax.swing.ToolTipManager) GATEVersionIcon(gate.resources.img.svg.GATEVersionIcon) PatternLayout(org.apache.log4j.PatternLayout) JMenuButton(gate.swing.JMenuButton) TransferHandler(javax.swing.TransferHandler) GridBagLayout(java.awt.GridBagLayout) URI(java.net.URI) DataFlavor(java.awt.datatransfer.DataFlavor) JScrollPane(javax.swing.JScrollPane) ActionMap(javax.swing.ActionMap) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) IOException(java.io.IOException) XJTabbedPane(gate.swing.XJTabbedPane) TreePath(javax.swing.tree.TreePath) OverlayLayout(javax.swing.OverlayLayout) Layout(org.apache.log4j.Layout) GridBagLayout(java.awt.GridBagLayout) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout) PatternLayout(org.apache.log4j.PatternLayout) ButtonGroup(javax.swing.ButtonGroup) JMenuBar(javax.swing.JMenuBar) GridBagConstraints(java.awt.GridBagConstraints) ActionEvent(java.awt.event.ActionEvent) StringSelection(java.awt.datatransfer.StringSelection) BorderLayout(java.awt.BorderLayout) ArrayList(java.util.ArrayList) List(java.util.List) JList(javax.swing.JList) AbstractAction(javax.swing.AbstractAction) Appender(org.apache.log4j.Appender) FileAppender(org.apache.log4j.FileAppender) Color(java.awt.Color) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionListener(java.awt.event.ActionListener) InputMap(javax.swing.InputMap) JSplitPane(javax.swing.JSplitPane) File(java.io.File) Insets(java.awt.Insets) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BoxLayout(javax.swing.BoxLayout) JProgressBar(javax.swing.JProgressBar) JButton(javax.swing.JButton) GATEIcon(gate.resources.img.svg.GATEIcon) URISyntaxException(java.net.URISyntaxException) XJPopupMenu(gate.swing.XJPopupMenu) ResourceReference(gate.creole.ResourceReference) XJMenuItem(gate.swing.XJMenuItem) JMenuItem(javax.swing.JMenuItem) DocTimeReporter(gate.util.reporting.DocTimeReporter) JComponent(javax.swing.JComponent) Transferable(java.awt.datatransfer.Transferable) JToolBar(javax.swing.JToolBar) Point(java.awt.Point) Date(java.util.Date) XJPopupMenu(gate.swing.XJPopupMenu) JPopupMenu(javax.swing.JPopupMenu) OverlayLayout(javax.swing.OverlayLayout) PRTimeReporter(gate.util.reporting.PRTimeReporter) XJMenuItem(gate.swing.XJMenuItem) JMenu(javax.swing.JMenu) XJMenu(gate.swing.XJMenu)

Example 29 with JProgressBar

use of javax.swing.JProgressBar in project keystore-explorer by kaikramer.

the class DGeneratingKeyPair method initComponents.

private void initComponents() {
    jlGenKeyPair = new JLabel(res.getString("DGeneratingKeyPair.jlGenKeyPair.text"));
    ImageIcon icon = new ImageIcon(getClass().getResource(res.getString("DGeneratingKeyPair.jlGenKeyPair.image")));
    jlGenKeyPair.setIcon(icon);
    jlGenKeyPair.setHorizontalTextPosition(SwingConstants.LEADING);
    jlGenKeyPair.setIconTextGap(15);
    jpGenKeyPair = new JPanel(new FlowLayout(FlowLayout.CENTER));
    jpGenKeyPair.add(jlGenKeyPair);
    jpGenKeyPair.setBorder(new EmptyBorder(5, 5, 5, 5));
    jpbGenKeyPair = new JProgressBar();
    jpbGenKeyPair.setIndeterminate(true);
    jpProgress = new JPanel(new FlowLayout(FlowLayout.CENTER));
    jpProgress.add(jpbGenKeyPair);
    jpProgress.setBorder(new EmptyBorder(5, 5, 5, 5));
    jbCancel = new JButton(res.getString("DGeneratingKeyPair.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jpCancel = PlatformUtil.createDialogButtonPanel(jbCancel, false);
    getContentPane().add(jpGenKeyPair, BorderLayout.NORTH);
    getContentPane().add(jpProgress, BorderLayout.CENTER);
    getContentPane().add(jpCancel, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            if ((generator != null) && (generator.isAlive())) {
                generator.interrupt();
            }
            closeDialog();
        }
    });
    setTitle(res.getString("DGeneratingKeyPair.Title"));
    setResizable(false);
    pack();
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) JProgressBar(javax.swing.JProgressBar) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction)

Example 30 with JProgressBar

use of javax.swing.JProgressBar in project ant by apache.

the class SplashScreen method init.

protected void init(ImageIcon img, String progressRegExp, String displayText) {
    if (progressRegExp != null) {
        progressRegExpPattern = Pattern.compile(progressRegExp);
    }
    JPanel pan = (JPanel) getContentPane();
    JLabel piccy;
    if (img == null) {
        piccy = new JLabel();
    } else {
        piccy = new JLabel(img);
    }
    piccy.setBorder(BorderFactory.createLineBorder(Color.black, 1));
    if (displayText == null) {
        displayText = "Building....";
    }
    text = new JLabel(displayText, JLabel.CENTER);
    text.setFont(new Font("Sans-Serif", Font.BOLD, FONT_SIZE));
    text.setBorder(BorderFactory.createEtchedBorder());
    pb = new JProgressBar(MIN, MAX);
    pb.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
    JPanel pan2 = new JPanel();
    pan2.setLayout(new BorderLayout());
    pan2.add(text, BorderLayout.NORTH);
    pan2.add(pb, BorderLayout.SOUTH);
    pan.setLayout(new BorderLayout());
    pan.add(piccy, BorderLayout.CENTER);
    pan.add(pan2, BorderLayout.SOUTH);
    pan.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
    pack();
    Dimension size = getSize();
    Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (scr.width - size.width) / 2;
    int y = (scr.height - size.height) / 2;
    setBounds(x, y, size.width, size.height);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Font(java.awt.Font)

Aggregations

JProgressBar (javax.swing.JProgressBar)87 JLabel (javax.swing.JLabel)53 JPanel (javax.swing.JPanel)40 JButton (javax.swing.JButton)32 Dimension (java.awt.Dimension)30 BorderLayout (java.awt.BorderLayout)28 ActionEvent (java.awt.event.ActionEvent)20 JScrollPane (javax.swing.JScrollPane)20 ActionListener (java.awt.event.ActionListener)16 Insets (java.awt.Insets)14 IOException (java.io.IOException)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)13 FlowLayout (java.awt.FlowLayout)12 JCheckBox (javax.swing.JCheckBox)12 ArrayList (java.util.ArrayList)11 JDialog (javax.swing.JDialog)11 File (java.io.File)10 ImageIcon (javax.swing.ImageIcon)10 JComboBox (javax.swing.JComboBox)9