Example usage for javax.swing JComponent add

List of usage examples for javax.swing JComponent add

Introduction

In this page you can find the example usage for javax.swing JComponent add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java

private void initLayout() {
    Container content = this.getContentPane();
    JComponent controls = Box.createVerticalBox();
    {/*from  ww w  .j av a  2  s  . com*/
        JPanel filePanel = new JPanel(new BorderLayout());
        {
            filePanel.setBorder(BorderFactory.createTitledBorder("Stock Market Trading Data"));
            JPanel dataButtons = new JPanel(new GridLayout(2, 1));
            {
                dataButtons.add(this.loadFileButton);
                dataButtons.add(this.viewDataButton);
            }
            filePanel.add(dataButtons, BorderLayout.EAST);
            JPanel fileControls = new JPanel(new FlowLayout());
            {
                fileControls.add(new JLabel("Stock data File:"));
                fileControls.add(this.fileField);
                fileControls.add(this.fileBrowseButton);
                fileControls.add(new JLabel("  Stock data format:"));
                fileControls.add(this.fileFormatCombo);
            }
            filePanel.add(fileControls, BorderLayout.CENTER);
        }
        controls.add(filePanel);
        JComponent simPanel = new JPanel(new BorderLayout());
        {
            simPanel.setBorder(BorderFactory.createTitledBorder("Simulation Run"));
            simPanel.add(this.runButton, BorderLayout.EAST);
            JComponent simControlsPanel = Box.createVerticalBox();
            {
                JPanel accountControls = new JPanel(new FlowLayout());
                {
                    accountControls.add(new JLabel("Initial Cash:"));
                    accountControls.add(this.initialCashField);
                    accountControls.add(new JLabel("  Per Trade Fee:"));
                    accountControls.add(this.perTradeFeeField);
                    accountControls.add(new JLabel("  Per Share Trade Commission:"));
                    accountControls.add(this.perShareTradeCommissionField);
                    accountControls.add(new JLabel("  Compare:"));
                    accountControls.add(this.compareIndexSymbolField);
                }
                simControlsPanel.add(accountControls);
                JPanel runControls = new JPanel(new FlowLayout());
                {
                    runControls.add(this.strategyField);
                    runControls.add(new JLabel("Start Date:"));
                    runControls.add(this.startDateField);
                    runControls.add(new JLabel("  End Date:"));
                    runControls.add(this.endDateField);
                    runControls.add(new JLabel("  Strategy:"));
                    runControls.add(this.strategyField);
                    runControls.add(this.editButton);
                    runControls.add(this.compileButton);
                }
                simControlsPanel.add(runControls);
            }
            simPanel.add(simControlsPanel, BorderLayout.CENTER);
        }
        controls.add(simPanel);
    }
    content.add(controls, BorderLayout.NORTH);
    JSplitPane vSplit = this.vSplit;
    {
        vSplit.setResizeWeight(0.5);
        vSplit.add(this.chartPanel, JSplitPane.TOP);
        JSplitPane hSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        {
            hSplit.setResizeWeight(0.5); // enough for no hscrollbar in 1024 width
            JSplitPane reportSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
            {
                reportSplit.setResizeWeight(0.5);
                JScrollPane reportScroll = new JScrollPane(this.reportArea);
                {
                    reportScroll.setBorder(BorderFactory.createTitledBorder("Report"));
                }
                reportSplit.add(reportScroll, JSplitPane.TOP);
                JScrollPane monthScroll = new JScrollPane(this.monthlyLogArea);
                {
                    monthScroll.setBorder(BorderFactory.createTitledBorder("Monthly Log"));
                }
                reportSplit.add(monthScroll, JSplitPane.BOTTOM);
            }
            hSplit.add(reportSplit, JSplitPane.LEFT);
            JScrollPane tradeScroll = new JScrollPane(this.tradeLogArea);
            {
                tradeScroll.setBorder(BorderFactory.createTitledBorder("Trade Log"));
            }
            hSplit.add(tradeScroll, JSplitPane.RIGHT);
        }
        vSplit.add(hSplit, JSplitPane.BOTTOM);
    }
    content.add(vSplit, BorderLayout.CENTER);
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected JComponent showWindowThisTab(Window window, String caption, String description) {
    getDialogParams().reset();/*ww  w. j a  va  2  s .c  om*/

    window.setWidth("100%");
    window.setHeight("100%");

    JComponent layout;
    if (isMainWindowManager) {
        layout = (JComponent) tabsPane.getSelectedComponent();
    } else {
        layout = (JComponent) frame.getContentPane().getComponent(0);
    }
    WindowBreadCrumbs breadCrumbs = tabs.get(layout);
    if (breadCrumbs == null)
        throw new IllegalStateException("BreadCrumbs not found");

    Window currentWindow = breadCrumbs.getCurrentWindow();
    Window currentWindowFrame = (Window) currentWindow.getFrame();
    windowOpenMode.get(currentWindowFrame).setFocusOwner(frame.getFocusOwner());

    Set<Map.Entry<Window, Integer>> set = windows.entrySet();
    boolean pushed = false;
    for (Map.Entry<Window, Integer> entry : set) {
        if (entry.getKey().equals(currentWindow)) {
            windows.remove(currentWindow);
            stacks.get(breadCrumbs).push(entry);
            pushed = true;
            break;
        }
    }
    if (!pushed) {
        stacks.get(breadCrumbs).push(new AbstractMap.SimpleEntry<>(currentWindow, null));
    }

    windows.remove(window);
    layout.remove(DesktopComponentsHelper.getComposition(currentWindow));

    JComponent component = DesktopComponentsHelper.getComposition(window);
    layout.add(component);

    breadCrumbs.addWindow(window);
    if (isMainWindowManager) {
        setActiveWindowCaption(caption, description, tabsPane.getSelectedIndex());
    } else {
        setTopLevelWindowCaption(caption);
        component.revalidate();
        component.repaint();
    }

    return layout;
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected void closeWindow(Window window, WindowOpenInfo openInfo) {
    if (!disableSavingScreenHistory) {
        screenHistorySupport.saveScreenHistory(window, openInfo.getOpenMode());
    }/*from   w w w . j ava  2  s.co  m*/

    switch (openInfo.getOpenMode()) {
    case DIALOG: {
        JDialog dialog = (JDialog) openInfo.getData();
        dialog.setVisible(false);
        dialog.dispose();
        cleanupAfterModalDialogClosed(window);

        fireListeners(window, tabs.size() != 0);
        break;
    }
    case NEW_TAB:
    case NEW_WINDOW: {
        JComponent layout = (JComponent) openInfo.getData();
        layout.remove(DesktopComponentsHelper.getComposition(window));
        if (isMainWindowManager) {
            tabsPane.remove(layout);
        }

        WindowBreadCrumbs windowBreadCrumbs = tabs.get(layout);
        if (windowBreadCrumbs != null) {
            windowBreadCrumbs.clearListeners();
            windowBreadCrumbs.removeWindow();
        }

        tabs.remove(layout);
        stacks.remove(windowBreadCrumbs);

        fireListeners(window, tabs.size() != 0);
        if (!isMainWindowManager) {
            closeFrame(getFrame());
        }
        break;
    }
    case THIS_TAB: {
        JComponent layout = (JComponent) openInfo.getData();

        final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
        if (breadCrumbs == null)
            throw new IllegalStateException("Unable to close screen: breadCrumbs not found");

        breadCrumbs.removeWindow();
        Window currentWindow = breadCrumbs.getCurrentWindow();
        if (!stacks.get(breadCrumbs).empty()) {
            Map.Entry<Window, Integer> entry = stacks.get(breadCrumbs).pop();
            putToWindowMap(entry.getKey(), entry.getValue());
        }
        JComponent component = DesktopComponentsHelper.getComposition(currentWindow);
        Window currentWindowFrame = (Window) currentWindow.getFrame();
        final java.awt.Component focusedCmp = windowOpenMode.get(currentWindowFrame).getFocusOwner();
        if (focusedCmp != null) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    focusedCmp.requestFocus();
                }
            });
        }
        layout.remove(DesktopComponentsHelper.getComposition(window));

        if (App.getInstance().getConnection().isConnected()) {
            layout.add(component);
            if (isMainWindowManager) {
                // If user clicked on close button maybe selectedIndex != tabsPane.getSelectedIndex()
                // Refs #1117
                int selectedIndex = 0;
                while ((selectedIndex < tabs.size()) && (tabsPane.getComponentAt(selectedIndex) != layout)) {
                    selectedIndex++;
                }
                if (selectedIndex == tabs.size()) {
                    selectedIndex = tabsPane.getSelectedIndex();
                }

                setActiveWindowCaption(currentWindow.getCaption(), currentWindow.getDescription(),
                        selectedIndex);
            } else {
                setTopLevelWindowCaption(currentWindow.getCaption());
                component.revalidate();
                component.repaint();
            }
        }

        fireListeners(window, tabs.size() != 0);
        break;
    }

    default:
        throw new UnsupportedOperationException();
    }
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

