Example usage for javax.swing JToolBar add

List of usage examples for javax.swing JToolBar add

Introduction

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

Prototype

public JButton add(Action a) 

Source Link

Document

Adds a new JButton which dispatches the action.

Usage

From source file:com._17od.upm.gui.MainWindow.java

private JToolBar createToolBar() {

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);/* w  w  w .  j  a  v a  2s  .  co  m*/
    toolbar.setRollover(true);

    // The "Add Account" button
    addAccountButton = new JButton();
    addAccountButton.setToolTipText(Translator.translate(ADD_ACCOUNT_TXT));
    addAccountButton.setIcon(Util.loadImage("add_account.gif"));
    addAccountButton.setDisabledIcon(Util.loadImage("add_account_d.gif"));
    ;
    addAccountButton.addActionListener(this);
    addAccountButton.setEnabled(false);
    addAccountButton.setActionCommand(ADD_ACCOUNT_TXT);
    toolbar.add(addAccountButton);

    // The "Edit Account" button
    editAccountButton = new JButton();
    editAccountButton.setToolTipText(Translator.translate(EDIT_ACCOUNT_TXT));
    editAccountButton.setIcon(Util.loadImage("edit_account.gif"));
    editAccountButton.setDisabledIcon(Util.loadImage("edit_account_d.gif"));
    ;
    editAccountButton.addActionListener(this);
    editAccountButton.setEnabled(false);
    editAccountButton.setActionCommand(EDIT_ACCOUNT_TXT);
    toolbar.add(editAccountButton);

    // The "Delete Account" button
    deleteAccountButton = new JButton();
    deleteAccountButton.setToolTipText(Translator.translate(DELETE_ACCOUNT_TXT));
    deleteAccountButton.setIcon(Util.loadImage("delete_account.gif"));
    deleteAccountButton.setDisabledIcon(Util.loadImage("delete_account_d.gif"));
    ;
    deleteAccountButton.addActionListener(this);
    deleteAccountButton.setEnabled(false);
    deleteAccountButton.setActionCommand(DELETE_ACCOUNT_TXT);
    toolbar.add(deleteAccountButton);

    toolbar.addSeparator();

    // The "Copy Username" button
    copyUsernameButton = new JButton();
    copyUsernameButton.setToolTipText(Translator.translate(COPY_USERNAME_TXT));
    copyUsernameButton.setIcon(Util.loadImage("copy_username.gif"));
    copyUsernameButton.setDisabledIcon(Util.loadImage("copy_username_d.gif"));
    ;
    copyUsernameButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyUsernameToClipboard();
        }
    });
    copyUsernameButton.setEnabled(false);
    toolbar.add(copyUsernameButton);

    // The "Copy Password" button
    copyPasswordButton = new JButton();
    copyPasswordButton.setToolTipText(Translator.translate(COPY_PASSWORD_TXT));
    copyPasswordButton.setIcon(Util.loadImage("copy_password.gif"));
    copyPasswordButton.setDisabledIcon(Util.loadImage("copy_password_d.gif"));
    ;
    copyPasswordButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyPasswordToClipboard();
        }
    });
    copyPasswordButton.setEnabled(false);
    toolbar.add(copyPasswordButton);

    // The "Launch URL" button
    launchURLButton = new JButton();
    launchURLButton.setToolTipText(Translator.translate(LAUNCH_URL_TXT));
    launchURLButton.setIcon(Util.loadImage("launch_URL.gif"));
    launchURLButton.setDisabledIcon(Util.loadImage("launch_URL_d.gif"));
    ;
    launchURLButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            AccountInformation accInfo = dbActions.getSelectedAccount();
            String uRl = accInfo.getUrl();

            // Check if the selected url is null or emty and inform the user
            // via JoptioPane message
            if ((uRl == null) || (uRl.length() == 0)) {
                JOptionPane.showMessageDialog(launchURLButton.getParent(),
                        Translator.translate("EmptyUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Check if the selected url is a valid formated url(via
                // urlIsValid() method) and inform the user via JoptioPane
                // message
            } else if (!(urlIsValid(uRl))) {
                JOptionPane.showMessageDialog(launchURLButton.getParent(),
                        Translator.translate("InvalidUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Call the method LaunchSelectedURL() using the selected
                // url as input
            } else {
                LaunchSelectedURL(uRl);

            }
        }
    });
    launchURLButton.setEnabled(false);
    toolbar.add(launchURLButton);

    toolbar.addSeparator();

    // The "Option" button
    optionsButton = new JButton();
    optionsButton.setToolTipText(Translator.translate(OPTIONS_TXT));
    optionsButton.setIcon(Util.loadImage("options.gif"));
    optionsButton.setDisabledIcon(Util.loadImage("options_d.gif"));
    ;
    optionsButton.addActionListener(this);
    optionsButton.setEnabled(true);
    optionsButton.setActionCommand(OPTIONS_TXT);
    toolbar.add(optionsButton);

    toolbar.addSeparator();

    // The Sync database button
    syncDatabaseButton = new JButton();
    syncDatabaseButton.setToolTipText(Translator.translate(SYNC_DATABASE_TXT));
    syncDatabaseButton.setIcon(Util.loadImage("sync.png"));
    syncDatabaseButton.setDisabledIcon(Util.loadImage("sync_d.png"));
    ;
    syncDatabaseButton.addActionListener(this);
    syncDatabaseButton.setEnabled(false);
    syncDatabaseButton.setActionCommand(SYNC_DATABASE_TXT);
    toolbar.add(syncDatabaseButton);

    return toolbar;
}

From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java

