Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.ec.vistas; import javax.swing.JOptionPane; import org.jfree.chart.*; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.general.DefaultPieDataset; /** * * @author Toshiba */ public class Dashboard extends javax.swing.JInternalFrame { /** * Creates new form Dashboard */ public Dashboard() { initComponents(); this.Vivienda.setVisible(false); ChartPanel panel; JFreeChart chart; DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Categra 1", 43.2); data.setValue("Categra 2", 27.9); data.setValue("Categra 3", 79.5); /*chart=ChartFactory.createPieChart("Grafico1", data, true, true, true); panel = new ChartPanel(chart); panel.setBounds(5,10,50,60); pastel.add(panel); pastel.repaint();*/ chart = ChartFactory.createPieChart("Ejemplo de JFreeChart", //Ttrulo del grfico data, true, //Leyenda true, //ToolTips true); panel = new ChartPanel(chart); panel.setBounds(5, 10, 50, 60); Alimento.add(panel); Alimento.repaint(); //Creamos una especie de frame y mostramos el JFreeChart en l //Este constructor nos pide el ttulo del Chart y el chart creado //ChartFrame frame=new ChartFrame("Primer Chart para javax0711",chart); //frame.pack(); //frame.setVisible(true); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { Vivienda = new javax.swing.JPanel(); Alimento = new javax.swing.JPanel(); javax.swing.GroupLayout ViviendaLayout = new javax.swing.GroupLayout(Vivienda); Vivienda.setLayout(ViviendaLayout); ViviendaLayout.setHorizontalGroup(ViviendaLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 254, Short.MAX_VALUE)); ViviendaLayout.setVerticalGroup(ViviendaLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 125, Short.MAX_VALUE)); javax.swing.GroupLayout AlimentoLayout = new javax.swing.GroupLayout(Alimento); Alimento.setLayout(AlimentoLayout); AlimentoLayout.setHorizontalGroup(AlimentoLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 266, Short.MAX_VALUE)); AlimentoLayout.setVerticalGroup(AlimentoLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(Vivienda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(54, 54, 54).addComponent(Alimento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(Vivienda, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(Alimento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(0, 453, Short.MAX_VALUE))); pack(); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel Alimento; private javax.swing.JPanel Vivienda; // End of variables declaration//GEN-END:variables }