@SuppressWarnings("unchecked")
private JComponent initializeJComponentForParameter(final String strValue, final ParameterInfo info)
        throws ModelInformationException {
    JComponent field = null;

    if (info.isBoolean()) {
        field = new JCheckBox();
        boolean value = Boolean.parseBoolean(strValue);
        ((JCheckBox) field).setSelected(value);
    } else if (info.isEnum() || info instanceof MasonChooserParameterInfo) {
        Object[] elements = null;
        if (info.isEnum()) {
            final Class<Enum<?>> type = (Class<Enum<?>>) info.getJavaType();
            elements = type.getEnumConstants();
        } else {/* w ww .  j  a  v a  2  s  .com*/
            final MasonChooserParameterInfo chooserInfo = (MasonChooserParameterInfo) info;
            elements = chooserInfo.getValidStrings();
        }
        final JComboBox list = new JComboBox(elements);

        if (info.isEnum()) {
            try {
                @SuppressWarnings("rawtypes")
                final Object value = Enum.valueOf((Class<? extends Enum>) info.getJavaType(), strValue);
                list.setSelectedItem(value);
            } catch (final IllegalArgumentException e) {
                throw new ModelInformationException(e.getMessage() + " for parameter: " + info.getName() + ".");
            }
        } else {
            try {
                final int value = Integer.parseInt(strValue);
                list.setSelectedIndex(value);
            } catch (final NumberFormatException e) {
                throw new ModelInformationException(
                        "Invalid value for parameter " + info.getName() + " (not a number).");
            }
        }
        field = list;
    } else if (info.isFile()) {
        field = new JPanel();
        final JTextField textField = new JTextField();

        if (!strValue.isEmpty()) {
            final File file = new File(strValue);
            textField.setText(file.getName());
            textField.setToolTipText(file.getAbsolutePath());
        }

        field.add(textField);
    } else if (info instanceof MasonIntervalParameterInfo) {
        field = new JPanel();
        final JTextField textField = new JTextField(strValue);
        field.add(textField);
    } else {
        field = new JTextField(strValue);
    }

    return field;
}