/**
 * Initialize GUI components./*from   w  w  w.j  av  a 2 s  .c o m*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void initGUI() {

    App.init();

    // setBounds(100, 100, 972, 439);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setIconImage(Builder.getApplicationIcon());
    setTitle("Sample Size Analysis");
    getContentPane().setLayout(new MigLayout("", "[1136px,grow,fill]", "[30px][405px,grow]"));

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    getContentPane().add(toolBar, "cell 0 0,growx,aligny top");

    JToolBarButton btnOpen = new JToolBarButton(actionBrowse);
    btnOpen.setIcon(Builder.getImageIcon("fileopen.png"));
    toolBar.add(btnOpen);

    JToolBarButton btnSave = new JToolBarButton(actionSaveTable);
    btnSave.setIcon(Builder.getImageIcon("save.png"));
    toolBar.add(btnSave);

    JToolBarButton btnExportPDF = new JToolBarButton(actionExportPDF);
    btnExportPDF.setIcon(Builder.getImageIcon("pdf.png"));
    toolBar.add(btnExportPDF);

    JToolBarButton btnExportPNG = new JToolBarButton(actionExportPNG);
    btnExportPNG.setIcon(Builder.getImageIcon("formatpng.png"));
    toolBar.add(btnExportPNG);

    toolBar.addSeparator();

    JToolBarButton btnRun = new JToolBarButton(actionRun);
    btnRun.setIcon(Builder.getImageIcon("run.png"));
    toolBar.add(btnRun);

    JPanel panelMain = new JPanel();
    getContentPane().add(panelMain, "cell 0 1,grow");
    panelMain.setLayout(new BorderLayout(0, 0));

    JSplitPane splitPaneMain = new JSplitPane();
    splitPaneMain.setOneTouchExpandable(true);
    panelMain.add(splitPaneMain);

    JPanel panelParameters = new JPanel();
    splitPaneMain.setLeftComponent(panelParameters);
    panelParameters.setLayout(new MigLayout("", "[grow,right]", "[][][][193.00,grow,fill][]"));

    JPanel panelInput = new JPanel();
    panelInput.setBorder(new TitledBorder(null, "Input", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelInput, "cell 0 0,grow");
    panelInput.setLayout(new MigLayout("", "[100px:100px:180px,right][grow,fill][]", "[]"));

    JLabel lblInputFile = new JLabel("Input file:");
    panelInput.add(lblInputFile, "cell 0 0");

    txtInputFile = new JTextField();
    panelInput.add(txtInputFile, "cell 1 0,growx");
    txtInputFile.setActionCommand("NewFileTyped");
    txtInputFile.addActionListener(this);
    txtInputFile.setColumns(10);

    JButton btnBrowse = new JButton("");
    panelInput.add(btnBrowse, "cell 2 0");
    btnBrowse.setAction(actionBrowse);
    btnBrowse.setText("");
    btnBrowse.setIcon(Builder.getImageIcon("fileopen16.png"));
    btnBrowse.setPreferredSize(new Dimension(25, 25));
    btnBrowse.setMaximumSize(new Dimension(25, 25));
    btnBrowse.putClientProperty("JButton.buttonType", "segmentedTextured");
    btnBrowse.putClientProperty("JButton.segmentPosition", "middle");

    JPanel panelAnalysisOptions = new JPanel();
    panelAnalysisOptions.setBorder(new TitledBorder(null, "Analysis and filtering options",
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelAnalysisOptions, "cell 0 1,grow");
    panelAnalysisOptions.setLayout(new MigLayout("", "[100px:100px:180px,right][grow][][]", "[][][][][]"));

    JLabel lblEventTypes = new JLabel("Event type:");
    panelAnalysisOptions.add(lblEventTypes, "cell 0 0");

    cboEventType = new JComboBox();
    panelAnalysisOptions.add(cboEventType, "cell 1 0 3 1");
    cboEventType.setModel(new DefaultComboBoxModel(EventTypeToProcess.values()));
    new EventTypeWrapper(cboEventType, PrefKey.EVENT_TYPE_TO_PROCESS, EventTypeToProcess.FIRE_EVENT);

    chkCommonYears = new JCheckBox("<html>Only analyze years all series have in common");
    chkCommonYears.setEnabled(false);
    new CheckBoxWrapper(chkCommonYears, PrefKey.SSIZ_CHK_COMMON_YEARS, false);
    panelAnalysisOptions.add(chkCommonYears, "cell 1 1 3 1");

    chkExcludeSeriesWithNoEvents = new JCheckBox("<html>Exclude series/segments with no events");
    chkExcludeSeriesWithNoEvents.setEnabled(false);
    new CheckBoxWrapper(chkExcludeSeriesWithNoEvents, PrefKey.SSIZ_CHK_EXCLUDE_SERIES_WITH_NO_EVENTS, false);
    panelAnalysisOptions.add(chkExcludeSeriesWithNoEvents, "cell 1 2 3 1");

    JLabel lblThresholdType = new JLabel("Threshold:");
    panelAnalysisOptions.add(lblThresholdType, "cell 0 3");

    cboThresholdType = new JComboBox();
    panelAnalysisOptions.add(cboThresholdType, "cell 1 3");
    cboThresholdType.setModel(new DefaultComboBoxModel(FireFilterType.values()));
    new FireFilterTypeWrapper(cboThresholdType, PrefKey.COMPOSITE_FILTER_TYPE_WITH_ALL_TREES,
            FireFilterType.NUMBER_OF_EVENTS);

    JLabel label = new JLabel(">=");
    panelAnalysisOptions.add(label, "flowx,cell 2 3");

    spnThresholdValueGT = new JSpinner();
    panelAnalysisOptions.add(spnThresholdValueGT, "cell 3 3");
    spnThresholdValueGT.setModel(new SpinnerNumberModel(1, 1, 999, 1));
    new SpinnerWrapper(spnThresholdValueGT, PrefKey.COMPOSITE_FILTER_VALUE, 1);

    chkEnableLessThan = new JCheckBox("");
    chkEnableLessThan.setActionCommand("LessThanThresholdStatus");
    chkEnableLessThan.addActionListener(this);
    panelAnalysisOptions.add(chkEnableLessThan, "flowx,cell 1 4,alignx right");

    lblLessThan = new JLabel("<=");
    lblLessThan.setEnabled(false);
    panelAnalysisOptions.add(lblLessThan, "cell 2 4");

    spnThresholdValueLT = new JSpinner();
    spnThresholdValueLT.setEnabled(false);
    spnThresholdValueLT.setModel(new SpinnerNumberModel(1, 1, 999, 1));
    panelAnalysisOptions.add(spnThresholdValueLT, "cell 3 4");

    lblAnd = new JLabel("and");
    panelAnalysisOptions.add(lblAnd, "cell 1 4");

    JPanel panelSimulations = new JPanel();
    panelSimulations.setBorder(
            new TitledBorder(null, "Simulations", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelSimulations, "cell 0 2,grow");
    panelSimulations.setLayout(new MigLayout("", "[100px:100px:180px,right][fill]", "[][][]"));

    JLabel lblSimulations = new JLabel("Simulations:");
    panelSimulations.add(lblSimulations, "cell 0 0");

    spnSimulations = new JSpinner();
    panelSimulations.add(spnSimulations, "cell 1 0");
    spnSimulations.setModel(new SpinnerNumberModel(new Integer(1000), new Integer(1), null, new Integer(1)));
    new SpinnerWrapper(spnSimulations, PrefKey.SSIZ_SIMULATION_COUNT, 1000);

    JLabel lblSeedNumber = new JLabel("Seed number:");
    panelSimulations.add(lblSeedNumber, "cell 0 1");

    spnSeed = new JSpinner();
    panelSimulations.add(spnSeed, "cell 1 1");
    spnSeed.setModel(new SpinnerNumberModel(new Integer(30188), null, null, new Integer(1)));
    new SpinnerWrapper(spnSeed, PrefKey.SSIZ_SEED_NUMBER, 30188);

    JLabel lblResampling = new JLabel("Resampling:");
    panelSimulations.add(lblResampling, "cell 0 2");

    cboResampling = new JComboBox();
    panelSimulations.add(cboResampling, "cell 1 2");
    cboResampling
            .setModel(new DefaultComboBoxModel(new String[] { "With replacement", "Without replacement" }));
    new ResamplingTypeWrapper(cboResampling, PrefKey.SSIZ_RESAMPLING_TYPE, ResamplingType.WITH_REPLACEMENT);

    segmentationPanel = new SegmentationPanel();
    segmentationPanel.chkSegmentation.setText("Process subset or segments of dataset?");
    segmentationPanel.chkSegmentation.setEnabled(false);
    panelParameters.add(segmentationPanel, "cell 0 3,growx");

    JPanel panel_3 = new JPanel();
    panelParameters.add(panel_3, "cell 0 4,grow");
    panel_3.setLayout(new MigLayout("", "[left][grow][right]", "[]"));

    JButton btnReset = new JButton("Reset");
    btnReset.setActionCommand("Reset");
    btnReset.addActionListener(this);
    panel_3.add(btnReset, "cell 0 0,grow");

    JButton btnRunAnalysis = new JButton("Run Analysis");
    btnRunAnalysis.setAction(actionRun);
    panel_3.add(btnRunAnalysis, "cell 2 0,grow");

    JPanel panelResults = new JPanel();
    splitPaneMain.setRightComponent(panelResults);
    panelResults.setLayout(new BorderLayout(0, 0));

    splitPaneResults = new JSplitPane();
    splitPaneResults.setResizeWeight(0.5);
    splitPaneResults.setOneTouchExpandable(true);
    splitPaneResults.setDividerLocation(0.5d);
    panelResults.add(splitPaneResults, BorderLayout.CENTER);
    splitPaneResults.setOrientation(JSplitPane.VERTICAL_SPLIT);

    JPanel panelResultsTop = new JPanel();
    splitPaneResults.setLeftComponent(panelResultsTop);
    panelResultsTop.setLayout(new BorderLayout(0, 0));

    JPanel panelChartOptions = new JPanel();
    panelChartOptions.setBackground(Color.WHITE);
    panelResultsTop.add(panelChartOptions, BorderLayout.SOUTH);
    panelChartOptions.setLayout(new MigLayout("", "[][][][][][grow][grow]", "[15px,center]"));

    JLabel lblNewLabel = new JLabel("Plot:");
    panelChartOptions.add(lblNewLabel, "cell 0 0,alignx trailing,aligny center");

    cboChartMetric = new JComboBox();
    cboChartMetric.setEnabled(false);
    cboChartMetric.setModel(new DefaultComboBoxModel(MiddleMetric.values()));
    panelChartOptions.add(cboChartMetric, "cell 1 0,growx");
    cboChartMetric.setBackground(Color.WHITE);

    JLabel lblOfSegment = new JLabel("of segment:");
    panelChartOptions.add(lblOfSegment, "cell 2 0,alignx trailing");

    cboSegment = new JComboBox();
    cboSegment.setBackground(Color.WHITE);
    cboSegment.setActionCommand("UpdateChart");
    cboSegment.addActionListener(this);

    panelChartOptions.add(cboSegment, "cell 3 0,growx");
    cboChartMetric.setActionCommand("UpdateChart");

    JLabel lblWithAsymptoteType = new JLabel("with asymptote type:");
    panelChartOptions.add(lblWithAsymptoteType, "cell 4 0,alignx trailing");

    JComboBox comboBox = new JComboBox();
    comboBox.setEnabled(false);
    comboBox.setModel(new DefaultComboBoxModel(new String[] { "none", "Weibull", "Michaelis-Menten",
            "Modified Michaelis-Menten", "Logistic", "Modified exponential" }));
    comboBox.setBackground(Color.WHITE);
    panelChartOptions.add(comboBox, "cell 5 0,growx");
    cboChartMetric.addActionListener(this);

    panelChart = new JPanel();
    panelChart.setMinimumSize(new Dimension(200, 200));
    panelResultsTop.add(panelChart, BorderLayout.CENTER);
    panelChart.setLayout(new BorderLayout(0, 0));
    panelChart.setBackground(Color.WHITE);

    JTabbedPane panelResultsBottom = new JTabbedPane(JTabbedPane.BOTTOM);
    splitPaneResults.setRightComponent(panelResultsBottom);

    simulationsTable = new SSIZResultsTable();
    simulationsTable.setEnabled(false);
    simulationsTable.addMouseListener(new TablePopClickListener());
    simulationsTable.setVisibleRowCount(10);

    adapter = new JTableSpreadsheetByRowAdapter(simulationsTable);

    scrollPaneSimulations = new JScrollPane();
    panelResultsBottom.addTab("Simulations", null, scrollPaneSimulations, null);
    scrollPaneSimulations.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPaneSimulations.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPaneSimulations.setViewportView(simulationsTable);

    JPanel panelAsymptote = new JPanel();

    asymptoteTable = new AsymptoteTable();
    asymptoteTable.setEnabled(false);
    // asymptoteTable.addMouseListener(new TablePopClickListener());
    asymptoteTable.setVisibleRowCount(10);

    scrollPaneAsymptote = new JScrollPane();

    scrollPaneAsymptote.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPaneAsymptote.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPaneAsymptote.setViewportView(asymptoteTable);
    panelAsymptote.setLayout(new BorderLayout());
    panelAsymptote.add(scrollPaneAsymptote, BorderLayout.CENTER);
    panelResultsBottom.addTab("Asymptote", null, panelAsymptote, null);

    // Disable asymptote tab until it is implemented
    panelResultsBottom.setEnabledAt(1, false);

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

    btnCancelAnalysis = new JButton("Cancel");
    btnCancelAnalysis.setIcon(Builder.getImageIcon("delete.png"));
    btnCancelAnalysis.setVisible(false);
    btnCancelAnalysis.setActionCommand("CancelAnalysis");
    btnCancelAnalysis.addActionListener(this);

    progressBar = new JProgressBar();
    panelProgressBar.add(progressBar, BorderLayout.CENTER);
    panelProgressBar.add(btnCancelAnalysis, BorderLayout.EAST);
    progressBar.setStringPainted(true);

    fileDialogWasUsed = false;
    mouseListenersActive = false;

    this.setGUIForFHFileReader();
    this.setGUIForThresholdStatus();

    pack();
    this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    setVisible(true);
}

From source file:com.emental.mindraider.ui.outline.OutlineJPanel.java

private JToolBar createToolbar() {
    JToolBar toolbar = new JToolBar();
    newButton = new JButton("", IconsRegistry.getImageIcon("add.png"));
    newButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.newConcept"));
    newButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            newConcept();/*  ww  w . j a v  a2 s. c om*/
        }
    });
    toolbar.add(newButton);

    attachButton = new JButton("", IconsRegistry.getImageIcon("attach.png"));
    attachButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.attachDragDropResourceToConcept"));
    attachButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            conceptAttach();
        }
    });
    toolbar.add(attachButton);

    discardButton = new JButton("", IconsRegistry.getImageIcon("explorerDiscardSmall.png"));
    discardButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.discardConcept"));
    discardButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            conceptDiscard();
        }
    });
    toolbar.add(discardButton);

    toolbar.addSeparator();

    promoteButton = new JButton("", IconsRegistry.getImageIcon("back.png"));
    promoteButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.promoteConceptToParentLevel"));
    promoteButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            conceptPromote();
        }
    });
    toolbar.add(promoteButton);
    firstButton = new JButton("", IconsRegistry.getImageIcon("upup.png"));
    firstButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.moveConceptFirst"));
    firstButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            while (conceptUp())
                ;
        }
    });
    toolbar.add(firstButton);
    upButton = new JButton("", IconsRegistry.getImageIcon("up.png"));
    upButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.moveConceptUp"));
    upButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            conceptUp();
        }
    });
    toolbar.add(upButton);
    downButton = new JButton("", IconsRegistry.getImageIcon("down.png"));
    downButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.moveConceptDown"));
    downButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            conceptDown();
        }
    });
    toolbar.add(downButton);
    lastButton = new JButton("", IconsRegistry.getImageIcon("downdown.png"));
    lastButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.moveConceptLast"));
    lastButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            while (conceptDown())
                ;
        }
    });
    toolbar.add(lastButton);
    demoteButton = new JButton("", IconsRegistry.getImageIcon("forward.png"));
    demoteButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.demoteConceptToChildrenLevel"));
    demoteButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            conceptDemote();
        }
    });
    toolbar.add(demoteButton);

    toolbar.addSeparator();

    refactorButton = new JButton("", IconsRegistry.getImageIcon("refactorConcept.png"));
    refactorButton
            .setToolTipText(Messages.getString("NotebookOutlineJPanel.refactorConceptsToAnotherNotebook"));
    refactorButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            /*
             * in this case refactoring means: o discard of the concept in
             * this notebook o creation of the concept in the target
             * notebook concept is not deleted because URN should be never
             * deleted. this feature will be important for example for
             * vodyanoi.
             */
            conceptRefactor();
            treeTable.tree.updateUI();
        }
    });
    toolbar.add(refactorButton);

    refreshButton = new JButton("", IconsRegistry.getImageIcon("explorerReloadSmall.png"));
    refreshButton.setToolTipText(Messages.getString("NotebookOutlineJPanel.reloadNotebook"));
    refreshButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            refresh();
        }
    });
    toolbar.add(refreshButton);

    toolbar.addSeparator();

    expandTreeButton = new JButton("", IconsRegistry.getImageIcon("expandTree.png"));
    expandTreeButton.setToolTipText("Expand Concept tree");
    expandTreeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            expandAllTreeTableRows();
        }
    });
    toolbar.add(expandTreeButton);

    collapseTreeButton = new JButton("", IconsRegistry.getImageIcon("collapseTree.png"));
    collapseTreeButton.setToolTipText("Collapse Concept tree");
    collapseTreeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            collapseAllTreeTableRows();
        }
    });
    toolbar.add(collapseTreeButton);

    toolbar.addSeparator();

    // Gnowsis: link
    gnowsisLinkButton = new JButton("", IconsRegistry.getImageIcon("gnowsisLink.png"));
    gnowsisLinkButton.setToolTipText("Send Concept to Gnowsis to be linked");
    gnowsisLinkButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(OutlineJPanel.this,
                        "To send URI to Gnowsis a notebook must be loaded!", "Gnowsis Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            // determine selected resource URI
            DefaultMutableTreeNode node = getSelectedTreeNode();
            if (node != null) {
                String uri = ((OutlineNode) node).getUri();
                logger.debug("Gnowsis hub: sending URI: '" + uri + "'");
                GnowsisClient.linkResource(uri);
            } else {
                logger.debug("No node selected!");
            }
        }
    });
    if (MindRaider.profile.isEnableGnowsisSupport()) {
        toolbar.add(gnowsisLinkButton);
    }

    // Gnowsis: browse
    gnowsisBrowseButton = new JButton("", IconsRegistry.getImageIcon("gnowsisBrowse.png"));
    gnowsisBrowseButton.setToolTipText("Browse Concept in Gnowsis");
    gnowsisBrowseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(OutlineJPanel.this,
                        "To browse URI in Gnowsis a notebook must be loaded!", "Gnowsis Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            // determine selected resource URI
            DefaultMutableTreeNode node = getSelectedTreeNode();
            if (node != null) {
                String uri = ((OutlineNode) node).getUri();
                logger.debug("Gnowsis hub: sending browse URI: '" + uri + "'");
                GnowsisClient.browseResource(uri);
            } else {
                logger.debug("No node selected!");
            }
        }
    });
    if (MindRaider.profile.isEnableGnowsisSupport()) {
        toolbar.add(gnowsisBrowseButton);

        toolbar.addSeparator();
    }

    //        JButton button = new JButton("", IconsRegistry.getImageIcon("collapseTree.png"));
    //        button.setToolTipText("Hide/Show annotation column");
    //        button.addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                hideTreeTableAnnotationColumn();
    //            }
    //        });
    //        mainPanelControls.add(button);
    //        mainPanelControls.addSeparator();

    onTheFlyTWikiExportButton = new JButton("", IconsRegistry.getImageIcon("mozillaTwiki.png"));
    onTheFlyTWikiExportButton.setToolTipText("'On the fly' TWiki Export 2 HTML");
    onTheFlyTWikiExportButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(OutlineJPanel.this, "To export a notebook it must be loaded!",
                        "Export Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export"
                    + File.separator + "twiki" + File.separator + "tmp";
            Utils.createDirectory(exportDirectory);
            String dstFileName = exportDirectory + File.separator + "TWIKI-EXPORT-"
                    + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".html";
            logger.debug("Exporting to file: " + dstFileName);
            MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI_HTML, dstFileName);
            Launcher.launchInBrowser(dstFileName);
        }
    });
    // TODO removed mainPanelControls.add(onTheFlyTWikiExportButton);

    twikiExportJButton = new JButton("", IconsRegistry.getImageIcon("twikiExport.png"));
    twikiExportJButton.setToolTipText("Export back to the imported TWiki file");
    twikiExportJButton.setEnabled(false);
    twikiExportJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(OutlineJPanel.this, "To export a notebook it must be loaded!",
                        "Export Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
            // take the path from the notebook custodian
            String dstFileName;
            OutlineResource notebookResource = MindRaider.outlineCustodian.getActiveOutlineResource();
            if (notebookResource != null && notebookResource.getSourceTWikiFileProperty() != null) {
                dstFileName = notebookResource.getSourceTWikiFileProperty().getPath();
                StatusBar.show("Exporting Notebook to TWiki file: '" + dstFileName + "'...");
                MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI, dstFileName);
            }
        }
    });
    toolbar.add(twikiExportJButton);

    // TODO removed mainPanelControls.addSeparator();

    onTheFlyExportButton = new JButton("", IconsRegistry.getImageIcon("mozilla.png"));
    onTheFlyExportButton.setToolTipText("'On the fly' OPML Export 2 HTML");
    onTheFlyExportButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(OutlineJPanel.this, "To export a notebook it must be loaded!",
                        "Export Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export"
                    + File.separator + "opml" + File.separator + "tmp";
            Utils.createDirectory(exportDirectory);
            String dstFileName = exportDirectory + File.separator + "OPML-EXPORT-"
                    + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".html";
            logger.debug("Exporting to file: " + dstFileName);
            MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_OPML_HTML, dstFileName);
            Launcher.launchInBrowser(dstFileName);

        }
    });
    // TODO removed mainPanelControls.add(onTheFlyExportButton);

    toolbar.addSeparator();

    mindForgerUploadJButton = new JButton("", IconsRegistry.getImageIcon("tasks-internet.png"));
    mindForgerUploadJButton.setToolTipText("Upload this Outline to Online Edition");
    mindForgerUploadJButton.setEnabled(false);
    mindForgerUploadJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(OutlineJPanel.this, "To upload an Outline it must be loaded!",
                        "Upload Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
            // take the path from the notebook custodian
            MindRaiderMainWindow.getInstance().handleMindForgerActiveOutlineUpload();
        }
    });
    toolbar.add(mindForgerUploadJButton);

    return toolbar;
}

