Sie sind auf Seite 1von 28

/* * To change this template, choose Tools * and open the template in the editor. */ /* * WindowApp.

java * * Created on Jun 29, 2010, 9:44:51 PM */ package windowappgui; import java.sql.*; //import java.util.*;

Templates

/** * * @author Neelam */ public class WindowApp extends javax.swing.JFrame { /** Creates new form WindowApp */ public WindowApp() { initComponents(); } /** 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"> private void initComponents() { window_2 = new javax.swing.JDialog(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox(); jTextField1 = new javax.swing.JTextField(); jComboBox2 = new javax.swing.JComboBox(); jComboBox3 = new javax.swing.JComboBox(); jTextField2 = new javax.swing.JTextField(); jLabel15 = new javax.swing.JLabel(); jLabel16 = new javax.swing.JLabel(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); jButton2 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); jLabel20 = new javax.swing.JLabel(); jLabel21 = new javax.swing.JLabel(); jLabel22 = new javax.swing.JLabel();

jLabel23 = new javax.swing.JLabel(); jLabel24 = new javax.swing.JLabel(); jLabel25 = new javax.swing.JLabel(); jLabel26 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jLabel27 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea2 = new javax.swing.JTextArea(); jButton1 = new javax.swing.JButton(); buttonGroup1 = new javax.swing.ButtonGroup(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel19 = new javax.swing.JLabel(); jLabel18 = new javax.swing.JLabel(); jLabel10.setFont(new java.awt.Font("Harlow Solid Italic", 3, 24)); jLabel10.setForeground(new java.awt.Color(0, 204, 204)); jLabel10.setText("Make your life easier................................. ................................................................................ ......................."); jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 36)); jLabel11.setText("Source"); jLabel12.setFont(new java.awt.Font("Times New Roman", 1, 36)); jLabel12.setText("Destination"); jLabel13.setFont(new java.awt.Font("Times New Roman", 1, 36)); jLabel13.setText("Time"); jLabel14.setFont(new java.awt.Font("Times New Roman", 1, 36)); jLabel14.setText("Day"); jComboBox1.setFont(new java.awt.Font("Utsaah", 1, 24)); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" })); jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); } }); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField1ActionPerformed(evt); } }); jComboBox2.setFont(new java.awt.Font("Utsaah", 1, 24)); jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" })) ;

jComboBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox2ActionPerformed(evt); } }); jComboBox3.setFont(new java.awt.Font("Utsaah", 1, 24)); jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" })); jComboBox3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox3ActionPerformed(evt); } }); jTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField2ActionPerformed(evt); } }); jLabel15.setFont(new java.awt.Font("Harrington", 2, 18)); jLabel15.setText("in 24 hr format"); jLabel16.setFont(new java.awt.Font("Times New Roman", 1, 36)); jLabel16.setText("Priority"); buttonGroup1.add(jRadioButton1); jRadioButton1.setFont(new java.awt.Font("Times New Roman", 1, 24)); jRadioButton1.setText("Time"); buttonGroup1.add(jRadioButton2); jRadioButton2.setFont(new java.awt.Font("Times New Roman", 1, 24)); jRadioButton2.setText("Distance"); jRadioButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton2ActionPerformed(evt); } }); jButton2.setFont(new java.awt.Font("Times New Roman", 1, 24)); jButton2.setText("Submit"); jButton2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton2MouseClicked(evt); } }); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jLabel17.setFont(new java.awt.Font("Times New Roman", 1, 24)); jLabel17.setText("Shortest Distance:"); jLabel20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/wind owappgui/graph.png"))); // NOI18N

jLabel21.setFont(new java.awt.Font("Verdana", 1, 24)); jLabel21.setForeground(new java.awt.Color(204, 0, 0)); jLabel21.setText("______"); jLabel22.setFont(new java.awt.Font("Tahoma", 1, 18)); jLabel22.setText("km."); jLabel23.setFont(new java.awt.Font("Times New Roman", 1, 24)); jLabel23.setText("Minimum Time:"); jLabel24.setFont(new java.awt.Font("Verdana", 1, 24)); jLabel24.setForeground(new java.awt.Color(204, 0, 0)); jLabel24.setText("______"); jLabel25.setFont(new java.awt.Font("Tahoma", 1, 18)); jLabel25.setText("minutes."); jLabel26.setFont(new java.awt.Font("Times New Roman", 1, 24)); jLabel26.setText("Required Path :"); jTextArea1.setColumns(12); jTextArea1.setFont(new java.awt.Font("Times New Roman", 1, 24)); jTextArea1.setForeground(new java.awt.Color(204, 0, 0)); jTextArea1.setRows(3); jTextArea1.setTabSize(5); jScrollPane1.setViewportView(jTextArea1); jLabel27.setFont(new java.awt.Font("Times New Roman", 1, 24)); jLabel27.setText("Required Path:"); jTextArea2.setColumns(12); jTextArea2.setFont(new java.awt.Font("Times New Roman", 1, 24)); jTextArea2.setForeground(new java.awt.Color(204, 0, 0)); jTextArea2.setRows(3); jTextArea2.setTabSize(5); jScrollPane2.setViewportView(jTextArea2); jButton1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N jButton1.setText("Clear"); jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); javax.swing.GroupLayout window_2Layout = new javax.swing.GroupLayout(win dow_2.getContentPane()); window_2.getContentPane().setLayout(window_2Layout); window_2Layout.setHorizontalGroup( window_2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment .LEADING) .addGroup(window_2Layout.createSequentialGroup() .addGroup(window_2Layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addGroup(window_2Layout.createSequentialGroup() .addGap(38, 38, 38) .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING) .addGroup(window_2Layout.createSequentialGroup() .addComponent(jLabel11, javax.swing.GroupLayout.

PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED) .addComponent(jComboBox3, javax.swing.GroupLayou t.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(51, 51, 51) .addComponent(jLabel12) .addGap(36, 36, 36) .addComponent(jComboBox1, javax.swing.GroupLayou t.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(81, 81, 81) .addComponent(jLabel13, javax.swing.GroupLayout. PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(13, 13, 13) .addComponent(jTextField1, javax.swing.GroupLayo ut.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED) .addComponent(jTextField2, javax.swing.GroupLayo ut.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(114, 114, 114) .addComponent(jLabel14, javax.swing.GroupLayout. PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.UNRELATED) .addComponent(jComboBox2, javax.swing.GroupLayou t.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel10, javax.swing.GroupLayout.PREF ERRED_SIZE, 1193, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(window_2Layout.createSequentialGroup() .addGroup(window_2Layout.createParallelGroup(jav ax.swing.GroupLayout.Alignment.LEADING) .addGroup(window_2Layout.createSequentialGro up() .addComponent(jLabel16) .addGap(53, 53, 53) .addComponent(jRadioButton1) .addGap(131, 131, 131) .addComponent(jRadioButton2)) .addGroup(window_2Layout.createSequentialGro up() .addGap(249, 249, 249) .addComponent(jButton2, javax.swing.Grou pLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(window_2Layout.createSequentialGro up() .addGroup(window_2Layout.createParallelG roup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel17, javax.swing. GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel26) .addComponent(jLabel23) .addComponent(jLabel27) .addGroup(window_2Layout.createSeque ntialGroup() .addGap(32, 32, 32) .addComponent(jButton1))) .addGap(39, 39, 39) .addGroup(window_2Layout.createParallelG roup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(jScrollPane1) .addGroup(window_2Layout.createSeque ntialGroup() .addComponent(jLabel24) .addGap(26, 26, 26) .addComponent(jLabel25, javax.sw ing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(window_2Layout.createSeque ntialGroup() .addComponent(jLabel21) .addGap(18, 18, 18) .addComponent(jLabel22)) .addComponent(jScrollPane2)))) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED, 121, Short.MAX_VALUE) .addComponent(jLabel20, javax.swing.GroupLayout. PREFERRED_SIZE, 693, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(window_2Layout.createSequentialGroup() .addGap(1085, 1085, 1085) .addComponent(jLabel4)) .addGroup(window_2Layout.createSequentialGroup() .addGap(718, 718, 718) .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRE D_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(796, Short.MAX_VALUE)) ); window_2Layout.setVerticalGroup( window_2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment .LEADING) .addGroup(window_2Layout.createSequentialGroup() .addGap(27, 27, 27) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(window_2Layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addGroup(window_2Layout.createSequentialGroup() .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING) .addGroup(window_2Layout.createSequentialGroup() .addGap(27, 27, 27) .addGroup(window_2Layout.createParallelGroup(jav ax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11) .addComponent(jLabel12) .addComponent(jLabel13))) .addGroup(window_2Layout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(jComboBox3, javax.swing.GroupLayou t.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout. PREFERRED_SIZE)) .addGroup(window_2Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jComboBox1, javax.swing.GroupLayou t.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout. PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem ent.RELATED) .addComponent(jLabel15)) .addGroup(window_2Layout.createSequentialGroup() .addGap(30, 30, 30)

.addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.BASELINE) .addComponent(jTextField1, javax.swing.GroupLayout.P REFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextField2, javax.swing.GroupLayout.P REFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(window_2Layout.createSequentialGroup() .addGap(29, 29, 29) .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING) .addComponent(jComboBox2, javax.swing.GroupLayout.PR EFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREF ERRED_SIZE) .addComponent(jLabel14)))) .addGroup(window_2Layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addGroup(window_2Layout.createSequentialGroup() .addGap(12, 12, 12) .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.BASELINE) .addComponent(jLabel16) .addComponent(jRadioButton1) .addComponent(jRadioButton2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem ent.RELATED) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRE D_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24) .addComponent(jLabel4) .addGap(27, 27, 27) .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.BASELINE) .addComponent(jLabel17, javax.swing.GroupLayout.PREF ERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel21) .addComponent(jLabel22)) .addGap(55, 55, 55) .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING, false) .addGroup(window_2Layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLay out.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayou t.PREFERRED_SIZE) .addGap(50, 50, 50)) .addGroup(window_2Layout.createSequentialGroup() .addComponent(jLabel26) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1) .addGap(35, 35, 35))) .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.BASELINE) .addComponent(jLabel24) .addComponent(jLabel25, javax.swing.GroupLayout.PREF ERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel23)) .addGroup(window_2Layout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING) .addGroup(window_2Layout.createSequentialGroup() .addGap(57, 57, 57)

.addComponent(jLabel27)) .addGroup(window_2Layout.createSequentialGroup() .addGap(36, 36, 36) .addComponent(jScrollPane2, javax.swing.GroupLay out.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayou t.PREFERRED_SIZE)))) .addGroup(window_2Layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(jLabel20))) .addContainerGap(1749, Short.MAX_VALUE)) ); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setFont(new java.awt.Font("Harlow Solid Italic", 3, 36)); jLabel1.setForeground(new java.awt.Color(0, 204, 204)); jLabel1.setText("Save your precious time................................ ..............Avoid traffic jams"); jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 48)); jLabel2.setText("WELCOME"); jLabel3.setFont(new java.awt.Font("Tahoma", 2, 36)); jLabel3.setText("to"); jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 48)); jLabel5.setForeground(new java.awt.Color(163, 120, 120)); jLabel5.setText("TRAVELLER"); jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 48)); jLabel6.setForeground(new java.awt.Color(142, 91, 91)); jLabel6.setText("INFORMATION"); jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 48)); jLabel7.setForeground(new java.awt.Color(112, 69, 69)); jLabel7.setText("SYSTEM"); jLabel8.setFont(new java.awt.Font("Harlow Solid Italic", 3, 36)); jLabel8.setForeground(new java.awt.Color(0, 204, 204)); jLabel8.setText("click here"); jLabel8.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel8MouseClicked(evt); } }); jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 36)); jLabel9.setText("to continue"); jLabel19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/wind owappgui/1245105405_lilman41.png"))); // NOI18N jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/wind owappgui/1245105405_lilman4.png"))); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentP ane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING

) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED _SIZE, 1208, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING , layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel6) .addGap(265, 265, 265)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING , layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(128, 128, 128) .addComponent(jLabel2)) .addGroup(layout.createSequentialGroup() .addGap(233, 233, 233) .addComponent(jLabel3, javax.swing.Group Layout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(116, 116, 116) .addComponent(jLabel5))) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED, 329, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING) .addComponent(jLabel7) .addComponent(jLabel18)) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED))) .addComponent(jLabel19) .addGap(318, 318, 318))) .addContainerGap(181, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(409, 409, 409) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 1 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA TED) .addComponent(jLabel9) .addContainerGap(955, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING ) .addGroup(layout.createSequentialGroup() .addGap(26, 26, 26) .addComponent(jLabel1) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.LEADING) .addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(59, 59, 59) .addComponent(jLabel2) .addGap(64, 64, 64) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED, 73, Short.MAX_VALUE) .addComponent(jLabel5) .addGap(54, 54, 54)) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.Compone ntPlacement.RELATED, 52, Short.MAX_VALUE) .addComponent(jLabel18, javax.swing.GroupLayout. PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18))) .addGap(106, 106, 106) .addComponent(jLabel7) .addGap(31, 31, 31) .addGroup(layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.BASELINE) .addComponent(jLabel8) .addComponent(jLabel9, javax.swing.GroupLayout.PREFE RRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(12, 12, 12)) .addGroup(layout.createSequentialGroup() .addGap(193, 193, 193) .addComponent(jLabel19))) .addGap(464, 464, 464)) .addGroup(layout.createSequentialGroup() .addGap(478, 478, 478) .addComponent(jLabel6) .addContainerGap(682, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jLabel8MouseClicked(java.awt.event.MouseEvent evt) { window_2.setBounds(0,0,1355,978); window_2.setVisible(true); } private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) { } private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:

} private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {

if( jRadioButton2.isSelected()) { int[]predecessor=new int[100]; int[]dist=new int[100]; int[]status=new int[100]; int []path=new int [100]; char so; char de; int s,d; int result=0; int res1; String t=(String)jComboBox3.getSelectedItem(); so=t.charAt(0); s=so-97; String m=(String)jComboBox1.getSelectedItem(); de=m.charAt(0); d=de-97; int[][]adj={{0,5,0,0,15,0,0,0,0,0,0,0,10,12,0,0,0,0,0,0,0,0,0,0,0,0},{5,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,6 ,6,4,0,0,0,10,0,0,0,0,0,0,0,0,0}, {15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,5,0,0,0, 7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,6,8 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,7,5,0,0},{0,0,0,0,0,0,0,6,0,0,0 ,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,6,0,7,0,8,7,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,6,0,0,0,0,0,0,5 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {10,0,3,4,0,0,0,0,0,0,0,0,0,5,7,0,0,0,0,0,0,0,0,0,0,0},{12,0,0,0,0,0,0,0,0,0 ,0,0,5,0,5,0,10,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,25,0,0,7,5,0,5,0,0,6,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0, 0,0,0,0,5,0,0,0,3,0,0,0,0,0,0,0},

{0,0,0,10,0,0,0,0,0,0,0,0,0,10,0,0,0,4,7,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,4,0,0,0,0,0,9,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,3,7,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,3,0,12,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,2},{0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,5,5,0}, {0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,9,0,12,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,5,0, 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0}};

int infinity=9999; int i ,min,count=0,current,newdist,u,v; int sdist=0; for(i=0;i<adj.length;i++) { predecessor[i]=999; dist[i]=infinity; status[i]=999 ; } predecessor[s]=999; dist[s]=0; status[s]=111; current=s; while(current!=d) { for(i=0;i<adj.length;i++) { if ( adj[current][i] > 0 && status[i] == 999) { newdist=dist[current] + adj[current][i]; /*Checks for Relabeling*/ if( newdist < dist[i] ) { predecessor[i] = current; dist[i]= newdist; } } }/*End of for*/ /*Search for temporary node with minimum distance make it current node*/ min=infinity; current=999; for(i=0;i<adj.length;i++)