From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java

private void initComponents() {

    URL icon;//from w w w  .j  a  va 2 s  .c om
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/icon.png");
    this.setIconImage(Toolkit.getDefaultToolkit().createImage(icon));
    JComponent pane;
    pane = (JComponent) getContentPane();

    // ====================Menu Setting=======================
    newItem = new JMenuItem("New From Blast");
    newItem.setMnemonic('n');
    newItem.addActionListener(commandActionListener);

    openItem = new JMenuItem("Open");
    openItem.setMnemonic('o');
    openItem.addActionListener(commandActionListener);

    appendGraphItem = new JMenuItem("Append Graph");
    appendGraphItem.setMnemonic('a');
    appendGraphItem.addActionListener(commandActionListener);

    saveItem = new JMenuItem("Save");
    saveItem.setMnemonic('s');
    saveItem.addActionListener(commandActionListener);

    saveAsGraphItem = new JMenuItem("Save As");
    saveAsGraphItem.addActionListener(commandActionListener);

    exportGraphItem = new JMenuItem("Export");
    exportGraphItem.addActionListener(commandActionListener);

    saveCurGraphItem = new JMenuItem("Save Current Graph");
    saveCurGraphItem.addActionListener(commandActionListener);

    saveCurImgItem = new JMenuItem("Save Image");
    saveCurImgItem.addActionListener(commandActionListener);

    saveAllVertexAttrItem = new JMenuItem("Save Vertex Attribute");
    saveAllVertexAttrItem.addActionListener(commandActionListener);

    saveCurVertexAttrItem = new JMenuItem("Save Vertex Attribute");
    saveCurVertexAttrItem.addActionListener(commandActionListener);

    saveAsMenu = new JMenu("Save As");
    saveAsMenu.add(saveAsGraphItem);
    saveAsMenu.add(saveAllVertexAttrItem);

    saveCurGraphMenu = new JMenu("Save Current Graph");
    saveCurGraphMenu.add(saveCurGraphItem);
    saveCurGraphMenu.add(saveCurImgItem);
    saveCurGraphMenu.add(saveCurVertexAttrItem);

    printItem = new JMenuItem("Print...");
    printItem.setMnemonic('p');
    printItem.addActionListener(commandActionListener);

    importVertexAttrItem = new JMenuItem("Import Vertex Attribute");
    importVertexAttrItem.addActionListener(commandActionListener);

    closeItem = new JMenuItem("Close");
    closeItem.setMnemonic('c');
    closeItem.addActionListener(commandActionListener);

    exitItem = new JMenuItem("Exit");
    exitItem.setMnemonic('x');
    exitItem.addActionListener(commandActionListener);

    fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    fileMenu.add(newItem);
    fileMenu.add(openItem);
    fileMenu.add(appendGraphItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(closeItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(saveItem);
    fileMenu.add(saveAsMenu);
    fileMenu.add(saveCurGraphMenu);
    fileMenu.add(new JSeparator());
    fileMenu.add(printItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(importVertexAttrItem);
    fileMenu.add(exportGraphItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitItem);

    // edit menu
    undoItem = new JMenuItem("Undo");
    redoItem = new JMenuItem("Redo");
    Global.COMMAND_MANAGER.registerUndoRedoItem(undoItem, redoItem);
    removeSingleItem = new JMenuItem("Remove Single Vertices");
    removeSingleItem.addActionListener(commandActionListener);
    filterItem = new JMenuItem("Filt Graph");
    filterItem.addActionListener(commandActionListener);
    settingItem = new JMenuItem("Setting");
    settingItem.addActionListener(commandActionListener);

    markovClusterItem = new JMenuItem("Markov Cluster");
    markovClusterItem.addActionListener(commandActionListener);

    // genomeNumFiltItem = new JMenuItem("GenomeNum Filt");
    // genomeNumFiltItem.addActionListener(commandActionListener);

    // removeSingleLinkageItem = new JMenuItem("Remove Single Linkage");
    // removeSingleLinkageItem.addActionListener(commandActionListener);

    editMenu = new JMenu("Edit");
    editMenu.setMnemonic('e');
    editMenu.add(undoItem);
    editMenu.add(redoItem);
    editMenu.add(filterItem);
    editMenu.add(markovClusterItem);
    editMenu.add(removeSingleItem);
    // editMenu.add(genomeNumFiltItem);
    // editMenu.add(removeSingleLinkageItem);
    editMenu.add(settingItem);

    // Tools Item
    geneContentItem = new JMenuItem("Gene Content Table");
    geneContentItem.addActionListener(commandActionListener);

    batchSaveItem = new JMenuItem("Batch Save");
    batchSaveItem.addActionListener(commandActionListener);

    mstItem = new JMenuItem("Minimum Spanning Tree");
    mstItem.addActionListener(commandActionListener);

    viewNeighborItem = new JMenuItem("View Neighbor of...");
    viewNeighborItem.addActionListener(commandActionListener);

    //
    // tempWorkItem = new JMenuItem("Temp Work");
    // tempWorkItem.addActionListener(commandActionListener);

    toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic('t');
    toolsMenu.add(geneContentItem);
    toolsMenu.add(viewNeighborItem);
    toolsMenu.add(mstItem);
    toolsMenu.add(batchSaveItem);
    // toolsMenu.add(tempWorkItem);

    // graph Menu
    graphMenu = new JMenu("Graph");
    previousItem = new JMenuItem("Previous");
    previousItem.addActionListener(commandActionListener);
    nextItem = new JMenuItem("Next");
    nextItem.addActionListener(commandActionListener);
    resortItem = new JMenuItem("Resort graphs");
    resortItem.addActionListener(commandActionListener);

    graphMenu.add(nextItem);
    graphMenu.add(previousItem);
    graphMenu.add(resortItem);

    // help Menu
    helpContentItem = new JMenuItem("Online Manual");
    helpContentItem.addActionListener(commandActionListener);
    aboutItem = new JMenuItem("About BlastGraph");
    aboutItem.addActionListener(commandActionListener);

    helpMenu = new JMenu("Help");
    helpMenu.add(helpContentItem);
    helpMenu.add(aboutItem);

    // menu bar
    menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(graphMenu);
    menuBar.add(toolsMenu);
    menuBar.add(helpMenu);

    setJMenuBar(menuBar);

    // ===================mainPanel Setting===================
    GridBagManager.reset();
    GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
    GridBagManager.GRID_BAG.anchor = GridBagConstraints.FIRST_LINE_START;
    GridBagManager.GRID_BAG.weightx = 0;
    GridBagManager.GRID_BAG.weighty = 0;
    GridBagManager.GRID_BAG.insets = new Insets(2, 2, 1, 1);

    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    pane.add(mainPanel);

    hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    hsplitPane.setContinuousLayout(true);
    hsplitPane.setOneTouchExpandable(true);
    hsplitPane.setResizeWeight(0.9);

    // ===================toolBarPanel Setting===================

    // graph file toolbar
    fileToolBar = new JToolBar();
    fileToolBar.setRollover(true);
    newButton = new JButton();
    newButton.setBorderPainted(false);
    newButton.setMnemonic('n');
    newButton.setToolTipText("New From Blast");
    newButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filenew.png");
    // System.out.println(icon);
    newButton.setIcon(new ImageIcon(icon));

    openButton = new JButton();
    openButton.setBorderPainted(false);
    openButton.setMnemonic('o');
    openButton.setToolTipText("Open");
    openButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileopen.png");
    openButton.setIcon(new ImageIcon(icon));

    saveButton = new JButton();
    saveButton.setBorderPainted(false);
    saveButton.setMnemonic('s');
    saveButton.setToolTipText("Save");
    saveButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filesave.png");
    saveButton.setIcon(new ImageIcon(icon));

    saveCurImgButton = new JButton();
    saveCurImgButton.setBorderPainted(false);
    saveCurImgButton.setToolTipText("Save current image");
    saveCurImgButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/saveimage.png");
    saveCurImgButton.setIcon(new ImageIcon(icon));

    printButton = new JButton();
    printButton.setBorderPainted(false);
    printButton.setToolTipText("Print...");
    printButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileprint.png");
    printButton.setIcon(new ImageIcon(icon));

    fileToolBar.add(newButton);
    fileToolBar.add(openButton);
    fileToolBar.add(saveButton);
    fileToolBar.add(saveCurImgButton);
    fileToolBar.add(printButton);

    // graph control toolbar
    graphToolBar = new JToolBar();
    graphToolBar.setRollover(true);

    previousButton = new JButton();
    previousButton.setBorderPainted(false);
    previousButton.setToolTipText("Previous graph");
    previousButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/previous.png");
    previousButton.setIcon(new ImageIcon(icon));

    indexField = new JTextField();
    indexField.setSize(new Dimension(25, 16));
    indexField.setMinimumSize(new Dimension(25, 16));
    indexField.setPreferredSize(new Dimension(25, 16));
    indexField.addKeyListener(keyListener);

    nextButton = new JButton();
    nextButton.setBorderPainted(false);
    nextButton.setToolTipText("Next graph");
    nextButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/next.png");
    nextButton.setIcon(new ImageIcon(icon));

    filterButton = new JButton();
    filterButton.setBorderPainted(false);
    filterButton.setToolTipText("Filt graph");
    filterButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filter.png");
    filterButton.setIcon(new ImageIcon(icon));

    resortButton = new JButton();
    resortButton.setBorderPainted(false);
    resortButton.setToolTipText("Resort graph");
    resortButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/resort.png");
    resortButton.setIcon(new ImageIcon(icon));

    searchField = new JTextField();
    searchField.setSize(new Dimension(60, 16));
    searchField.setMinimumSize(new Dimension(60, 16));
    searchField.setPreferredSize(new Dimension(60, 16));
    searchField.addKeyListener(keyListener);

    searchButton = new JButton();
    searchButton.setBorderPainted(false);
    searchButton.setToolTipText("Search");
    searchButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/search.png");
    searchButton.setIcon(new ImageIcon(icon));

    graphToolBar.add(filterButton);
    graphToolBar.add(resortButton);
    // graphToolBar.add(new JToolBar.Separator());
    graphToolBar.add(previousButton);
    graphToolBar.add(indexField);
    graphToolBar.add(nextButton);
    graphToolBar.add(searchField);
    graphToolBar.add(searchButton);

    // view toolbar (modebox & layoutbox)
    viewToolBar = new JToolBar();
    viewToolBar.setRollover(true);
    modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            int index = modeBox.getSelectedIndex();
            if (index == 2) {
                int annotCount = annotationToolBar.getComponentCount();
                for (int i = 0; i < annotCount; i++) {
                    annotationToolBar.getComponent(i).setEnabled(true);
                }
            } else {
                int annotCount = annotationToolBar.getComponentCount();
                for (int i = 0; i < annotCount; i++) {
                    annotationToolBar.getComponent(i).setEnabled(false);
                }
            }

        }
    });
    layoutBox = this.getLayoutComboBox();
    viewToolBar.add(modeBox);
    viewToolBar.add(layoutBox);

    colorComboBox = new JComboBox(new String[] { "vertex color", "index", "strand", "genomeAcc", "organism" });
    viewToolBar.add(colorComboBox);

    // add additional menu to graphMenu
    modeMenu = graphMouse.getModeMenu();
    modeMenu.setText("Mode");
    layoutMenu = getLayoutMenu();
    layoutMenu.setText("Layout");
    graphMenu.add(modeMenu);
    graphMenu.add(layoutMenu);

    // annotation toolbar
    AnnotationControls<HitVertex, ValueEdge> annotationControls = new AnnotationControls<HitVertex, ValueEdge>(
            annotatingPlugin);
    annotationToolBar = annotationControls.getAnnotationsToolBar();
    ((JButton) annotationToolBar.getComponent(1)).setBorderPainted(false);
    ((JToggleButton) annotationToolBar.getComponent(2)).setBorderPainted(false);

    // add toolbars to toolBarPanel
    toolBarPanel = new JPanel();
    toolBarPanel.setLayout(new ModifiedFlowLayout(ModifiedFlowLayout.LEFT, 0, 0));
    toolBarPanel.setBorder(new EtchedBorder());
    toolBarPanel.add(fileToolBar);
    toolBarPanel.add(graphToolBar);
    toolBarPanel.add(viewToolBar);
    toolBarPanel.add(annotationToolBar);

    mainPanel.add(toolBarPanel, BorderLayout.NORTH);
    mainPanel.add(hsplitPane, BorderLayout.CENTER);

    // GridBagManager.add(mainPanel, toolBarPanel, 0, 0, 1, 1);
    // GridBagManager.add(mainPanel, hsplitPane, 0, 1, 1, 1);

    // mainPanel.add(toolBarPanel, BorderLayout.NORTH);

    // ===================vsplitPane Setting=================
    vsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    vsplitPane.setContinuousLayout(true);
    vsplitPane.setOneTouchExpandable(true);
    vsplitPane.setResizeWeight(0.9);

    hsplitPane.setLeftComponent(vsplitPane);
    // GridBagManager.GRID_BAG.weightx = 0.9;
    // GridBagManager.GRID_BAG.weighty = 1;
    // GridBagManager.add(mainPanel, vsplitPane, 0, 1, 1, 2);
    // mainPanel.add(vsplitPane, BorderLayout.CENTER);

    // ===================vvPanel Setting===================

    vvPanel = new GraphZoomScrollPane(vv);
    vsplitPane.setTopComponent(vvPanel);

    // ===================Tab Panel Setting=======================
    // progressPanel = new ProgressPanel();

    verticesTable = new VerticesTable();
    verticesTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            int row = verticesTable.rowAtPoint(e.getPoint());
            int col = verticesTable.columnAtPoint(e.getPoint());
            // System.out.println(row + " " + col);
            String value = verticesTable.getValueAt(row, col).toString();
            // System.out.println(value);
            if (Global.graph.containsVertex(new HitVertex(value))) {
                for (int i = 0; i < subSetList.size(); i++) {
                    if (subSetList.get(i).contains(new HitVertex(value))) {
                        curGraph = FilterUtils.createInducedSubgraph(subSetList.get(i), Global.graph);
                        PickedState<HitVertex> pickedVertexState = vv.getPickedVertexState();

                        // picked is a reference to picked vertices
                        // use a temp set to avoid concurrent modification
                        Set<HitVertex> picked = pickedVertexState.getPicked();
                        Set<HitVertex> temp = new HashSet<HitVertex>();
                        for (HitVertex hitVertex : picked) {
                            temp.add(hitVertex);
                        }
                        for (HitVertex hv : temp) {
                            pickedVertexState.pick(hv, false);
                        }

                        pickedVertexState.pick(new HitVertex(value), true);
                        // refreshSubGraphView();
                        return;
                    }
                }
            }
        }
    });

    verticesTable.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent e) {
            int row = verticesTable.rowAtPoint(e.getPoint());
            int col = verticesTable.columnAtPoint(e.getPoint());
            String value = verticesTable.getValueAt(row, col).toString();
            // System.out.println(value);
            if (Global.graph.containsVertex(value)) {
                Cursor normalCursor = new Cursor(Cursor.HAND_CURSOR);
                setCursor(normalCursor);
            } else {
                Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
                setCursor(normalCursor);
            }
        }
    });
    verticesPanel = new JPanel();
    verticesPanel.setLayout(new GridLayout());
    verticesPanel.add(new JScrollPane(verticesTable));

    edgesTable = new EdgesTable();
    edgesPanel = new JPanel();
    edgesPanel.setLayout(new GridLayout());
    edgesPanel.add(new JScrollPane(edgesTable));

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Vertices", verticesPanel);
    tabbedPane.addTab("Edges", edgesPanel);
    vsplitPane.setBottomComponent(tabbedPane);

    graphMouse.addPichedChangeListener(verticesTable, edgesTable);

    // ===================Info Panel Setting===================
    infoPanel = new JPanel(new GridBagLayout());
    GridBagManager.GRID_BAG.weightx = 0.1;
    GridBagManager.GRID_BAG.weighty = 1;
    hsplitPane.setRightComponent(infoPanel);

    JPanel mainInfoPanel = new JPanel(new GridBagLayout());
    mainInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Main Info"));

    JPanel currentInfoPanel = new JPanel(new GridBagLayout());
    currentInfoPanel.setBorder(
            BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Current Graph"));
    JPanel selectedInfoPanel = new JPanel(new GridBagLayout());
    selectedInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Selected"));

    JPanel statisticsInfoPanel = new JPanel(new GridBagLayout());
    statisticsInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Statistics"));

    JPanel progressInfoPanel = new JPanel(new GridBagLayout());
    progressInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Progress"));

    GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH;
    GridBagManager.GRID_BAG.fill = GridBagConstraints.HORIZONTAL;
    GridBagManager.GRID_BAG.weighty = 0;
    GridBagManager.add(infoPanel, mainInfoPanel, 0, 1, 1, 1);
    GridBagManager.add(infoPanel, currentInfoPanel, 0, 2, 1, 1);
    GridBagManager.add(infoPanel, selectedInfoPanel, 0, 3, 1, 1);
    GridBagManager.GRID_BAG.weighty = 0.5;
    GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
    GridBagManager.add(infoPanel, statisticsInfoPanel, 0, 4, 1, 1);
    GridBagManager.add(infoPanel, progressInfoPanel, 0, 5, 1, 1);

    // mainInfoPanel
    {
        JLabel vertices = new JLabel("Vertices:");
        vertexCountLabel = new JLabel("0");
        JLabel edges = new JLabel("Edges:");
        edgeCountLabel = new JLabel("0");
        JLabel subGraphs = new JLabel("SubGraphs:");
        subGraphCountLabel = new JLabel("0");
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(mainInfoPanel, vertices, 0, 0, 1, 1);
        GridBagManager.add(mainInfoPanel, edges, 0, 1, 1, 1);
        GridBagManager.add(mainInfoPanel, subGraphs, 0, 2, 1, 1);
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(mainInfoPanel, vertexCountLabel, 1, 0, 1, 1);
        GridBagManager.add(mainInfoPanel, edgeCountLabel, 1, 1, 1, 1);
        GridBagManager.add(mainInfoPanel, subGraphCountLabel, 1, 2, 1, 1);

    } // end of mainInfoPanel

    // currentInfoPanel
    {
        JLabel vertices = new JLabel("Vertices:");
        currentVertexCountLabel = new JLabel("0");

        JLabel edges = new JLabel("Edges:");
        currentEdgeCountLabel = new JLabel("0");

        JLabel acc = new JLabel("ACC:");
        currentAccLabel = new JLabel("0");

        GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(currentInfoPanel, vertices, 0, 0, 1, 1);
        GridBagManager.add(currentInfoPanel, edges, 0, 1, 1, 1);
        GridBagManager.add(currentInfoPanel, acc, 0, 2, 1, 1);
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(currentInfoPanel, currentVertexCountLabel, 1, 0, 1, 1);
        GridBagManager.add(currentInfoPanel, currentEdgeCountLabel, 1, 1, 1, 1);
        GridBagManager.add(currentInfoPanel, currentAccLabel, 1, 2, 1, 1);

    } // end of currentInfoPanel

    // selectedInfoPanel
    {
        JLabel vertices = new JLabel("Vertices:");
        selectedVertexCountLabel = new JLabel("0");
        JLabel edges = new JLabel("Edges:");
        selectedEdgeCountLabel = new JLabel("0");
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(selectedInfoPanel, vertices, 0, 0, 1, 1);
        GridBagManager.add(selectedInfoPanel, edges, 0, 1, 1, 1);
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(selectedInfoPanel, selectedVertexCountLabel, 1, 0, 1, 1);
        GridBagManager.add(selectedInfoPanel, selectedEdgeCountLabel, 1, 1, 1, 1);
        CollectionChangeListener<HitVertex> svListener = new CollectionChangeListener<HitVertex>() {

            @Override
            public void onCollectionChange(Set<HitVertex> set) {
                selectedVertexCountLabel.setText("" + set.size());
            }
        };

        CollectionChangeListener<ValueEdge> veListener = new CollectionChangeListener<ValueEdge>() {

            @Override
            public void onCollectionChange(Set<ValueEdge> set) {
                selectedEdgeCountLabel.setText("" + set.size());
            }
        };

        graphMouse.addPichedChangeListener(svListener, veListener);

    } // end of selectedInfoPanel

    {// statistics Panel
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH;
        GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
        GridBagManager.add(statisticsInfoPanel, graphStatisticsPanel, 0, 0, 1, 1);
    } // statistics Panel

    {// progressInfoPanel
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH;
        GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
        GridBagManager.add(progressInfoPanel, progressPanel, 0, 0, 1, 1);
    } // progressInfoPanel
      // set frame size
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    setSize((screen.width * 3) / 4, (screen.height * 9) / 10);
    setLocation(screen.width / 6, screen.height / 16);

    refreshUI(false);
}