From source file:org.fhaes.jsea.JSEAFrame.java

/**
 * Setup toolbar./*from  www . jav a  2  s.c  o  m*/
 */
private void setupToolbar() {

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    getContentPane().add(toolBar, "cell 0 0");
    {
        JToolBarButton btnNew = new JToolBarButton(actionReset);
        btnNew.setToolTipText("Start new analysis");
        toolBar.add(btnNew);

        JToolBarButton btnSaveAll = new JToolBarButton(actionSaveAll);
        btnSaveAll.setToolTipText("Save all results");
        toolBar.add(btnSaveAll);

        toolBar.addSeparator();

        JToolBarButton btnCopy = new JToolBarButton(actionCopy);
        btnSaveAll.setToolTipText("Copy");
        toolBar.add(btnCopy);

        JToolBarButton btnChartProperties = new JToolBarButton(actionChartProperties);
        btnChartProperties.setToolTipText("Chart properties");
        toolBar.add(btnChartProperties);

        toolBar.addSeparator();

        JToolBarButton btnRun = new JToolBarButton(actionRun);
        btnRun.setToolTipText("Run analysis");
        toolBar.add(btnRun);

        toolBar.addSeparator();

        JToolBarButton btnLagMap = new JToolBarButton(actionLagMap);
        btnLagMap.setToolTipText("Launch LagMap");
        toolBar.add(btnLagMap);
    }
}

