Example usage for javax.swing JToolBar JToolBar

List of usage examples for javax.swing JToolBar JToolBar

Introduction

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

Prototype

public JToolBar() 

Source Link

Document

Creates a new tool bar; orientation defaults to HORIZONTAL.

Usage

From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Constructor//w ww .j  a v a2  s  .  co  m
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public VOCTAdditionalInfoPanel(boolean compactLayout) {
    super(new BorderLayout());

    EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this);

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    // if (false) {
    // messageText = new JTextField();
    // ((JTextField) messageText).addActionListener(this);
    // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    //
    // } else {
    messageText = new JTextArea();
    JScrollPane scrollPane2 = new JScrollPane(messageText);
    scrollPane2.setPreferredSize(new Dimension(100, 50));
    scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    // }

    // Add buttons
    // ButtonGroup group = new ButtonGroup();

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));

    }

    if (compactLayout) {
        addBtn = new JButton("Add to Log");
        sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    // addBtn.setEnabled(false);
    // messageText.setEditable(false);
    addBtn.addActionListener(this);
}

From source file:fr.crnan.videso3d.ihm.PLNSPanel.java

private JToolBar createToolbar() {
    JToolBar toolbar = new JToolBar();

    JButton newGraph = new JButton("Nouveau");
    newGraph.addActionListener(new ActionListener() {

        @Override//from ww w .  j a v  a2  s. c o  m
        public void actionPerformed(ActionEvent e) {
            PLNSChartCreateUI chartCreator = new PLNSChartCreateUI(PLNSPanel.this);
            JFreeChart chart = null;
            try {
                if (chartCreator.showDialog(PLNSPanel.this)) {
                    switch (chartCreator.getChartType()) {
                    case 0://XY
                        JDBCXYDataset dataset = new JDBCXYDataset(plnsAnalyzer.getConnection());
                        dataset.executeQuery(chartCreator.getRequest());
                        chart = ChartFactory.createXYAreaChart(chartCreator.getChartTitle(),
                                chartCreator.getAbscissesTitle(), chartCreator.getOrdonneesTitle(), dataset,
                                PlotOrientation.VERTICAL, false, true, false);
                        break;
                    case 1://Pie
                        JDBCPieDataset dataset1 = new JDBCPieDataset(plnsAnalyzer.getConnection());
                        dataset1.executeQuery(chartCreator.getRequest());
                        chart = ChartFactory.createPieChart3D(chartCreator.getChartTitle(), dataset1, false,
                                true, false);
                        break;
                    case 2://Category
                        JDBCCategoryDataset dataset2 = new JDBCCategoryDataset(plnsAnalyzer.getConnection());
                        dataset2.executeQuery(chartCreator.getRequest());
                        chart = ChartFactory.createBarChart(chartCreator.getChartTitle(),
                                chartCreator.getAbscissesTitle(), chartCreator.getOrdonneesTitle(), dataset2,
                                PlotOrientation.VERTICAL, false, true, false);
                        break;
                    default:
                        break;
                    }
                }
            } catch (SQLException e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(PLNSPanel.this,
                        "<html>L'excution de la requte a chou :<br />" + e1 + "</html>",
                        "Impossible de crer le graphique", JOptionPane.ERROR_MESSAGE);
            }
            if (chart != null)
                addChart(chart);

        }
    });

    toolbar.add(newGraph);

    JButton retile = new JButton("Rarranger");
    retile.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            desktop.tile(true);
        }
    });
    toolbar.add(retile);

    return toolbar;
}

From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java

/**
 * @return/*from  ww  w. j  a  v a 2 s  . co m*/
 */
private Component createContentPanel() {
    JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
    scriptEditorTA = new RSyntaxTextArea();
    setSyntaxStyle();
    RTextScrollPane sp = new RTextScrollPane(scriptEditorTA);
    pane.setTopComponent(sp);

    JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JPanel panel = new JPanel(new BorderLayout());
    output = new TextAreaOutputLogger(scrollPane, INITIAL_OUTPUT_CONTENT);
    output.setEditable(false);
    output.setAutoscrolls(true);
    output.setScrollContent(true);
    output.setWrapStyleWord(true);
    scrollPane.setViewportView(output);

    JToolBar toolBar = new JToolBar();
    JButton clearBT = new JButton("Clear");
    clearBT.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            output.setText(INITIAL_OUTPUT_CONTENT);
        }
    });

    final JCheckBox scrollCB = new JCheckBox("Auto Scroll Content");
    scrollCB.setSelected(true);
    scrollCB.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            output.setScrollContent(scrollCB.isSelected());
        }
    });
    toolBar.add(clearBT);
    toolBar.add(scrollCB);

    panel.add(toolBar, BorderLayout.NORTH);
    panel.add(scrollPane, BorderLayout.CENTER);

    pane.setBottomComponent(panel);
    pane.setDividerLocation(300);
    return pane;
}

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