{ if(status[i] == 999 && dist[i] < min) { min = dist[i]; current=i; } }/*End of for*/ status[current]=111; if(current==999) System.out.println("No path exists"); /*If Source or Sink node is isolated*/

}/*End of while*/ /* Getting full path in array from destination to source */ while( current!=999 ) { count++; path[count]=current; current=predecessor[current]; } /*Getting distance from source to destination*/ for(i=count;i>1;i--) { u=path[i]; v=path[i-1]; sdist=sdist+adj[u][v]; } if(sdist!=0) { //System.out.print( "shortest distance is:"+sdist+"\n"); result=sdist; jLabel21.setText(String.valueOf(result)); System.out.print("shortest path is:"); for(i=count;i>1;i--) { System.out.print(path[i]+"->"); if(path[i]==0) jTextArea1.append(String.valueOf("a->")); if(path[i]==1) jTextArea1.append(String.valueOf("b->")); if(path[i]==2) jTextArea1.append(String.valueOf("c->"));

if(path[i]==3) jTextArea1.append(String.valueOf("d->")); if(path[i]==4) jTextArea1.append(String.valueOf("e->")); if(path[i]==5) jTextArea1.append(String.valueOf("f->")); if(path[i]==6) jTextArea1.append(String.valueOf("g->")); if(path[i]==7) jTextArea1.append(String.valueOf("h->")); if(path[i]==8) jTextArea1.append(String.valueOf("i->")); if(path[i]==9) jTextArea1.append(String.valueOf("j->")); if(path[i]==10) jTextArea1.append(String.valueOf("k->")); if(path[i]==11) jTextArea1.append(String.valueOf("l->")); if(path[i]==12) jTextArea1.append(String.valueOf("m->")); if(path[i]==13) jTextArea1.append(String.valueOf("n->")); if(path[i]==14) jTextArea1.append(String.valueOf("o->")); if(path[i]==15) jTextArea1.append(String.valueOf("p->")); if(path[i]==16) jTextArea1.append(String.valueOf("q->")); if(path[i]==17) jTextArea1.append(String.valueOf("r->")); if(path[i]==18) jTextArea1.append(String.valueOf("s->")); if(path[i]==19) jTextArea1.append(String.valueOf("t->"));

if(path[i]==20) jTextArea1.append(String.valueOf("u->")); if(path[i]==21) jTextArea1.append(String.valueOf("v->")); if(path[i]==22) jTextArea1.append(String.valueOf("w->")); if(path[i]==23) jTextArea1.append(String.valueOf("x->")); if(path[i]==24) jTextArea1.append(String.valueOf("y->")); if(path[i]==25) jTextArea1.append(String.valueOf("z->"));

jTextArea1.append(String.valueOf(de)+"."+"\n"); jTextArea1.append(String.valueOf("Have a nice day.")+"\n\n");

System.out.print(path[i]); //System.out.println(de); } else System.out.print("there is no path from source to destination no de \n");

else if(jRadioButton1.isSelected()) { float a[]=new float[100]; int c[]=new int[100]; float d[]=new float[100]; int h[]=new int [100]; float product[]=new float[100]; float sum[]=new float[100];

int b[]=new int[100]; String so=null; String de=null; int[]predecessor=new int[1000]; float[]time=new float[1000]; int[]status=new int[1000];

int i=0; int j=0,m=0,n=0,o=0,p=0,l=0 ,q=0; char source; char destination; int sour,dest; float adj[][]=new float[1000][1000]; /*to be used for dij*/ int []path=new int [1000]; /*to be used for dij*/ char so_1,de_1; /*to be used for dij*/ int source_1; int dest_1; int res2=0;

boolean day; float result1=0; String string1=(String)jComboBox3.getSelectedItem(); so_1=string1.charAt(0); source_1=so_1-97; String string2=(String)jComboBox1.getSelectedItem(); de_1=string2.charAt(0); dest_1=de_1-97; String string3=(String)jComboBox2.getSelectedItem(); if(string3=="Saturday" string3=="Sunday") day=false; else day=true;

float utime = Float.parseFloat(jTextField1.getText());

// Scanner sc=new Scanner(System.in); //System.out.print("enter day"); //day=sc.nextBoolean(); try {

Class.forName("com.mysql.jdbc.Driver"); String connectionUrl = "jdbc:mysql://localhost/nan?" + "user=root&password=shona"; Connection con = DriverManager.getConnection(connectionUrl); System.out.println("connection is successful"); Statement stmt = null; ResultSet rs = null;

// System.out.println("enter time"); // utime=sc.nextInt(); /* if(utime>24) {System.out.print("Wrong input"); }*/

if(day==false) { for(i=0;i<33;i++) {

String SQL="SELECT trffc_id from second_2 where r_id ="+(i+1)+" and "+ utime+" >= ts1 and "+utime+ " <= ts2"; //JOptionPane.showMessageDialog(null, SQL ); stmt=con.createStatement(); rs=stmt.executeQuery(SQL); while(rs.next()) { a[j]=rs.getFloat("trffc_id"); // JOptionPane.showMessageDialog(null, a[j] ); // System.out.println(a[j]); j++; }/*end of while*/ }/*end of for*/ String SQL="select * from final_2"; ResultSet rs2= null;

Statement stmt2= con.createStatement(); rs2=stmt2.executeQuery(SQL); //JOptionPane.showMessageDialog(null, "Check" + rs2); while(rs2.next()) { for(int k=0;k<33;k++) { if(rs2.getFloat("id")==a[k]) { //JOptionPane.showMessageDialog(null,"Inside Whi le" +rs2.getString("time_min") ); b[l]=rs2.getInt("time_min"); //JOptionPane.showMessageDialog(null,b[l]); //System.out.println(b[l]); l++; //System.out.println(rs2.getString("time_min")); } } }/*end of while*/

}/*end of if*/

else { for(i=0;i<33;i++) {

String SQL="SELECT trffc_id from second where r_id=" +(i+1)+" and "+ utime+" >= ts1 and "+utime+ " <= ts2"; //JOptionPane.showMessageDialog(null, SQL ); stmt=con.createStatement(); rs=stmt.executeQuery(SQL); while(rs.next()) {

a[j]=rs.getFloat("trffc_id"); // JOptionPane.showMessageDialog(null, a[j] ); //System.out.println(a[j]); j++; } }/*end of for*/ String SQL="select * from final_1"; ResultSet rs2= null; Statement stmt2= con.createStatement(); rs2=stmt2.executeQuery(SQL); //JOptionPane.showMessageDialog(null, "Check" + rs2); l=0; while(rs2.next()) { for(int k=0;k<33;k++) { if(rs2.getFloat("id")==a[k]) { //JOptionPane.showMessageDialog(null,"Inside Whi le" +rs2.getString("time_min") ); b[l]=rs2.getInt("time_min"); //JOptionPane.showMessageDialog(null,b[l]); //System.out.println(b[l]); l++; //System.out.println(rs2.getString("time_min")); } } }/*end of while*/ }/*end of else*/ String SQL="SELECT * from red "; //JOptionPane.showMessageDialog(null, SQL ); stmt=con.createStatement(); rs=stmt.executeQuery(SQL); while(rs.next()) { c[m]=rs.getInt("no_red"); // JOptionPane.showMessageDialog(null, c[m] ); // System.out.println(c[m]);

m++; } ResultSet rs2= null; Statement stmt2= con.createStatement(); rs2=stmt2.executeQuery(SQL); while(rs2.next()) { d[n]=rs2.getFloat("time"); // JOptionPane.showMessageDialog(null, d[n] ); // System.out.println(d[n]); n++; } m=0; n=0; o=0; while(m<33&&n<33) { product[o]=(c[m]*d[n]); m++; n++; o++; } // for(o=0;o<33;o++)ye yahan kyu hai // System.out.println(product[o]); SQL="SELECT * from first "; //JOptionPane.showMessageDialog(null, SQL ); stmt=con.createStatement(); rs=stmt.executeQuery(SQL); while(rs.next()) { h[p]=rs.getInt("time_taken"); // JOptionPane.showMessageDialfog(null, h[p] ); // System.out.println(h[p]); p++; } /*addition*/ i=0; q=0; while(i<33&&q<33) { sum[q]+=((product[i]+h[i]+b[i])+(h[i]+b[i]))/2; i++; q++; }

for(q=0;q<33;q++) { //System.out.println(sum[q]); } for(i=0;i<33;i++) { SQL="SELECT 1st,2nd from first where r_id= " + (i+1) ; //JOptionPane.showMessageDialog(null, SQL ); stmt=con.createStatement(); rs=stmt.executeQuery(SQL); while(rs.next()) { so=rs.getString("1st"); de=rs.getString("2nd"); //JOptionPane.showMessageDialog(null, so); //JOptionPane.showMessageDialog(null, de); // System.out.println(so); //System.out.println(de); }

source =so.charAt(0); destination =de.charAt(0); //System.out.println(source); //System.out.println(destination); sour=source-97; dest=destination-97; adj[sour][dest]=sum[i]; adj[dest][sour]=sum[i]; //System.out.println(adj[sour][dest] ); //System.out.println("\n"); //System.out.println(adj[dest][sour] );

// System.out.print("the adjacency matrix is:\n"); /*for(i=0;i<26;i++) { for(j=0;j<26;j++) System.out.print(adj[i][j]+" "); System.out.print("\n"); }*/

/*System.out.println("enter source node b/w a and z('Q' to quit):"); string1=sc.next(); so_1=string1.charAt(0); System.out.println("you entered" + " " + so_1 ); source_1=so_1-97; //System.out.println(source_1);

System.out.print( "enter destination node b/w a and z ('Q' to quit):") ; string2=sc.next(); de_1=string2.charAt(0); System.out.println("you entered" + " " + de_1 +"\n\n" ); dest_1=de_1-97; // System.out.println(dest_1); if(so_1 =='Q' de_1=='Q') break;*/

int infinity=9999; int count=0,current,u,v; float newtime=0.0f,min; float stime=0.0f; for(i=0;i<26;i++) { predecessor[i]=999; time[i]=infinity; status[i]=999 ; } predecessor[source_1]=999; time[source_1]=0; status[source_1]=111; current=source_1; while(current!=dest_1) { for(i=0;i<26;i++) { if ( adj[current][i] > 0.0f && status[i] == 999) { newtime=time[current] + adj[current][i]; /*Checks for Relabeling*/ if( newtime< time[i] )

{ predecessor[i] = current; time[i]= newtime; } } }/*end of for*/ min=infinity; current=999; for(i=0;i<26;i++) { if(status[i] == 999 && time[i] < min) { min = time[i]; current=i; }/*End of if*/ }/*end of for*/ if(current==999) System.out.println("No path exists"); status[current]=111;

}/*End of while*/ /* Getting full path in array from destination to source */

while( current!=999 ) { count++; path[count]=current; current=predecessor[current]; } /*Getting time from source to destination*/ for(i=count;i>1;i--) { u=path[i]; v=path[i-1]; stime=stime+adj[u][v]; } //System.out.println(stime); if(stime!=0.0f) { if(utime<=24) { System.out.print( "shortest time is:"+stime+ " " + "minutes" + "\n

"); result1=stime; jLabel24.setText(String.valueOf(result1));

System.out.print("shortest path is:"); for(i=count;i>1;i--) { System.out.print(path[i]+"->");

if(path[i]==0) jTextArea2.append(String.valueOf("a->")); if(path[i]==1) jTextArea2.append(String.valueOf("b->")); if(path[i]==2) jTextArea2.append(String.valueOf("c->")); if(path[i]==3) jTextArea2.append(String.valueOf("d->")); if(path[i]==4) jTextArea2.append(String.valueOf("e->")); if(path[i]==5) jTextArea2.append(String.valueOf("f->")); if(path[i]==6) jTextArea2.append(String.valueOf("g->")); if(path[i]==7) jTextArea2.append(String.valueOf("h->")); if(path[i]==8) jTextArea2.append(String.valueOf("i->")); if(path[i]==9) jTextArea2.append(String.valueOf("j->")); if(path[i]==10) jTextArea2.append(String.valueOf("k->")); if(path[i]==11) jTextArea2.append(String.valueOf("l->")); if(path[i]==12)

jTextArea2.append(String.valueOf("m->")); if(path[i]==13) jTextArea2.append(String.valueOf("n->")); if(path[i]==14) jTextArea2.append(String.valueOf("o->")); if(path[i]==15) jTextArea2.append(String.valueOf("p->")); if(path[i]==16) jTextArea2.append(String.valueOf("q->")); if(path[i]==17) jTextArea2.append(String.valueOf("r->")); if(path[i]==18) jTextArea2.append(String.valueOf("s->")); if(path[i]==19) jTextArea2.append(String.valueOf("t->")); if(path[i]==20) jTextArea2.append(String.valueOf("u->")); if(path[i]==21) jTextArea2.append(String.valueOf("v->")); if(path[i]==22) jTextArea2.append(String.valueOf("w->")); if(path[i]==23) jTextArea2.append(String.valueOf("x->")); if(path[i]==24) jTextArea2.append(String.valueOf("y->")); if(path[i]==25) jTextArea2.append(String.valueOf("z->"));

} jTextArea2.append(String.valueOf(de_1)+"."+"\n"); jTextArea2.append(String.valueOf("Have a nice day.\n\n")

); //System.out.println(de_1); //System.out.println("Have a nice day"); } else jTextArea2.append(String.valueOf("Wrong Input")); } else System.out.print("there is no path from source to destination no de \n");

}/*end of try*/ catch(SQLException e) { // TODO code application logic hereh (SQLException e) { System.out.println("SQL Exception: "+ e.toString()); } catch (ClassNotFoundException cE) { System.out.println("Class Not Found Exception: "+ cE.toString()); }

} // TODO add your handling code here: } private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { jTextArea1.setText(""); jTextArea2.setText(""); jLabel21.setText("");

jLabel24.setText(""); // TODO add your handling code here: } //* @param args the command line arguments public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new WindowApp().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JComboBox jComboBox1; private javax.swing.JComboBox jComboBox2; private javax.swing.JComboBox jComboBox3; 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 jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLabel22; private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; private javax.swing.JLabel jLabel27; 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.JRadioButton jRadioButton1; private javax.swing.JRadioButton jRadioButton2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextArea jTextArea2; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; private javax.swing.JDialog window_2; // End of variables declaration

Das könnte Ihnen auch gefallen