From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java

private void addToolbar() {
    final JToolBar toolbar = new JToolBar();

    final Icon addIcon = Utils.icon("add16.png");

    final JButton addButton = new JButton(addIcon);
    addButton.addActionListener(new ActionListener() {
        @Override// w ww  .j a va2s. c om
        public void actionPerformed(final ActionEvent e) {
            startAddServerWizard();
        }
    });
    addButton.setBounds(10, 10, addIcon.getIconWidth(), addIcon.getIconHeight());

    final Icon refreshIcon = Utils.icon("refresh16.png");
    final JButton refreshButton = new JButton(refreshIcon);
    refreshButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            refreshSelectedServers();
        }
    });
    refreshButton.setBounds(10, 10, refreshIcon.getIconWidth(), refreshIcon.getIconHeight());

    final Icon searchIcon = Utils.icon("search16.png");
    final JButton searchButton = new JButton(searchIcon);
    searchButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            showFilter();
        }
    });
    searchButton.setBounds(10, 10, searchIcon.getIconWidth(), searchIcon.getIconHeight());

    toolbar.add(addButton);
    toolbar.add(refreshButton);
    toolbar.add(searchButton);
    toolbar.setFloatable(false);
    add(toolbar, BorderLayout.PAGE_START);
}

From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java