From source file:org.datacleaner.panels.WelcomePanel.java

private JComponent createContentPanel() {
    JComponent result = null;

    final String welcomePanelClassName = SystemProperties.getString(SystemProperties.UI_DESKTOP_WELCOME_PANEL,
            null);/*from   www .j  a  v a  2 s.co m*/
    if (!Strings.isNullOrEmpty(welcomePanelClassName)) {
        final Injector injector = _dcModule.createInjectorBuilder().with(WelcomePanel.class, this)
                .createInjector();
        try {
            @SuppressWarnings("unchecked")
            final Class<? extends JComponent> componentClass = (Class<? extends JComponent>) Class
                    .forName(welcomePanelClassName);

            result = injector.getInstance(componentClass);
        } catch (Exception e) {
            logger.error("Failed to instantiate welcome panel class: {}", welcomePanelClassName, e);
        }
    }

    if (result == null) {
        result = new DCPanel();
        if (Version.isCommunityEdition()) {
            final JXEditorPane editorPane = new JXEditorPane("text/html",
                    "You're now using the <b>Community Edition</b> of DataCleaner.<br/><br/>"
                            + "We hope that you enjoy this free product. We encourage you to also check out the "
                            + "commercial DataCleaner editions which feature added functionality, "
                            + "helpful getting started wizards and commercial support. "
                            + "You can find more information about them online.");
            editorPane.setEditable(false);
            editorPane.setOpaque(false);
            editorPane.setFont(WidgetUtils.FONT_HEADER2);
            editorPane.setPreferredSize(new Dimension(DCSplashPanel.WIDTH_CONTENT, 120));

            final JButton tryProfessionalButton = WidgetFactory.createDefaultButton("Try professional edition",
                    IconUtils.APPLICATION_ICON);
            tryProfessionalButton
                    .addActionListener(new OpenBrowserAction("http://datacleaner.org/get_datacleaner"));

            final JButton readMoreButton = WidgetFactory.createDefaultButton("Compare the editions",
                    IconUtils.WEBSITE);
            readMoreButton.addActionListener(new OpenBrowserAction("http://datacleaner.org/editions"));

            final JButton discussionForumButton = WidgetFactory
                    .createDefaultButton("Visit the discussion forum", "images/menu/forum.png");
            discussionForumButton.setToolTipText(
                    "Visit the online discussion forum for questions and answers in the community");
            final OpenBrowserAction forumActionListener = new OpenBrowserAction("http://datacleaner.org/forum");
            discussionForumButton.addActionListener(forumActionListener);

            final JButton twitterButton = WidgetFactory.createDefaultButton(null, "images/menu/twitter.png");
            twitterButton.setToolTipText("Spread the message about #DataCleaner on Twitter");
            twitterButton.addActionListener(new OpenBrowserAction("https://twitter.com/intent/tweet?text="
                    + UrlEscapers.urlFormParameterEscaper().escape("I'm using @DataCleaner (v. "
                            + Version.getVersion() + ") for some really fancy #dataquality stuff!")));

            final JButton linkedInButton = WidgetFactory.createDefaultButton(null, "images/menu/linkedin.png");
            linkedInButton.setToolTipText("Join our LinkedIn group of users and professionals");
            linkedInButton
                    .addActionListener(new OpenBrowserAction("http://www.linkedin.com/groups?gid=3352784"));

            final JLabel loveFeedbackAnimation = new JLabel(
                    ImageManager.get().getImageIcon("images/window/we_love_community_and_feedback.gif"),
                    JLabel.LEFT);
            loveFeedbackAnimation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            loveFeedbackAnimation.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    forumActionListener.actionPerformed(null);
                }
            });

            final DCPanel innerPanel = new DCPanel();
            innerPanel.setLayout(new VerticalLayout());
            innerPanel.setBorder(
                    new CompoundBorder(WidgetUtils.BORDER_LIST_ITEM_LEFT_ONLY, new EmptyBorder(0, 20, 0, 0)));
            innerPanel.add(editorPane);
            innerPanel.add(DCPanel.flow(tryProfessionalButton, readMoreButton));
            innerPanel.add(Box.createVerticalStrut(80));
            innerPanel.add(loveFeedbackAnimation);
            innerPanel.add(Box.createVerticalStrut(20));
            innerPanel.add(DCPanel.flow(discussionForumButton, twitterButton, linkedInButton));
            innerPanel.add(Box.createVerticalStrut(5));

            result.setLayout(new VerticalLayout());
            result.add(Box.createVerticalStrut(100));
            result.add(innerPanel);
        }
    }

    return wrapContent(result);
}

