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 skyc; import java.awt.Color; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; import java.io.File; import java.io.IOException; import java.util.Date; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.data.time.Day; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; /** * * @author aui12345678 */ public class ViewContent extends javax.swing.JFrame { public void saveChart(JFreeChart chart) { String fileName = "Chart.jpg"; try { /** * This utility saves the JFreeChart as a JPEG * First Parameter: FileName * Second Parameter: Chart To Save * Third Parameter: Height Of Picture * Fourth Parameter: Width Of Picture */ ChartUtilities.saveChartAsJPEG(new File(fileName), chart, 800, 600); } catch (IOException e) { e.printStackTrace(); System.err.println("Problem occurred creating chart."); } } public static String toHex(int r, int g, int b) { return toBrowserHexValue(r) + toBrowserHexValue(g) + toBrowserHexValue(b); } private static String toBrowserHexValue(int number) { StringBuilder builder = new StringBuilder(Integer.toHexString(number & 0xff)); while (builder.length() < 2) { builder.append("0"); } return builder.toString().toUpperCase(); } /** Creates new form ViewContent */ public ViewContent() throws SQLException { initComponents(); b2.setVisible(false); label1.setText(""); label2.setText(""); label3.setText(""); label4.setText(null); label11.setText(""); label22.setText(""); labbel33.setText(""); label44.setText(""); p1.setBackground(Color.WHITE); p2.setBackground(Color.WHITE); p3.setBackground(Color.WHITE); p4.setBackground(Color.WHITE); jComboBox1.addItem("Select A Location"); Statement stmt = null; Connection currentCon = null; boolean rs = false; ResultSet rs2; currentCon = ConnectionManager.getConnection(); stmt = currentCon.createStatement(); String SelectQuery = "Select DISTINCT location from pics "; try { rs2 = stmt.executeQuery(SelectQuery); while (rs2.next()) { jComboBox1.addItem(rs2.getString("location").toString()); } } catch (SQLException e2) { System.out.println("SQL error is: " + e2); } } /** 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() { label33 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); label1 = new javax.swing.JLabel(); label2 = new javax.swing.JLabel(); label3 = new javax.swing.JLabel(); label4 = new javax.swing.JLabel(); label5 = new javax.swing.JLabel(); label6 = new javax.swing.JLabel(); label7 = new javax.swing.JLabel(); jComboBox2 = new javax.swing.JComboBox(); jLabel7 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); from = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); to = new javax.swing.JTextField(); label11 = new javax.swing.JLabel(); label22 = new javax.swing.JLabel(); labbel33 = new javax.swing.JLabel(); label44 = new javax.swing.JLabel(); p3 = new javax.swing.JPanel(); p2 = new javax.swing.JPanel(); p4 = new javax.swing.JPanel(); p1 = new javax.swing.JPanel(); b2 = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("View Pictures"); label33.setBackground(new java.awt.Color(255, 255, 255)); jLabel1.setText("Select a location "); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {})); jComboBox1.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jComboBox1ItemStateChanged(evt); } }); jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); } }); jLabel3.setText("Sky color ordered:"); label1.setBackground(new java.awt.Color(255, 255, 255)); label1.setText("aaaaa"); label2.setText("bbbbb"); label3.setText("cccc"); label4.setText("dddd"); jComboBox2.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Red Opacity", "Blue Opacity", "Green Opacity" })); jLabel7.setText("Select order opacity"); jButton1.setText("Get Pictures"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jLabel4.setText("From"); jLabel5.setText("To"); label11.setText("eeee"); label22.setText("ffff"); labbel33.setText("ggggg"); label44.setText("hhhhh"); org.jdesktop.layout.GroupLayout p3Layout = new org.jdesktop.layout.GroupLayout(p3); p3.setLayout(p3Layout); p3Layout.setHorizontalGroup( p3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 41, Short.MAX_VALUE)); p3Layout.setVerticalGroup( p3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 34, Short.MAX_VALUE)); org.jdesktop.layout.GroupLayout p2Layout = new org.jdesktop.layout.GroupLayout(p2); p2.setLayout(p2Layout); p2Layout.setHorizontalGroup( p2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 41, Short.MAX_VALUE)); p2Layout.setVerticalGroup( p2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 34, Short.MAX_VALUE)); org.jdesktop.layout.GroupLayout p4Layout = new org.jdesktop.layout.GroupLayout(p4); p4.setLayout(p4Layout); p4Layout.setHorizontalGroup( p4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 41, Short.MAX_VALUE)); p4Layout.setVerticalGroup( p4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 34, Short.MAX_VALUE)); org.jdesktop.layout.GroupLayout p1Layout = new org.jdesktop.layout.GroupLayout(p1); p1.setLayout(p1Layout); p1Layout.setHorizontalGroup( p1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 41, Short.MAX_VALUE)); p1Layout.setVerticalGroup( p1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 34, Short.MAX_VALUE)); b2.setText("Genarate statistical graph "); b2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { b2ActionPerformed(evt); } }); jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/skyc/kghostview.png"))); // NOI18N jLabel6.setToolTipText(""); org.jdesktop.layout.GroupLayout label33Layout = new org.jdesktop.layout.GroupLayout(label33); label33.setLayout(label33Layout); label33Layout.setHorizontalGroup(label33Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup().add(22, 22, 22).add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup().add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup().add(16, 16, 16).add(jLabel6) .add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup() .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel2)) .add(label33Layout.createSequentialGroup().add(83, 83, 83) .add(label33Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.TRAILING) .add(label33Layout.createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel7).add(jLabel1)) .add(label33Layout.createSequentialGroup() .add(jLabel4) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(from, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap( org.jdesktop.layout.LayoutStyle.UNRELATED) .add(jLabel5))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(label33Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createParallelGroup( org.jdesktop.layout.GroupLayout.TRAILING) .add(jComboBox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(to, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .add(label33Layout.createSequentialGroup().add(142, 142, 142) .add(jButton1)))) .add(label5)).addContainerGap(168, Short.MAX_VALUE)) .add(label33Layout.createSequentialGroup().add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup().add(194, 194, 194).add(b2)) .add(org.jdesktop.layout.GroupLayout.TRAILING, label33Layout.createSequentialGroup().add(6, 6, 6).add(label33Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING) .add(label11) .add(label33Layout.createSequentialGroup().add(label1) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(label33Layout.createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup() .add(label2) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(label3).add(18, 18, 18) .add(label4)) .add(label33Layout.createSequentialGroup() .add(label22).add(18, 18, 18) .add(labbel33).add(10, 10, 10) .add(label44))))) .add(207, 207, 207)) .add(label33Layout.createSequentialGroup().add(jLabel3) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(p1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(p2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(p3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(p4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .add(label33Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(label33Layout.createSequentialGroup().add(24, 24, 24).add(label7)) .add(org.jdesktop.layout.GroupLayout.LEADING, label6))) .add(0, 0, Short.MAX_VALUE))))); label33Layout.setVerticalGroup(label33Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup().add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup() .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jLabel2)) .add(label33Layout.createSequentialGroup().add(44, 44, 44).add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(label33Layout.createSequentialGroup().add(jLabel6).add(0, 0, Short.MAX_VALUE)) .add(label33Layout.createSequentialGroup() .add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1).add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(10, 10, 10) .add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel7).add(jComboBox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(17, 17, 17) .add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4) .add(from, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel5).add(to, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(28, 28, 28).add(jButton1).addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED, 32, Short.MAX_VALUE))))) .add(18, 18, 18) .add(label33Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(label33Layout.createSequentialGroup() .add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(p2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(p1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(p3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(p4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18)) .add(label33Layout.createSequentialGroup().add(jLabel3).add(29, 29, 29))) .add(label33Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(label33Layout.createSequentialGroup() .add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(label1).add(label2).add(label3).add(label4)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(label33Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(label22).add(label11).add(labbel33).add(label44)) .add(51, 51, 51)) .add(b2)) .add(34, 34, 34).add(label5).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(label6).add(38, 38, 38).add(label7).addContainerGap(82, Short.MAX_VALUE))); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add( org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup().add(0, 0, Short.MAX_VALUE).add(label33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))); layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(label33, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); pack(); }// </editor-fold>//GEN-END:initComponents private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBox1ActionPerformed private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged // TODO add your handling code here: }//GEN-LAST:event_jComboBox1ItemStateChanged String fromstring = ""; String tostring = ""; String location = ""; String color = ""; private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: fromstring = from.getText(); tostring = to.getText(); b2.setVisible(true); location = jComboBox1.getSelectedItem().toString(); Statement stmt = null; Connection currentCon = null; boolean rs = false; ResultSet rs2; int Orderby = jComboBox2.getSelectedIndex(); if (Orderby == 0) color = "r"; else if (Orderby == 1) color = "b"; else color = "g"; currentCon = ConnectionManager.getConnection(); try { stmt = currentCon.createStatement(); } catch (SQLException ex) { Logger.getLogger(ViewContent.class.getName()).log(Level.SEVERE, null, ex); } String SelectQuery = "Select * from pics WHERE location = '" + location + "' AND date >= '" + fromstring + "' AND date <= '" + tostring + "' ORDER BY '" + color + "'"; try { rs2 = stmt.executeQuery(SelectQuery); if (rs2.next()) { String r = rs2.getString("r").toString(); String g = rs2.getString("g").toString(); String b = rs2.getString("b").toString(); String path = rs2.getString("pic_path").toString(); ImageIcon imgThisImg = new ImageIcon(path); StringTokenizer st = new StringTokenizer(r, "."); r = st.nextToken(); st = new StringTokenizer(g, "."); g = st.nextToken(); st = new StringTokenizer(b, "."); b = st.nextToken(); label1.setIcon(imgThisImg); label11.setText("r: " + r + ", g: " + g + ", b" + b); p1.setBackground(new Color(Integer.parseInt(r), Integer.parseInt(g), Integer.parseInt(b))); } if (rs2.next()) { String r = rs2.getString("r").toString(); String g = rs2.getString("g").toString(); String b = rs2.getString("b").toString(); String path = rs2.getString("pic_path").toString(); ImageIcon imgThisImg = new ImageIcon(path); StringTokenizer st = new StringTokenizer(r, "."); r = st.nextToken(); st = new StringTokenizer(g, "."); g = st.nextToken(); st = new StringTokenizer(b, "."); b = st.nextToken(); label2.setIcon(imgThisImg); label22.setText("r: " + r + ", g: " + g + ", b" + b); p2.setBackground(new Color(Integer.parseInt(r), Integer.parseInt(g), Integer.parseInt(b))); } if (rs2.next()) { String r = rs2.getString("r").toString(); String g = rs2.getString("g").toString(); String b = rs2.getString("b").toString(); String path = rs2.getString("pic_path").toString(); ImageIcon imgThisImg = new ImageIcon(path); StringTokenizer st = new StringTokenizer(r, "."); r = st.nextToken(); st = new StringTokenizer(g, "."); g = st.nextToken(); st = new StringTokenizer(b, "."); b = st.nextToken(); label3.setIcon(imgThisImg); labbel33.setText("r: " + r + ", g: " + g + ", b" + b); p3.setBackground(new Color(Integer.parseInt(r), Integer.parseInt(g), Integer.parseInt(b))); } if (rs2.next()) { String r = rs2.getString("r").toString(); String g = rs2.getString("g").toString(); String b = rs2.getString("b").toString(); String path = rs2.getString("pic_path").toString(); ImageIcon imgThisImg = new ImageIcon(path); StringTokenizer st = new StringTokenizer(r, "."); r = st.nextToken(); st = new StringTokenizer(g, "."); g = st.nextToken(); st = new StringTokenizer(b, "."); b = st.nextToken(); label4.setIcon(imgThisImg); label44.setText("r: " + r + ", g: " + g + ", b" + b); p4.setBackground(new Color(Integer.parseInt(r), Integer.parseInt(g), Integer.parseInt(b))); } } catch (SQLException e2) { System.out.println("SQL error is: " + e2); } }//GEN-LAST:event_jButton1ActionPerformed private void b2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b2ActionPerformed // TODO add your handling code here: Statement stmt = null; Connection currentCon = null; boolean rs = false; ResultSet rs2; String color; int Orderby = jComboBox2.getSelectedIndex(); if (Orderby == 0) color = "r"; else if (Orderby == 1) color = "b"; else color = "g"; TimeSeries series = new TimeSeries("", Day.class); currentCon = ConnectionManager.getConnection(); try { stmt = currentCon.createStatement(); } catch (SQLException ex) { Logger.getLogger(ViewContent.class.getName()).log(Level.SEVERE, null, ex); } String SelectQuery = "Select * from pics WHERE location = '" + location + "' AND date >= '" + fromstring + "' AND date <= '" + tostring + "' ORDER BY '" + color + "'"; try { rs2 = stmt.executeQuery(SelectQuery); int i = 10; while (rs2.next()) { String r = rs2.getString("r").toString(); String g = rs2.getString("g").toString(); String b = rs2.getString("b").toString(); String path = rs2.getString("pic_path").toString(); ImageIcon imgThisImg = new ImageIcon(path); StringTokenizer st = new StringTokenizer(r, "."); r = st.nextToken(); st = new StringTokenizer(g, "."); g = st.nextToken(); st = new StringTokenizer(b, "."); b = st.nextToken(); series.add(new Day(new Date("2015/04/" + i)), Integer.parseInt(b)); i++; // p1.setBackground(new Color(Integer.parseInt(r),Integer.parseInt(g),Integer.parseInt(b)) ); } } catch (SQLException e2) { System.out.println("SQL error is: " + e2); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart("Change of sky color", // Title "Day", // X-Axis label "Ratio", // Y-Axis label dataset, // Dataset true, // Show legend true, //tooltips false //url ); saveChart(chart); gr h = new gr(); h.setVisible(true); }//GEN-LAST:event_b2ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(ViewContent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ViewContent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ViewContent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ViewContent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { new ViewContent().setVisible(true); } catch (SQLException ex) { Logger.getLogger(ViewContent.class.getName()).log(Level.SEVERE, null, ex); } } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton b2; private javax.swing.JTextField from; private javax.swing.JButton jButton1; private javax.swing.JComboBox jComboBox1; private javax.swing.JComboBox jComboBox2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JPanel jPanel1; private javax.swing.JLabel labbel33; private javax.swing.JLabel label1; private javax.swing.JLabel label11; private javax.swing.JLabel label2; private javax.swing.JLabel label22; private javax.swing.JLabel label3; private javax.swing.JPanel label33; private javax.swing.JLabel label4; private javax.swing.JLabel label44; private javax.swing.JLabel label5; private javax.swing.JLabel label6; private javax.swing.JLabel label7; private javax.swing.JPanel p1; private javax.swing.JPanel p2; private javax.swing.JPanel p3; private javax.swing.JPanel p4; private javax.swing.JTextField to; // End of variables declaration//GEN-END:variables }