/**
 * Create the panel./*from  w  ww. jav  a2  s  .com*/
 */
public Hl7V2MessageEditorPanel(final Controller theController) {
    setBorder(null);
    myController = theController;

    ButtonGroup encGrp = new ButtonGroup();
    setLayout(new BorderLayout(0, 0));

    mysplitPane = new JSplitPane();
    mysplitPane.setResizeWeight(0.5);
    mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(mysplitPane);

    mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight();
            ourLog.debug("Resizing split to ratio: {}", ratio);
            Prefs.getInstance().setHl7EditorSplit(ratio);
        }
    });

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit());
        }
    });

    messageEditorContainerPanel = new JPanel();
    messageEditorContainerPanel.setBorder(null);
    mysplitPane.setRightComponent(messageEditorContainerPanel);
    messageEditorContainerPanel.setLayout(new BorderLayout(0, 0));

    myMessageEditor = new JEditorPane();
    Highlighter h = new UnderlineHighlighter();
    myMessageEditor.setHighlighter(h);
    // myMessageEditor.setFont(Prefs.getHl7EditorFont());
    myMessageEditor.setSelectedTextColor(Color.black);

    myMessageEditor.setCaret(new EditorCaret());

    myMessageScrollPane = new JScrollPane(myMessageEditor);
    messageEditorContainerPanel.add(myMessageScrollPane);

    JToolBar toolBar = new JToolBar();
    messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    myFollowToggle = new JToggleButton("Follow");
    myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync");
    myFollowToggle.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            theController.setMessageEditorInFollowMode(myFollowToggle.isSelected());
        }
    });
    myFollowToggle.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png")));
    myFollowToggle.setSelected(theController.isMessageEditorInFollowMode());
    toolBar.add(myFollowToggle);

    myhorizontalStrut = Box.createHorizontalStrut(20);
    toolBar.add(myhorizontalStrut);

    mylabel_4 = new JLabel("Encoding");
    toolBar.add(mylabel_4);

    myRdbtnEr7 = new JRadioButton("ER7");
    myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1));
    toolBar.add(myRdbtnEr7);

    myRdbtnXml = new JRadioButton("XML");
    myRdbtnXml.setMargin(new Insets(1, 5, 0, 1));
    toolBar.add(myRdbtnXml);
    encGrp.add(myRdbtnEr7);
    encGrp.add(myRdbtnXml);

    treeContainerPanel = new JPanel();
    mysplitPane.setLeftComponent(treeContainerPanel);
    treeContainerPanel.setLayout(new BorderLayout(0, 0));

    mySpinnerIconOn = new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif"));
    mySpinnerIconOff = new ImageIcon();

    myTreePanel = new Hl7V2MessageTree(theController);
    myTreePanel.setWorkingListener(new IWorkingListener() {

        public void startedWorking() {
            mySpinner.setText("");
            mySpinner.setIcon(mySpinnerIconOn);
            mySpinnerIconOn.setImageObserver(mySpinner);
        }

        public void finishedWorking(String theStatus) {
            mySpinner.setText(theStatus);

            mySpinner.setIcon(mySpinnerIconOff);
            mySpinnerIconOn.setImageObserver(null);
        }
    });
    myTreeScrollPane = new JScrollPane(myTreePanel);

    myTopTabBar = new JTabbedPane();
    treeContainerPanel.add(myTopTabBar);
    myTopTabBar.setBorder(null);

    JPanel treeContainer = new JPanel();
    treeContainer.setLayout(new BorderLayout(0, 0));
    treeContainer.add(myTreeScrollPane);

    myTopTabBar.add("Message Tree", treeContainer);

    mytoolBar_1 = new JToolBar();
    mytoolBar_1.setFloatable(false);
    treeContainer.add(mytoolBar_1, BorderLayout.NORTH);

    mylabel_3 = new JLabel("Show");
    mytoolBar_1.add(mylabel_3);

    myShowCombo = new JComboBox();
    mytoolBar_1.add(myShowCombo);
    myShowCombo.setPreferredSize(new Dimension(130, 27));
    myShowCombo.setMinimumSize(new Dimension(130, 27));
    myShowCombo.setMaximumSize(new Dimension(130, 32767));

    collapseAllButton = new JButton();
    collapseAllButton.setBorderPainted(false);
    collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton));
    collapseAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.collapseAll();
        }
    });
    collapseAllButton.setToolTipText("Collapse All");
    collapseAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png")));
    mytoolBar_1.add(collapseAllButton);

    expandAllButton = new JButton();
    expandAllButton.setBorderPainted(false);
    expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton));
    expandAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.expandAll();
        }
    });
    expandAllButton.setToolTipText("Expand All");
    expandAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png")));
    mytoolBar_1.add(expandAllButton);

    myhorizontalGlue = Box.createHorizontalGlue();
    mytoolBar_1.add(myhorizontalGlue);

    mySpinner = new JButton("");
    mySpinner.setForeground(Color.DARK_GRAY);
    mySpinner.setHorizontalAlignment(SwingConstants.RIGHT);
    mySpinner.setMaximumSize(new Dimension(200, 15));
    mySpinner.setPreferredSize(new Dimension(200, 15));
    mySpinner.setMinimumSize(new Dimension(200, 15));
    mySpinner.setBorderPainted(false);
    mySpinner.setSize(new Dimension(16, 16));
    mytoolBar_1.add(mySpinner);
    myProfileComboboxModel = new ProfileComboModel();

    myTablesComboModel = new TablesComboModel(myController);

    mytoolBar = new JToolBar();
    mytoolBar.setFloatable(false);
    mytoolBar.setRollover(true);
    treeContainerPanel.add(mytoolBar, BorderLayout.NORTH);

    myOutboundInterfaceCombo = new JComboBox();
    myOutboundInterfaceComboModel = new DefaultComboBoxModel();

    mylabel_1 = new JLabel("Send");
    mytoolBar.add(mylabel_1);
    myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel);
    myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767));
    mytoolBar.add(myOutboundInterfaceCombo);

    mySendButton = new JButton("Send");
    mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton));
    mySendButton.setBorderPainted(false);
    mySendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // int selectedIndex =
            // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem());
            int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex();
            OutboundConnection connection = myController.getOutboundConnectionList().getConnections()
                    .get(selectedIndex);
            activateSendingActivityTabForConnection(connection);
            myController.sendMessages(connection, myMessage,
                    mySendingActivityTable.provideTransmissionCallback());
        }
    });

    myhorizontalStrut_2 = Box.createHorizontalStrut(20);
    myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_2);

    mySendOptionsButton = new JButton("Options");
    mySendOptionsButton.setBorderPainted(false);
    final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton);
    mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor);
    mySendOptionsButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png")));
    mytoolBar.add(mySendOptionsButton);
    mySendOptionsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent theE) {
            if (mySendOptionsPopupDialog != null) {
                mySendOptionsPopupDialog.doHide();
                mySendOptionsPopupDialog = null;
                return;
            }
            mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage,
                    mySendOptionsButton, sendOptionsHoverAdaptor);
            Point los = mySendOptionsButton.getLocationOnScreen();
            mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight());
            mySendOptionsPopupDialog.setVisible(true);
        }
    });

    mySendButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png")));
    mytoolBar.add(mySendButton);

    myhorizontalStrut_1 = Box.createHorizontalStrut(20);
    mytoolBar.add(myhorizontalStrut_1);

    mylabel_2 = new JLabel("Validate");
    mytoolBar.add(mylabel_2);

    myProfileCombobox = new JComboBox();
    mytoolBar.add(myProfileCombobox);
    myProfileCombobox.setPreferredSize(new Dimension(200, 27));
    myProfileCombobox.setMinimumSize(new Dimension(200, 27));
    myProfileCombobox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (myHandlingProfileComboboxChange) {
                return;
            }

            myHandlingProfileComboboxChange = true;
            try {
                if (myProfileCombobox.getSelectedIndex() == 0) {
                    myMessage.setValidationContext(null);
                } else if (myProfileCombobox.getSelectedIndex() == 1) {
                    myMessage.setValidationContext(new DefaultValidation());
                } else if (myProfileCombobox.getSelectedIndex() > 0) {
                    ProfileGroup profile = myProfileComboboxModel.myProfileGroups
                            .get(myProfileCombobox.getSelectedIndex());
                    myMessage.setRuntimeProfile(profile);

                    // } else if (myProfileCombobox.getSelectedItem() ==
                    // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) {
                    // IOkCancelCallback<Void> callback = new
                    // IOkCancelCallback<Void>() {
                    // public void ok(Void theArg) {
                    // myProfileComboboxModel.update();
                    // }
                    //
                    // public void cancel(Void theArg) {
                    // myProfileCombobox.setSelectedIndex(0);
                    // }
                    // };
                    // myController.chooseAndLoadConformanceProfileForMessage(myMessage,
                    // callback);
                }
            } catch (ProfileException e2) {
                ourLog.error("Failed to load profile", e2);
            } finally {
                myHandlingProfileComboboxChange = false;
            }
        }
    });
    myProfileCombobox.setMaximumSize(new Dimension(300, 32767));
    myProfileCombobox.setModel(myProfileComboboxModel);

    myhorizontalStrut_4 = Box.createHorizontalStrut(20);
    myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_4);

    // mySendingPanel = new JPanel();
    // mySendingPanel.setBorder(null);
    // myTopTabBar.addTab("Sending", null, mySendingPanel, null);
    // mySendingPanel.setLayout(new BorderLayout(0, 0));

    mySendingActivityTable = new ActivityTable();
    mySendingActivityTable.setController(myController);
    myTopTabBar.addTab("Sending", null, mySendingActivityTable, null);

    // mySendingPanelScrollPanel = new JScrollPane();
    // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable);
    //
    // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER);

    bottomPanel = new JPanel();
    bottomPanel.setPreferredSize(new Dimension(10, 20));
    bottomPanel.setMinimumSize(new Dimension(10, 20));
    add(bottomPanel, BorderLayout.SOUTH);
    GridBagLayout gbl_bottomPanel = new GridBagLayout();
    gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 };
    gbl_bottomPanel.rowHeights = new int[] { 16, 0 };
    gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    bottomPanel.setLayout(gbl_bottomPanel);

    mylabel = new JLabel("Terser Path:");
    mylabel.setHorizontalTextPosition(SwingConstants.LEFT);
    mylabel.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.fill = GridBagConstraints.VERTICAL;
    gbc_label.weighty = 1.0;
    gbc_label.anchor = GridBagConstraints.NORTHWEST;
    gbc_label.gridx = 0;
    gbc_label.gridy = 0;
    bottomPanel.add(mylabel, gbc_label);

    myTerserPathTextField = new JLabel();
    myTerserPathTextField.setForeground(Color.BLUE);
    myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13));
    myTerserPathTextField.setBorder(null);
    myTerserPathTextField.setBackground(SystemColor.control);
    myTerserPathTextField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) {
                myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0);
            }
        }
    });

    GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints();
    gbc_TerserPathTextField.weightx = 1.0;
    gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL;
    gbc_TerserPathTextField.gridx = 1;
    gbc_TerserPathTextField.gridy = 0;
    bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField);

    initLocal();

}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java