From source file:org.freeplane.view.swing.features.filepreview.AudioViewerFactory.java

public JComponent createViewer(final ExternalResource resource, final URI uri, int maximumWidth)
        throws MalformedURLException, IOException {
    String vlcPath = "C:\\Program Files\\VideoLAN\\VLC";
    NativeLibrary.addSearchPath("libvlc", vlcPath);
    System.setProperty("jna.library.path", vlcPath);

    final URI mediaPath = uri;

    JComponent jc = new JPanel();
    jc.setLayout(new GridLayout(3, 2, 5, 10));
    JLabel FileType = new JLabel("FILE TYPE: ");
    JLabel FileName = new JLabel("AUDIO FILE");

    JLabel Title = new JLabel("TITLE: ");
    tField = new TextField(20);
    tField.setEditable(true);/*from   w w  w. j av  a 2  s  . c  o m*/
    //tField.setText(new Scanner(new File("fieldSave.txt")).useDelimiter("\\A").next());
    //   JLabel TitleData = new JLabel("________________________");

    JButton TitleButton = new JButton("Save Title");
    JButton playAudio = new JButton("Play Audio");

    jc.add(FileType);
    jc.add(FileName);
    jc.add(Title);
    jc.add(tField);
    //      jc.add(TitleData);
    jc.add(TitleButton);
    jc.add(playAudio);

    playAudio.addActionListener(new PlayAudio(mediaPath, vlcPath));
    TitleButton.addActionListener(new AddTitleData());

    jc.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    return jc;
}

