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 muh; import java.awt.Color; import javax.swing.ImageIcon; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; /** * * @author Merve */ public class avagadroYasasi extends javax.swing.JFrame { /** * Creates new form kutle */ public avagadroYasasi() { initComponents(); ImageIcon ikon0 = new ImageIcon("C:\\\\Users\\\\serenn\\\\Desktop\\\\images\\cancel-icon.png"); jButton2.setIcon(ikon0); ImageIcon ikon1 = new ImageIcon("C:\\\\Users\\\\serenn\\\\Desktop\\\\images\\Button-Help-icon.png"); jButton1.setIcon(ikon1); } /** * 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() { jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jPanel1 = new javax.swing.JPanel(); jTextField2 = new javax.swing.JTextField(); jTextField3 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jComboBox8 = new javax.swing.JComboBox(); jTextField6 = new javax.swing.JTextField(); jComboBox7 = new javax.swing.JComboBox(); jComboBox3 = new javax.swing.JComboBox(); jComboBox6 = new javax.swing.JComboBox(); jTextField5 = new javax.swing.JTextField(); jLabel10 = new javax.swing.JLabel(); jButton3 = new javax.swing.JButton(); jLabel9 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jComboBox5 = new javax.swing.JComboBox(); jLabel7 = new javax.swing.JLabel(); jTextField4 = new javax.swing.JTextField(); jTextField1 = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jComboBox4 = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jTextField8 = new javax.swing.JTextField(); jTextField7 = new javax.swing.JTextField(); jLabel11 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); setTitle("Avagadro Yasas"); jPanel1.setPreferredSize(new java.awt.Dimension(569, 395)); jPanel1.setLayout(null); jTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField2ActionPerformed(evt); } }); jPanel1.add(jTextField2); jTextField2.setBounds(220, 20, 88, 22); jTextField3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField3ActionPerformed(evt); } }); jPanel1.add(jTextField3); jTextField3.setBounds(220, 60, 88, 22); jButton1.setText("HESAPLA"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel1.add(jButton1); jButton1.setBounds(450, 30, 90, 40); jLabel4.setFont(new java.awt.Font("Tahoma", 2, 18)); // NOI18N jLabel4.setText("Avagadro Yasasna Gre;"); jPanel1.add(jLabel4); jLabel4.setBounds(460, 130, 230, 22); jLabel5.setBackground(new java.awt.Color(255, 255, 255)); jPanel1.add(jLabel5); jLabel5.setBounds(430, 310, 180, 40); jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel3.setText("Sonraki Hacim Deeri :"); jPanel1.add(jLabel3); jLabel3.setBounds(20, 180, 190, 22); jComboBox8.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "(K) Kelvin ", "(C) Celsius", "(F) Fahrenheit ", " " })); jComboBox8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox8ActionPerformed(evt); } }); jPanel1.add(jComboBox8); jComboBox8.setBounds(320, 100, 110, 22); jPanel1.add(jTextField6); jTextField6.setBounds(220, 220, 90, 22); jComboBox7.setModel( new javax.swing.DefaultComboBoxModel(new String[] { "(V) - m3", "(V) - dm3", "(V) - cm3" })); jPanel1.add(jComboBox7); jComboBox7.setBounds(320, 180, 110, 20); jComboBox3.setModel( new javax.swing.DefaultComboBoxModel(new String[] { "(V) - m3", "(V) - dm3", "(V) - cm3" })); jPanel1.add(jComboBox3); jComboBox3.setBounds(320, 60, 110, 20); jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "(P) - paskal ", " " })); jComboBox6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox6ActionPerformed(evt); } }); jPanel1.add(jComboBox6); jComboBox6.setBounds(320, 20, 110, 22); jPanel1.add(jTextField5); jTextField5.setBounds(220, 180, 90, 22); jLabel10.setFont(new java.awt.Font("Tahoma", 3, 10)); // NOI18N jLabel10.setText("Amedeo Avogadro"); jPanel1.add(jLabel10); jLabel10.setBounds(560, 350, 190, 20); jButton3.setBackground(new java.awt.Color(255, 255, 255)); jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/muh/images/aaa.png"))); // NOI18N jButton3.setText("Grafikte Gster"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel1.add(jButton3); jButton3.setBounds(490, 80, 130, 50); jLabel9.setBackground(new java.awt.Color(153, 204, 0)); jLabel9.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel9.setText("Sonraki Basn Deeri :"); jPanel1.add(jLabel9); jLabel9.setBounds(20, 140, 190, 30); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jPanel1.add(jLabel6); jLabel6.setBounds(470, 170, 160, 30); jComboBox5.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "(K) Kelvin ", "(C) Celsius", "(F) Fahrenheit ", " " })); jComboBox5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox5ActionPerformed(evt); } }); jPanel1.add(jComboBox5); jComboBox5.setBounds(320, 220, 110, 22); jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel7.setText("nceki Scaklk Deeri :"); jPanel1.add(jLabel7); jLabel7.setBounds(20, 100, 190, 22); jTextField4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField4ActionPerformed(evt); } }); jPanel1.add(jTextField4); jTextField4.setBounds(220, 100, 88, 22); jTextField1.setToolTipText(""); jPanel1.add(jTextField1); jTextField1.setBounds(220, 140, 90, 22); jLabel8.setBackground(new java.awt.Color(153, 204, 0)); jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel8.setText("Sonraki Mol Says :"); jPanel1.add(jLabel8); jLabel8.setBounds(20, 300, 190, 30); jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "(P) - paskal ", " " })); jComboBox4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox4ActionPerformed(evt); } }); jPanel1.add(jComboBox4); jComboBox4.setBounds(320, 140, 110, 22); jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel2.setText("nceki Hacim Deeri :"); jPanel1.add(jLabel2); jLabel2.setBounds(20, 60, 190, 22); jButton2.setText("TEMZLE"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel1.add(jButton2); jButton2.setBounds(580, 30, 80, 40); jLabel12.setBackground(new java.awt.Color(153, 204, 0)); jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel12.setText("nceki Basn Deeri :"); jPanel1.add(jLabel12); jLabel12.setBounds(20, 20, 190, 30); jLabel13.setBackground(new java.awt.Color(153, 204, 0)); jLabel13.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel13.setText("nceki Mol Says :"); jPanel1.add(jLabel13); jLabel13.setBounds(20, 260, 190, 30); jPanel1.add(jTextField8); jTextField8.setBounds(220, 300, 90, 22); jPanel1.add(jTextField7); jTextField7.setBounds(220, 260, 90, 22); jLabel11.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel11.setText("Sonraki Scaklk Deeri :"); jPanel1.add(jLabel11); jLabel11.setBounds(20, 220, 190, 22); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/muh/images/ava8ggadsdro.jpg"))); // NOI18N jLabel1.setText("jLabel1"); jPanel1.add(jLabel1); jLabel1.setBounds(0, -10, 690, 390); 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, 670, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)); pack(); }// </editor-fold>//GEN-END:initComponents private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed }//GEN-LAST:event_jTextField2ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed double p1, v1, t1, p2, t2, v2, m1, m2; //D=Double.parseDouble(jTextField1.getText()); p1 = Double.parseDouble(jTextField2.getText()); v1 = Double.parseDouble(jTextField3.getText()); t1 = Double.parseDouble(jTextField4.getText()); p2 = Double.parseDouble(jTextField1.getText()); v2 = Double.parseDouble(jTextField5.getText()); t2 = Double.parseDouble(jTextField6.getText()); m1 = Double.parseDouble(jTextField7.getText()); m2 = Double.parseDouble(jTextField8.getText()); //A=(Math.PI*(D*D)/1000/4); //jLabel5.setText("KESIT ALAN:"+A); if ((p1 * v1) / (t1 * m1) == (p2 * v2) / (t2 * m2)) jLabel6.setText("uygundur"); else jLabel6.setText("uygun deildir"); }//GEN-LAST:event_jButton1ActionPerformed private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextField3ActionPerformed private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextField4ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed jTextField2.setText(""); jTextField3.setText(""); jTextField4.setText(""); jTextField5.setText(""); jTextField6.setText(""); jTextField7.setText(""); jTextField8.setText(""); // TODO add your handling code here: }//GEN-LAST:event_jButton2ActionPerformed private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox4ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBox4ActionPerformed private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox5ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBox5ActionPerformed private void jComboBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox6ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBox6ActionPerformed private void jComboBox8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox8ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBox8ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed double p1, v1, t1, p2, t2, v2, m1, m2; //D=Double.parseDouble(jTextField1.getText()); p1 = Double.parseDouble(jTextField2.getText()); v1 = Double.parseDouble(jTextField3.getText()); t1 = Double.parseDouble(jTextField4.getText()); p2 = Double.parseDouble(jTextField1.getText()); v2 = Double.parseDouble(jTextField5.getText()); t2 = Double.parseDouble(jTextField6.getText()); m1 = Double.parseDouble(jTextField7.getText()); m2 = Double.parseDouble(jTextField8.getText()); DefaultCategoryDataset dcd = new DefaultCategoryDataset(); dcd.setValue(p1, "nceki Deerler", "Basn(p1)"); dcd.setValue(v1, "nceki Deerler", "Hacim(v1)"); dcd.setValue(t1, "nceki Deerler", "Scaklk(t1)"); dcd.setValue(m1, "nceki Deerler", "Mol (m1)"); dcd.setValue((p1 * v1) / (t1 * m1), "nceki Deerler", "p1*v1/t1*m1"); dcd.setValue((p2 * v2) / (t2 * m2), "Sonraki Deerler", "p2*v2/t2*m2"); dcd.setValue(p2, "Sonraki Deerler", "Basn(p2)"); dcd.setValue(v2, "Sonraki Deerler", "Hacim(v2)"); dcd.setValue(t2, "Sonraki Deerler", "Scaklk(t2)"); dcd.setValue(m2, "Sonraki Deerler", "Mol (m2)"); JFreeChart jchart = ChartFactory.createBarChart3D("p1*v1/t1*m1 = p2*v2/t2*m2", "Veriler", "Deerler", dcd, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = jchart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.black); ChartFrame chartFrm = new ChartFrame("Grafiksel Gsterim", jchart, true); chartFrm.setVisible(true); chartFrm.setSize(500, 400);// TODO add your handling code here: }//GEN-LAST:event_jButton3ActionPerformed /** * @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(avagadroYasasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(avagadroYasasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(avagadroYasasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(avagadroYasasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new avagadroYasasi().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JComboBox jComboBox3; private javax.swing.JComboBox jComboBox4; private javax.swing.JComboBox jComboBox5; private javax.swing.JComboBox jComboBox6; private javax.swing.JComboBox jComboBox7; private javax.swing.JComboBox jComboBox8; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; 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.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; private javax.swing.JTextField jTextField3; private javax.swing.JTextField jTextField4; private javax.swing.JTextField jTextField5; private javax.swing.JTextField jTextField6; private javax.swing.JTextField jTextField7; private javax.swing.JTextField jTextField8; // End of variables declaration//GEN-END:variables }