/**
 * DOCUMENT ME!/*w  w w  .  j  a va  2s.  co  m*/
 * 
 * @return DOCUMENT ME!
 */
public JToolBar createDiscoveryToolBar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(true);

    // Find
    URL findUrl = getClass().getClassLoader().getResource("icons/find.gif");
    ImageIcon findIcon = new ImageIcon(findUrl);
    findButton = toolBar.add(new AbstractAction("", findIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 3307493586585435411L;

        public void actionPerformed(ActionEvent e) {
            findAction();
        }
    });

    findButton.setToolTipText(resourceBundle.getString("button.find"));

    // showSchemes
    URL showSchemesUrl = getClass().getClassLoader().getResource("icons/schemeViewer.gif");
    ImageIcon showSchemesIcon = new ImageIcon(showSchemesUrl);
    showSchemesButton = toolBar.add(new AbstractAction("", showSchemesIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 1899451223510883277L;

        public void actionPerformed(ActionEvent e) {
            if (RegistryBrowser.client.connection == null) {
                displayUnconnectedError();
            } else {
                ConceptsTreeDialog.showSchemes(RegistryBrowser.getInstance(), false, isAuthenticated());
            }
        }
    });

    showSchemesButton.setToolTipText(resourceBundle.getString("button.showSchemes"));

    // Re-authenticate
    URL authenticateUrl = getClass().getClassLoader().getResource("icons/authenticate.gif");
    ImageIcon authenticateIcon = new ImageIcon(authenticateUrl);
    authenticateButton = toolBar.add(new AbstractAction("", authenticateIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 3469608949024981381L;

        public void actionPerformed(ActionEvent e) {
            authenticate();
        }
    });

    authenticateButton.setToolTipText(resourceBundle.getString("button.authenticate"));

    // Logout
    URL logoutUrl = getClass().getClassLoader().getResource("icons/logoff.gif");
    ImageIcon logoutIcon = new ImageIcon(logoutUrl);
    logoutButton = toolBar.add(new AbstractAction("", logoutIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = -293987897100997408L;

        public void actionPerformed(ActionEvent e) {
            logout();
        }
    });

    logoutButton.setToolTipText(resourceBundle.getString("button.logout"));
    logoutButton.setEnabled(false);

    // key registration
    URL keyRegUrl = getClass().getClassLoader().getResource("icons/keyReg.gif");
    ImageIcon keyRegIcon = new ImageIcon(keyRegUrl);
    keyRegButton = toolBar.add(new AbstractAction("", keyRegIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = -8988435962749097387L;

        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();

            // showKeyRegistrationWizard();
            KeyManager keyMgr = KeyManager.getInstance();

            try {
                keyMgr.registerNewKey();
            } catch (Exception er) {
                RegistryBrowser.displayError(er);
            }

            RegistryBrowser.setDefaultCursor();
        }
    });

    keyRegButton.setToolTipText(resourceBundle.getString("button.keyReg"));

    // user registration
    URL userRegUrl = getClass().getClassLoader().getResource("icons/userReg.gif");
    ImageIcon userRegIcon = new ImageIcon(userRegUrl);
    userRegButton = toolBar.add(new AbstractAction("", userRegIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 8890984621456210702L;

        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();

            // showUserRegistrationWizard();
            if (RegistryBrowser.client.connection == null) {
                displayUnconnectedError();
            } else {
                UserManager userMgr = UserManager.getInstance();

                try {
                    // Make sure you are logged off when registering new
                    // user so new user is not owned by old user.
                    logout();
                    userMgr.registerNewUser();
                    logout();
                } catch (Exception er) {
                    RegistryBrowser.displayError(er);
                }
            }

            RegistryBrowser.setDefaultCursor();
        }
    });

    userRegButton.setToolTipText(resourceBundle.getString("button.userReg"));

    // locale selection
    URL localeSelUrl = getClass().getClassLoader().getResource("icons/localeSel.gif");
    ImageIcon localeSelIcon = new ImageIcon(localeSelUrl);
    localeSelButton = toolBar.add(new AbstractAction("", localeSelIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 6304340858289330717L;

        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();

            LocaleSelectorDialog dialog = getLocaleSelectorDialog();

            @SuppressWarnings("unused")
            Locale oldSelectedLocale = getSelectedLocale();

            dialog.setVisible(true);

            Locale selectedLocale = getSelectedLocale();

            System.out.println(getLocale());

            setLocale(selectedLocale);

            RegistryBrowser.setDefaultCursor();
        }
    });

    localeSelButton.setToolTipText(resourceBundle.getString("button.localeSel"));

    return toolBar;
}

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