From source file:org.freeplane.view.swing.features.filepreview.VideoViewerFactory.java

public JComponent createViewer(final ExternalResource resource, final URI uri, int maximumWidth)
        throws MalformedURLException, IOException {
    String vlcPath = "C:\\Program Files\\VideoLAN\\VLC";
    NativeLibrary.addSearchPath("libvlc", vlcPath);
    System.setProperty("jna.library.path", vlcPath);

    final URI mediaPath = uri;

    JComponent jc = new JPanel();
    jc.setLayout(new GridLayout(3, 2, 5, 10));
    JLabel FileType = new JLabel("FILE TYPE: ");
    JLabel FileName = new JLabel("VIDEO FILE");

    JLabel Title = new JLabel("TITLE: ");
    tField = new TextField(20);
    tField.setEditable(true);/* w w w  . j  av a 2 s .  c  om*/
    //tField.setText(new Scanner(new File("fieldSave.txt")).useDelimiter("\\A").next());

    //   JLabel TitleData = new JLabel("________________________");

    JButton TitleButton = new JButton("Save Title");
    JButton playVideo = new JButton("Play Video");

    jc.add(FileType);
    jc.add(FileName);
    jc.add(Title);
    jc.add(tField);
    //      jc.add(TitleData);
    jc.add(TitleButton);
    jc.add(playVideo);

    playVideo.addActionListener(new PlayAudio(mediaPath, vlcPath));
    TitleButton.addActionListener(new AddTitleData());

    tField.addActionListener(new AddTitleData());

    jc.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    return jc;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserModel.java

/**
 * Adds the children of the passed node to its internal desktop.
 * This method should be invoked when user switches between layout.
 * //from w  ww  .ja  va 2  s .com
 * @param node The node to handle.
 */
private void addToDesktop(ImageDisplay node) {
    if (node instanceof ImageNode)
        return;
    JComponent desktop = node.getInternalDesktop();
    Collection<ImageDisplay> children = node.getChildrenDisplay();
    if (children == null)
        return;
    //desktop.removeAll();
    Iterator<ImageDisplay> i = children.iterator();
    ImageDisplay child;
    while (i.hasNext()) {
        child = i.next();
        if (!node.containsImages())
            addToDesktop(child);
        else
            desktop.add(child);
    }
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserModel.java

/**
 * Implemented as specified by the {@link Browser} interface.
 * @see Browser#resetChildDisplay()/*from ww  w.  ja  va2s  .  c  o  m*/
 */
public void resetChildDisplay() {
    rootDisplay.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Collection<ImageDisplay> rootChildren = rootDisplay.getChildrenDisplay();
    JComponent desktop = rootDisplay.getInternalDesktop();
    desktop.removeAll();
    Iterator<ImageDisplay> i;
    switch (selectedLayout.getIndex()) {
    case LayoutFactory.SQUARY_LAYOUT:
        i = rootChildren.iterator();
        ImageDisplay child;
        while (i.hasNext()) {
            child = i.next();
            desktop.add(child);
            addToDesktop(child);
        }
        break;

    case LayoutFactory.FLAT_LAYOUT:
        i = getImageNodes().iterator();
        while (i.hasNext())
            desktop.add(i.next());
    }
    rootDisplay.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}