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:net.nosleep.superanalyzer.panels.HomePanel.java

public JPanel createRightButtonBarPanel(final PieRotator rotator) {
    URL url = this.getClass().getResource("/media/" + "ButtonPlay.png");
    final ImageIcon playIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    url = this.getClass().getResource("/media/" + "ButtonPause.png");
    final ImageIcon pauseIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    final JButton button = new JButton(playIcon);
    button.setBorder(null);/* w  ww  .  j a  v  a  2 s .  c o  m*/
    button.setBorderPainted(false);
    button.setText(null);
    button.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (rotator.isRunning() == false) {
                rotator.start();
                button.setIcon(pauseIcon);
            } else {
                rotator.stop();
                button.setIcon(playIcon);
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setBackground(Color.white);
    toolBar.add(button);

    JPanel barPanel = new JPanel(new BorderLayout());
    barPanel.setBackground(Color.white);
    barPanel.add(toolBar, BorderLayout.SOUTH);

    return barPanel;
}

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.WsdlTestRequestDesktopPanel.java

protected void insertButtons(JToolBar toolbar) {
    toolbar.add(addAssertionButton);
}

From source file:ToolBarDemo2.java

protected void addButtons(JToolBar toolBar) {
    JButton button = null;//from w w  w. jav  a2 s . c  om

    //first button
    button = makeNavigationButton("Back24", PREVIOUS, "Back to previous something-or-other", "Previous");
    toolBar.add(button);

    //second button
    button = makeNavigationButton("Up24", UP, "Up to something-or-other", "Up");
    toolBar.add(button);

    //third button
    button = makeNavigationButton("Forward24", NEXT, "Forward to something-or-other", "Next");
    toolBar.add(button);

    //separator
    toolBar.addSeparator();

    //fourth button
    button = new JButton("Another button");
    button.setActionCommand(SOMETHING_ELSE);
    button.setToolTipText("Something else");
    button.addActionListener(this);
    toolBar.add(button);

    //fifth component is NOT a button!
    JTextField textField = new JTextField("A text field");
    textField.setColumns(10);
    textField.addActionListener(this);
    textField.setActionCommand(TEXT_ENTERED);
    toolBar.add(textField);
}

From source file:mulavito.samples.GraphAlgorithmDemo.java

public GraphAlgorithmDemo() {
    super("MuLaViTo Algorithms Demo");

    // Set the frame icon.
    ImageIcon icon = Resources.getIconByName("/img/mulavito-logo.png");
    if (icon != null)
        setIconImage(icon.getImage());/* ww  w. ja  v  a2s.c  om*/

    // Create toolbar.
    JToolBar toolbar = new JToolBar();
    getToolBarPane().add(toolbar);

    JButton btn;

    btn = new JButton("New Graph");
    btn.setActionCommand("graph");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Auto Size");
    btn.setActionCommand("autosize");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Eppstein");
    btn.setActionCommand("eppstein");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Yen");
    btn.setActionCommand("yen");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Suurballe-Tarjan");
    btn.setActionCommand("suurballe-tarjan");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("About");
    btn.setActionCommand("about");
    btn.addActionListener(this);
    toolbar.add(btn);

    normalOutput("Welcome to MuLaViTo demonstrator.\n");
    debugOutput("Click on \"New Graph\" to create a new graph.\n");
    warnOutput("Click Eppstein, Yen, or Suurballe-Tarjan to randomly "
            + "select source and destination and run the algorithm\n");
    notifyOutput("Have fun!!!\n");

    setPreferredSize(new Dimension(500, 600));
    setMinimumSize(new Dimension(500, 600));
    setVisible(true);
}

From source file:TopLevelTransferHandlerDemo.java

private JToolBar createDummyToolBar() {
    JToolBar tb = new JToolBar();
    JButton b;//from   www.  ja va  2s.  c o  m
    b = new JButton("New");
    b.setRequestFocusEnabled(false);
    tb.add(b);
    b = new JButton("Open");
    b.setRequestFocusEnabled(false);
    tb.add(b);
    b = new JButton("Save");
    b.setRequestFocusEnabled(false);
    tb.add(b);
    b = new JButton("Print");
    b.setRequestFocusEnabled(false);
    tb.add(b);
    b = new JButton("Preview");
    b.setRequestFocusEnabled(false);
    tb.add(b);
    tb.setFloatable(false);
    return tb;
}

From source file:org.jax.bham.test.HaplotypeAssociationTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 *//*  ww  w. jav  a  2s.  co  m*/
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities
            .toIntegerList(this.testToPlot.getHaplotypeDataSource().getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                HaplotypeAssociationTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}

From source file:org.jax.bham.test.MultiHaplotypeBlockTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 *///from w  w w  .  j a  v a2  s .  com
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities.toIntegerList(this.testToPlot.getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                MultiHaplotypeBlockTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}

From source file:org.jax.bham.test.PhylogenyAssociationTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 *///  w  w  w.j  a  v  a2s . com
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities
            .toIntegerList(this.testToPlot.getPhylogenyDataSource().getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                PhylogenyAssociationTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}

From source file:be.nbb.demetra.dfm.DfmExecViewTopComponent.java

@Override
public JComponent getToolbarRepresentation() {
    JToolBar toolBar = NbComponents.newInnerToolbar();
    toolBar.addSeparator();/*from   w w w .j a v a 2  s .  co m*/
    toolBar.add(Box.createRigidArea(new Dimension(5, 0)));

    JToggleButton startStop = (JToggleButton) toolBar
            .add(new JToggleButton(StartStopCommand.INSTANCE.toAction(this)));
    startStop.setIcon(DemetraUiIcon.COMPILE_16);
    startStop.setDisabledIcon(createDisabledIcon(startStop.getIcon()));
    startStop.setToolTipText("Start/Stop");

    JButton edit = toolBar.add(EditSpecCommand.INSTANCE.toAction(this));
    edit.setIcon(DemetraUiIcon.PREFERENCES);
    edit.setDisabledIcon(createDisabledIcon(edit.getIcon()));
    edit.setToolTipText("Specification");

    JButton clear = toolBar.add(ClearCommand.INSTANCE.toAction(this));
    clear.setIcon(DemetraUiIcon.EDIT_CLEAR_16);
    clear.setDisabledIcon(createDisabledIcon(clear.getIcon()));
    clear.setToolTipText("Clear");

    SwingColorSchemeSupport colorSchemeSupport = SwingColorSchemeSupport
            .from(DemetraUI.getInstance().getColorScheme());
    sparkline = (ChartPanel) toolBar
            .add(Charts.avoidScaling(new ChartPanel(Charts.createSparkLineChart(null))));
    sparkline.setPreferredSize(new Dimension(150, 16));
    sparkline.setMaximumSize(new Dimension(150, 16));
    sparkline.getChart().getXYPlot().setDataset(dataset);
    sparkline.getChart().getXYPlot().getRenderer()
            .setBasePaint(colorSchemeSupport.getLineColor(ColorScheme.KnownColor.GREEN));
    sparkline.setBackground(colorSchemeSupport.getPlotColor());
    sparkline.setBorder(BorderFactory.createLineBorder(colorSchemeSupport.getGridColor()));
    sparkline.setToolTipText("loglikelihood");

    return toolBar;
}

From source file:misc.ActionDemo.java

public void createToolBar() {
    JButton button = null;//www.j  a  va2 s.  co  m

    //Create the toolbar.
    JToolBar toolBar = new JToolBar();
    add(toolBar, BorderLayout.PAGE_START);

    //first button
    button = new JButton(leftAction);
    if (button.getIcon() != null) {
        button.setText(""); //an icon-only button
    }
    toolBar.add(button);

    //second button
    button = new JButton(middleAction);
    if (button.getIcon() != null) {
        button.setText(""); //an icon-only button
    }
    toolBar.add(button);

    //third button
    button = new JButton(rightAction);
    if (button.getIcon() != null) {
        button.setText(""); //an icon-only button
    }
    toolBar.add(button);
}