private JToolBar createToolBar() {
    String urlString;/*  www  . ja  v  a2  s  .  c o m*/
    URL url;
    final JToolBar tools = new JToolBar("jMetrik Tool Bar");
    JButton button;

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconNew = new ImageIcon(url, "New");
    button = new JButton(new NewTextFileAction("", iconNew));
    tools.add(button);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconOpen = new ImageIcon(url, "Open");
    button = new JButton(new OpenFileAction("", iconOpen));
    tools.add(button);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSave = new ImageIcon(url, "Save As");
    button = new JButton(new SaveAction("", iconSave));
    tools.add(button);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSaveAs = new ImageIcon(url, "Save As");
    button = new JButton(new SaveAsAction("", iconSaveAs));
    tools.add(button);

    tools.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconPrint = new ImageIcon(url, "Print");
    button = new JButton(new PrintAction("", iconPrint));
    tools.add(button);

    tools.addSeparator();

    //        urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png";
    //        url = this.getClass().getResource( urlString );
    //        ImageIcon iconCut = new ImageIcon(url, "Cut");
    //        button = new JButton(new DefaultEditorKit.CutAction());
    //        button.setText("");
    //        button.setIcon(iconCut);
    //        tools.addArgument(button);
    //
    //        urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png";
    //        url = this.getClass().getResource( urlString );
    //        ImageIcon iconCopy = new ImageIcon(url, "Copy");
    //        button = new JButton(new DefaultEditorKit.CopyAction());
    //        button.setText("");
    //        button.setIcon(iconCopy);
    //        tools.addArgument(button);
    //
    //        urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png";
    //        url = this.getClass().getResource( urlString );
    //        ImageIcon iconPaste = new ImageIcon(url, "Paste");
    //        button = new JButton(new DefaultEditorKit.PasteAction());
    //        button.setIcon(iconPaste);
    //        button.setText("");
    //        tools.addArgument(button);
    //
    //        tools.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconUndo = new ImageIcon(url, "Undo");
    button = new JButton(new UndoAction("", iconUndo));
    tools.add(button);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconRedo = new ImageIcon(url, "Redo");
    button = new JButton(new RedoAction("", iconRedo));
    tools.add(button);

    tools.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDesc = new ImageIcon(url, "Descriptions");
    button = new JButton("", iconDesc);
    button.setToolTipText("View table descriptions");
    button.addActionListener(new TableDescriptionActionListener());
    tools.add(button);

    tools.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/media-playback-start.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconStart = new ImageIcon(url, "Run Analysis from Syntax");
    button = new JButton(iconStart);
    button.setToolTipText("Run commands");
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent();
            JViewport vp = pain.getViewport();
            Component c = vp.getComponent(0);
            if (c instanceof JmetrikTextFile) {
                JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex());
                JmetrikTextFile textFile = (JmetrikTextFile) c;
                workspace.runFromSyntax(textFile.getText());
            }
        }
    });
    tools.add(button);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/media-playback-stop.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconStopThreads = new ImageIcon(url, "Stop Analysis");
    //        button = new JButton(new StopAllThreadsAction("",iconStopThreads));
    button = new JButton(iconStopThreads);
    tools.add(button);

    tools.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/utilities-system-monitor.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconStartMemoryMonitor = new ImageIcon(url, "Start Memory Monitor");
    button = new JButton(iconStartMemoryMonitor);
    button.setToolTipText("View memory allocation");
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            double m = (double) Runtime.getRuntime().maxMemory();
            double f = (double) Runtime.getRuntime().freeMemory();
            double t = (double) Runtime.getRuntime().totalMemory();
            f = f / 1048576.0;
            t = t / 1048576.0;
            m = m / 1048576.0;
            double amem = Precision.round(f / t * 100.0, 2);

            JOptionPane.showMessageDialog(Jmetrik.this,
                    "Total memory available: " + Precision.round(m, 2) + " MB\n" + "Current allocation: "
                            + Precision.round(t, 2) + " MB\n" + "Current amount free: " + Precision.round(f, 2)
                            + " MB (" + amem + "%)",
                    "JVM Memory Available", JOptionPane.INFORMATION_MESSAGE);
        }
    });
    tools.add(button);

    urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCloseAllTabs = new ImageIcon(url, "Close All");
    button = new JButton(new CloseAllTabsAction("", iconCloseAllTabs));
    tools.add(button);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/view-refresh.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconRefreshData = new ImageIcon(url, "Refresh Data View");
    refreshButton = new JButton("", iconRefreshData);
    refreshButton.setEnabled(false);
    tools.add(refreshButton);
    refreshButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            workspace.reloadTable(workspace.getCurrentDataTable());
            refreshButton.setEnabled(false);
            refreshButton.setText("");
        }
    });
    workspace.setRefreshButton(refreshButton);

    return tools;
}

