Java tutorial
package GUI; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Stroke; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; /* * 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. */ /** * * @author Julliana */ public class TelaPrincipal extends javax.swing.JFrame { /** * Creates new form j */ public TelaPrincipal() { initComponents(); //getContentPane().setBackground(Color.white); this.setSize(800, 500);//1333, 650 / 700,400 this.setLocationRelativeTo(null); } /** * 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() { buttonGroup1 = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); rbPorSemestre = new javax.swing.JRadioButton(); comboDisciplinas1 = new javax.swing.JComboBox(); comboDisciplinas2 = new javax.swing.JComboBox(); botaoConsultar = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); rbPorDisciplina = new javax.swing.JRadioButton(); rbMedia = new javax.swing.JRadioButton(); jLabel2 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); buttonGroup1.add(rbPorSemestre); rbPorSemestre.setText("Por Semestre"); comboDisciplinas1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1- IMD0019 - RESOLUO DE PROBLEMAS MATEM?TICOS PARA TI ", "2- IMD0017 - PR?TICAS DE LEITURA E ESCRITA EM PORTUGUS I", "3- IMD0028 - FUNDAMENTOS MATEM?TICOS DA COMPUTAO I ", "4- IMD0012 - INTRODUO S TCNICAS DE PROGRAMAO", "5- IMD0029 - ESTRUTURA DE DADOS B?SICAS I ", "6- IMD0030 - LINGUAGEM DE PROGRAMAO I " })); comboDisciplinas1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { comboDisciplinas1ActionPerformed(evt); } }); comboDisciplinas2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1- IMD0024 - C?LCULO DIFERENCIAL E INTEGRAL I ", "2- IMD0027 - PR?TICAS DE LEITURA E ESCRITA EM PORTUGUS II", "3-IMD0038 - FUNDAMENTOS MATEM?TICOS DA COMPUTAO II", "4- IMD0030 - LINGUAGEM DE PROGRAMAO I ", "5- IMD0039 - ESTRUTURAS DE DADOS B?SICAS II ", "6- IMD0040 - LINGUAGEM DE PROGRAMAO II" })); botaoConsultar.setText("Consultar"); botaoConsultar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { botaoConsultarActionPerformed(evt); } }); jLabel1.setText("DiamondV| Copyright 2015 v 1.0"); buttonGroup1.add(rbPorDisciplina); rbPorDisciplina.setText("Por Disciplina"); rbPorDisciplina.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rbPorDisciplinaActionPerformed(evt); } }); rbMedia.setText("Mdias"); jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel2.setText("Grficos"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(341, 341, 341).addComponent(botaoConsultar) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(170, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(279, 279, 279)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout .createSequentialGroup() .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(rbPorSemestre).addComponent(rbPorDisciplina) .addGroup(jPanel1Layout.createSequentialGroup().addGap(17, 17, 17) .addComponent(jLabel2)) .addComponent(rbMedia)) .addGap(91, 91, 91) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(comboDisciplinas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(comboDisciplinas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(66, 66, 66))))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(118, 118, 118) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(comboDisciplinas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(21, 21, 21).addComponent( comboDisciplinas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rbPorSemestre) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rbPorDisciplina))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(rbMedia) .addGap(58, 58, 58).addComponent(botaoConsultar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE) .addComponent(jLabel1).addContainerGap())); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); pack(); }// </editor-fold>//GEN-END:initComponents private void comboDisciplinas1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDisciplinas1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_comboDisciplinas1ActionPerformed private void botaoConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoConsultarActionPerformed DefaultCategoryDataset barChartData = new DefaultCategoryDataset(); barChartData.setValue(20000, "Contribution", "JANUARY"); barChartData.setValue(15000, "Contribution", "FEBRUARY"); barChartData.setValue(30000, "Contribution", "MARCH"); JFreeChart barChart = ChartFactory.createBarChart("Church", "Monthly", "Contribution", barChartData, PlotOrientation.VERTICAL, false, true, false); CategoryPlot barchrt = barChart.getCategoryPlot(); barchrt.setRangeGridlinePaint(Color.PINK); barchrt.setBackgroundPaint(Color.WHITE); ChartFrame frame = new ChartFrame("Lala", barChart); frame.setVisible(true); frame.setSize(800, 500); }//GEN-LAST:event_botaoConsultarActionPerformed private void rbPorDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbPorDisciplinaActionPerformed // TODO add your handling code here: }//GEN-LAST:event_rbPorDisciplinaActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TelaPrincipal().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton botaoConsultar; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JComboBox comboDisciplinas1; private javax.swing.JComboBox comboDisciplinas2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JRadioButton rbMedia; private javax.swing.JRadioButton rbPorDisciplina; private javax.swing.JRadioButton rbPorSemestre; // End of variables declaration//GEN-END:variables }