/**
 * a function to initialize the components for this panel
 *//*from   w w w .j  a va 2s  . c  o  m*/
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:edu.ucla.stat.SOCR.analyses.gui.SimpleLinearRegression.java

/**Initialize the Analysis*/
public void init() {

    showInput = false;//from   www. j  av a2 s  . com
    showSelect = false;
    showVisualize = false;
    super.init();

    analysisType = AnalysisType.SIMPLE_LINEAR_REGRESSION;

    //////System.out.println("SLR analysisType = " + analysisType);
    useInputExample = false;
    useLocalExample = false;
    useRandomExample = true;
    useServerExample = false;
    useStaticExample = SimpleLinearRegressionExamples.availableExamples;
    useGraph = true;

    onlineDescription = "http://en.wikipedia.org/wiki/Linear_regression";
    depMax = 1; // max number of dependent var
    indMax = 1; // max number of independent var
    resultPanelTextArea.setFont(new Font(outputFontFace, Font.BOLD, outputFontSize));
    frame = getFrame(this);
    setName("Regression & Correlation Analysis");
    // Create the toolBar
    toolBar = new JToolBar();
    createActionComponents(toolBar);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);

    chartFactory = new Chart();
    resetGraph();
    validate();
    //      reset();
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private Component createToolBar() {
    JToolBar result = new JToolBar();
    result.setFloatable(false);//from  w  w  w.  j  a  v a2 s.  c  o  m

    result.add(RANDOM_DATA.toAction(chart)).setIcon(FontAwesome.FA_RANDOM.getIcon(getForeground(), 16f));

    JComboBox<RendererType> types = new JComboBox<>(
            support.getSupportedRendererTypes().toArray(new RendererType[0]));
    types.setMaximumSize(new Dimension(150, 100));
    types.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            RendererType type = (RendererType) e.getItem();
            chart.getXYPlot().setRenderer(support.createRenderer(type));
            chart.getXYPlot().setBackgroundPaint(support.getPlotColor());
            chart.setBackgroundPaint(colorSchemeSupport.getBackColor());
        }
    });
    types.setSelectedIndex(1);
    result.add(types);

    return result;
}

From source file:lab4.YouQuiz.java

private void switchToQuizMode() {

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);//from  w  ww. ja  va2s  .  c o m

    backButton.setFocusable(false);
    toolbar.add(backButton);
    toolbar.setAlignmentX(0);

    backButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            contentPanel.setQuestion(questionsArray.get(--questionIndex));
            forwardButton.setEnabled(true);

            if (questionIndex - 1 < 0) {
                backButton.setEnabled(false);
            }

            updateAnswerForm();
        }
    });

    forwardButton.setFocusable(false);
    toolbar.add(forwardButton);
    toolbar.setAlignmentX(0);

    forwardButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            contentPanel.setQuestion(questionsArray.get(++questionIndex));
            backButton.setEnabled(true);

            if (questionsArray.size() == questionIndex + 1) {
                forwardButton.setEnabled(false);
            }

            updateAnswerForm();
        }
    });

    speakButton.setFocusable(false);
    toolbar.add(speakButton);
    toolbar.setAlignmentX(0);

    speakButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            Audio audio = Audio.getInstance();
            InputStream sound = null;
            try {
                sound = audio.getAudio(questionsArray.get(questionIndex).getQuestion(), Language.ENGLISH);
            } catch (IOException ex) {
                Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {
                audio.play(sound);
            } catch (JavaLayerException ex) {
                Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    refreshButton.setFocusable(false);
    toolbar.add(refreshButton);
    toolbar.setAlignmentX(0);

    refreshButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            shuffleQuestions();
            questionIndex = 0;
            backButton.setEnabled(false);

            if (questionsArray.size() == 1) {
                forwardButton.setEnabled(false);
            } else {
                forwardButton.setEnabled(true);
            }

            contentPanel.setQuestion(questionsArray.get(questionIndex));
            updateAnswerForm();
        }
    });

    micButton.setFocusable(false);
    toolbar.add(micButton);
    toolbar.setAlignmentX(0);

    micButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {

            GSpeechDuplex dup = new GSpeechDuplex();
            dup.addResponseListener(new GSpeechResponseListener() {
                @Override
                public void onResponse(GoogleResponse gr) {
                    if (questionsArray.get(questionIndex).checkAnswer(gr.getResponse())) {
                        JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null,
                                "Oops! '" + gr.getResponse() + "' is a wrong Answer. Its '"
                                        + questionsArray.get(questionIndex).getAnswer().get(0) + "'",
                                "Sorry", JOptionPane.ERROR_MESSAGE);
                    }
                }
            });

            Microphone mic = new Microphone(FLACFileWriter.FLAC);
            File file = new File("CRAudioTest.flac");

            try {
                mic.captureAudioToFile(file);
                Thread.sleep(5000);
                mic.close();

                byte[] data = Files.readAllBytes(mic.getAudioFile().toPath());
                dup.recognize(data, (int) mic.getAudioFormat().getSampleRate());
                mic.getAudioFile().delete();

            } catch (LineUnavailableException | InterruptedException | IOException ex) {
            }

        }
    });

    contentPanel = new ContentPanel();

    contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    contentPanel.add(toolbar, BorderLayout.NORTH);
    contentPanel.add(Box.createRigidArea(new Dimension(0, 50)));
    contentPanel.add(contentPanel.questionLabel);

    add(contentPanel, BorderLayout.CENTER);

    if (questionsArray.isEmpty()) {
        refreshButton.setEnabled(false);
        backButton.setEnabled(false);
        forwardButton.setEnabled(false);
        speakButton.setEnabled(false);
    } else {
        questionIndex = 0;
        backButton.setEnabled(false);

        if (questionsArray.size() == 1) {
            forwardButton.setEnabled(false);
        }

        contentPanel.setQuestion(questionsArray.get(questionIndex));
        contentPanel.add(Box.createRigidArea(new Dimension(0, 20)));
        contentPanel.add(contentPanel.answerPanel);
        contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
        contentPanel.add(contentPanel.checkButton);
        updateAnswerForm();
    }

}