From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java

protected void createActionComponents(JToolBar toolBar) {
    super.createActionComponents(toolBar);
    JButton button;//from  ww  w . j a v a 2  s .c  o m

    /**************** wiki Tab ****************/
    Action linkAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {

            try {
                //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity");
                parentApplet.getAppletContext().showDocument(new java.net.URL(
                        "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_2D_PointSegmentation_EM_Mixture"),
                        "SOCR EduMaterials Activities 2D PointSegmentation EM Mixture");
            } catch (MalformedURLException Exc) {
                JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE);
                Exc.printStackTrace();
            }

        }
    };

    button = toolBar.add(linkAction);
    button.setText(" WIKI_Activity ");
    button.setToolTipText("Press this Button to go to SOCR 2D PointSegmentation EM Mixture Activity wiki page");
}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

private void initGuiComponents() {
    fileListModel = new FileListTableModel();
    fileList = new FileListTable(fileListModel);
    fileList.addKeyListener(new KeyAdapter() {
        @Override/*w  ww  .  ja va 2  s.co  m*/
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                openSelectedFile();
                e.consume();
            }
        }
    });
    fileList.setAutoCreateColumnsFromModel(true);
    fileList.setDropMode(DropMode.ON_OR_INSERT_ROWS);
    fileList.setFillsViewportHeight(true);
    fileList.setGridColor(new Color(-1));

    fileListScrollPane = new JScrollPane(fileList);
    fileListScrollPane.setAutoscrolls(false);
    fileListScrollPane.setBackground(UIManager.getColor("TableHeader.background"));
    fileListScrollPane.setPreferredSize(new Dimension(100, 128));
    fileListScrollPane.setEnabled(false);

    //
    // toolbar
    //

    final JToolBar toolBar1 = new JToolBar();
    toolBar1.setBorderPainted(false);
    toolBar1.setFloatable(false);
    toolBar1.setRollover(true);
    toolBar1.putClientProperty("JToolBar.isRollover", Boolean.TRUE);

    homeDirectoryButton = new JButton();
    homeDirectoryButton.setHorizontalAlignment(2);
    homeDirectoryButton.setIcon(GUIHelper.HOME_ICON);
    homeDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    homeDirectoryButton.setText("");
    homeDirectoryButton.setToolTipText("Go to home directory");
    homeDirectoryButton.setEnabled(false);
    toolBar1.add(homeDirectoryButton);

    refreshButton = new JButton();
    refreshButton.setHorizontalAlignment(2);
    refreshButton.setIcon(new ImageIcon(getClass().getResource("/images/refresh.gif")));
    refreshButton.setMargin(new Insets(3, 3, 3, 3));
    refreshButton.setText("");
    refreshButton.setToolTipText("Refresh current directory listing");
    refreshButton.setEnabled(false);
    toolBar1.add(refreshButton);

    upDirectoryButton = new JButton();
    upDirectoryButton.setHideActionText(false);
    upDirectoryButton.setHorizontalAlignment(2);
    upDirectoryButton.setIcon(GUIHelper.UP_DIR_ICON);
    upDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    upDirectoryButton.setToolTipText("Up");
    upDirectoryButton.setEnabled(false);
    toolBar1.add(upDirectoryButton);

    browseDirectoryButton = new JButton();
    browseDirectoryButton.setHideActionText(false);
    browseDirectoryButton.setHorizontalAlignment(2);
    browseDirectoryButton.setIcon(GUIHelper.DIRECTORY_ICON);
    browseDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    browseDirectoryButton.setToolTipText(BROWSE_LFS_TEXT);
    browseDirectoryButton.setEnabled(false);
    toolBar1.add(browseDirectoryButton);

    profileModel = new ProfileComboBoxModel();
    profileSelectionCombo = new JComboBox(profileModel);
    profileSelectionCombo.setEnabled(false);
    profileSelectionCombo.setToolTipText("Select a namespace profile");
    profileSelectionCombo.setPrototypeDisplayValue("#");

    pathCombo = new JComboBox();
    pathCombo.setEditable(false);
    pathCombo.setEnabled(false);
    pathCombo.setToolTipText("Current directory path");
    pathCombo.setPrototypeDisplayValue("#");

    sslButton = new JButton();
    sslButton.setAlignmentY(0.0f);
    sslButton.setBorderPainted(false);
    sslButton.setHorizontalAlignment(2);
    sslButton.setHorizontalTextPosition(11);
    sslButton.setIcon(new ImageIcon(getClass().getResource("/images/lockedstate.gif")));
    sslButton.setMargin(new Insets(0, 0, 0, 0));
    sslButton.setMaximumSize(new Dimension(20, 20));
    sslButton.setMinimumSize(new Dimension(20, 20));
    sslButton.setPreferredSize(new Dimension(20, 20));
    sslButton.setText("");
    sslButton.setToolTipText("View certificate");
    sslButton.setEnabled(false);

    //
    // profile and toolbar buttons
    //
    JPanel profileAndToolbarPanel = new FixedHeightPanel();
    profileAndToolbarPanel.setLayout(new BoxLayout(profileAndToolbarPanel, BoxLayout.X_AXIS));
    profileAndToolbarPanel.add(profileSelectionCombo);
    profileAndToolbarPanel.add(Box.createHorizontalStrut(25));
    profileAndToolbarPanel.add(toolBar1);

    //
    // Path & SSLCert button
    //
    JPanel pathPanel = new FixedHeightPanel();
    pathPanel.setLayout(new BoxLayout(pathPanel, BoxLayout.X_AXIS));
    pathCombo.setAlignmentY(CENTER_ALIGNMENT);
    pathPanel.add(pathCombo);
    pathPanel.add(Box.createHorizontalStrut(5));
    sslButton.setAlignmentY(CENTER_ALIGNMENT);
    pathPanel.add(sslButton);

    //
    // Put it all together
    //
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(profileAndToolbarPanel);
    add(Box.createVerticalStrut(5));
    add(pathPanel);
    add(Box.createVerticalStrut(5));
    add(fileListScrollPane);
    setBorder(new EmptyBorder(12, 12, 12, 12));
}