Example usage for javax.swing JButton add

List of usage examples for javax.swing JButton add

Introduction

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

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:Interface.Teste.java

public void criacao() {
    DefaultCategoryDataset ds = new DefaultCategoryDataset();
    ds.addValue(40.5, "maximo", "dia 1");
    ds.addValue(38.2, "maximo", "dia 2");
    ds.addValue(37.3, "maximo", "dia 3");
    ds.addValue(31.5, "maximo", "dia 4");
    ds.addValue(35.7, "maximo", "dia 5");
    ds.addValue(42.5, "maximo", "dia 6");

    // cria o grfico
    JFreeChart grafico = ChartFactory.createLineChart("Meu Grafico", "Dia", "Valor", ds,
            PlotOrientation.VERTICAL, true, true, false);
    try {/*from ww  w.j a v  a 2 s  .co m*/
        OutputStream arquivo = new FileOutputStream("grafico.png");
        ChartUtilities.writeChartAsPNG(arquivo, grafico, 550, 400);
        arquivo.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    JPopupMenu pop = new JPopupMenu();
    pop.add(new JMenuItem("1"));
    pop.add(new JMenuItem("2"));
    pop.add(new JMenuItem("3"));
    pop.add(new JMenuItem("4"));
    JPanel painel = new JPanel();
    JButton botao = new JButton("teste");
    JCalendar cal = new JCalendar();
    botao.add(pop);
    painel.add(cal);
    painel.add(new ChartPanel(grafico));
    //Calendar c = cal.getDate();
    Date data = cal.getDate();
    int dia = data.getDay();
    System.out.println("" + dia);

    add(painel);
}

From source file:JXTransformer.java

private JPanel createStressTestPanel() {
        JPanel panel = new JPanel();
        TitledBorder titledBorder = BorderFactory.createTitledBorder("Stress test (with tooltips)");
        titledBorder.setTitleJustification(TitledBorder.CENTER);
        panel.setBorder(titledBorder);// w w  w  .java  2  s.  com
        JButton lowerButton = new JButton("Button");
        lowerButton.setLayout(new FlowLayout());
        lowerButton.setToolTipText("Lower button");
        JButton middleButton = new JButton();
        middleButton.setToolTipText("Middle button");
        middleButton.setLayout(new FlowLayout());
        lowerButton.add(middleButton);
        JButton upperButton = new JButton("Upper button");
        upperButton.setToolTipText("Upper button");
        middleButton.add(upperButton);
        panel.add(createTransformer(lowerButton));
        return panel;
    }