From source file:edu.ucla.stat.SOCR.analyses.gui.PrincipalComponentAnalysis.java

/**Initialize the Analysis*/
public void init() {
    mapIndep = false;/*from ww w .j  a v a 2 s.c  o m*/
    showMapping = false; // added
    showDendro = false; // added: only for Clustering
    showGraph = true;
    showPCA = true;

    showInput = false;
    showSelect = false;
    showVisualize = false;
    super.init();

    analysisType = AnalysisType.PRINCIPAL_COMPONENT_ANALYSIS;
    useInputExample = false;
    useLocalExample = false;
    useRandomExample = false;
    useServerExample = false;

    useStaticExample = ClusteringExamples.availableExamples;

    onlineDescription = "http://en.wikipedia.org/wiki/Logistic_regression";
    depMax = 1; // max number of dependent var
    indMax = 15; // max number of independent var
    resultPanelTextArea.setFont(new Font(outputFontFace, Font.BOLD, outputFontSize));
    frame = getFrame(this);
    setName("Regression & Correlation Analysis");
    // Create the toolBar
    toolBar = new JToolBar();
    createActionComponents(toolBar);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);

    setPCADataPanel();

    // use the new JFreeChar function. annie che 20060312

    chartFactory = new Chart();
    resetGraph();
    validate();
}

From source file:com.apatar.ui.Actions.java

private void createToolbar() {
    toolbar = new JToolBar();
}

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

public void init() {

    sliderPanel = new JPanel();

    // ValueSetter(String title, int type int min, int max, int initial,boolean minimumRange10) 
    powerSlider = new edu.ucla.stat.SOCR.util.FloatSlider("Power", 1.0, -10.0, 10.0);
    powerSlider.setPreferredSize(new Dimension(CHART_SIZE_X / 2 + 150, 80));
    powerSlider.addObserver(this);
    powerSlider.setToolTipText("Slider for adjusting the value of power.");
    sliderPanel.add(this.powerSlider);

    mapDep = false;//from   w  ww  . j ava  2 s.  co  m
    LEGEND_SWITCH = false;

    super.init();

    indLabel = new JLabel("X");
    depLabel = new JLabel("Y");

    toolBar = new JToolBar();
    createActionComponents(toolBar);
    JPanel toolBarContainer = new JPanel();
    toolBarContainer.add(toolBar);
    JSplitPane toolContainer = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolBarContainer,
            new JScrollPane(sliderPanel));
    toolContainer.setContinuousLayout(true);
    toolContainer.setDividerLocation(0.6);
    this.getContentPane().add(toolContainer, BorderLayout.NORTH);

    depMax = 10; // max number of dependent var
    indMax = 10; // max number of independent var

}