1. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    how to call this ubah() method
    The code in post#203 has a statement that calls the ubah() method.
    Is that method being called when the code executes? A way to know if the method is being called is to add a println() FIRST thing in the method that prints a message saying the method is being executed. If the message does not print, then the method is not being called.
  2. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    The code in post#203 has a statement that calls the ubah() method.
    Is that method being called when the code executes? A way to know if the method is being called is to add a println() FIRST thing in the method that prints a message saying the method is being executed. If the message does not print, then the method is not being called.
    How to do that? What should I do next? If the method is not being called, so what should I do?
    Last edited by Tawijakarta; June 28th, 2013 at 10:27 AM.
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    What should I do next?
    Find where the problems are and fix them.
    What is the current problem with the program? Do you know what code is executing when the program is run? Using println() statements will help you understand where the code is executing.

    What prints out when the program is executed?

    Why were the println() statements shown in post#206 removed in the code shown in post#208.

    If the method is not being called
    Does that mean the method is NOT being called when the code is executed?
    Last edited by NormR; June 28th, 2013 at 10:33 AM.
  4. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    Find where the problems are and fix them.
    What is the current problem with the program? Do you know what code is executing when the program is run? Using println() statements will help you understand where the code is executing.

    What prints out when the program is executed?

    Why were the println() statements shown in post#206 removed in the code shown in post#208.


    Does that mean the method is NOT being called when the code is executed?
    If the code is executed, what should I do? Why was the code showing wrong messages?
  5. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    Why was the code showing wrong messages?
    What variable controls which message is shown?
    What is the contents of that variable when the wrong message is shown?
    Where is the contents of that variable changed?
    Where is the variable given the contents that causes the wrong message to be shown?
  6. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    What variable controls which message is shown?
    What is the contents of that variable when the wrong message is shown?
    Where is the contents of that variable changed?
    Where is the variable given the contents that causes the wrong message to be shown?
    You can see the full posted code to get details. Now what should I do? Do you see in ubah()? Why doesn't the JOptionPane show up?
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    Sorry, I have not tried to compile and execute the last posted program. It is too big.
    The NewMain program was the right size for compiling and testing.
    Why doesn't the JOptionPane show up?
    You need to find answers to the questions I asked in post#215 so that you understand what your program is doing. Using the println() statement will help.
  8. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    Sorry, I have not tried to compile and execute the last posted program. It is too big.
    The NewMain program was the right size for compiling and testing.

    You need to find answers to the questions I asked in post#215 so that you understand what your program is doing. Using the println() statement will help.
    I cannot reduce it any mores. Just try to merge and compile it will you?
  9. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    You must try to debug the code so you see what it is doing. Try Adding println() statements as I have suggested and given examples of in earlier posts.

    Make a program the same size as NewMain (less than 300 lines) if you want someone else to work with the code.
  10. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    You must try to debug the code so you see what it is doing. Try Adding println() statements as I have suggested and given examples of in earlier posts.

    Make a program the same size as NewMain (less than 300 lines) if you want someone else to work with the code.
    Code:
    tombolUbahPadukData.addActionListener(new java.awt.event.ActionListener() 
       {  
          @Override  
          public void actionPerformed(java.awt.event.ActionEvent evt) 
          {  
              try {  
                  ubah();
              } catch (SQLException ex) {
                  ex.printStackTrace();
                  Logger.getLogger(ProgramTesisBaru.class.getName()).log(Level.SEVERE, null, ex);
              }
          }  
      
          private void ubah() throws SQLException
          {  
              System.out.println("Connection Status is "+connection);
                  if (connection.isClosed())
                     {
                         JOptionPane.showMessageDialog(null, "Hubungkan Dahulu ke Paduk Data", "Tidak Ada Koneksi", JOptionPane.INFORMATION_MESSAGE);
                     }
                  else 
                     {
                        for (int lmo = 0; lmo < 4; lmo++)  
                            {  
                                 jawabKriteria[lmo][0].setEditable(true);
                                 jawabKriteria[lmo][0].setVisible(true);
                                 jawabKriteria[lmo][1].setEditable(true);  
                                 jawabKriteria[lmo][1].setVisible(true);
                                 kriteria[lmo][0].setVisible(true);
                                 kriteria[lmo][1].setVisible(true);
                            }  
                        for (int mlo = 0; mlo < 5; mlo++)  
                            {  
                                 jawabAlternatif[mlo][0].setEditable(true);  
                                 jawabAlternatif[mlo][0].setVisible(true);
                                 jawabAlternatif[mlo][1].setEditable(true);  
                                 jawabAlternatif[mlo][1].setVisible(true);
                                 alternatif[mlo][0].setVisible(true);
                                 alternatif[mlo][1].setVisible(true);
                            }  
                        lanjut.setEnabled(true); 
                        lanjut.setVisible(true);
                        myocardialInfarction.setVisible(true);
                        stroke.setVisible(true);
                      }
              //} catch (SQLException ex) {
                //  ex.printStackTrace();
                  //Logger.getLogger(ProgramTesisBaru.class.getName()).log(Level.SEVERE, null, ex);
              //}
          }
       });
    Why didn't the Java execute the println?
  11. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    Why didn't the Java execute the println?
    That is the same question that you asked in post#206.

    For the println() method to be executed, the listener must be called so that it can call the ubah() method.

    What statements in the program have been executed? Copy the full contents of the console window from when the program executes and paste it here.
  12. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    That is the same question that you asked in post#206.

    For the println() method to be executed, the listener must be called so that it can call the ubah() method.

    What statements in the program have been executed? Copy the full contents of the console window from when the program executes and paste it here.
    Nothing appears in the console, so? Ok I change the question, how to test whether or not the connection is open?

    The thing I want to do is:

    connection = open?
    if open bla bla bla
    if close bla bla bla, how to do that?
    Last edited by Tawijakarta; June 30th, 2013 at 08:54 AM.
  13. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    Nothing appears in the console
    Are you executing the correct program? Add some println() statements to the code so that you know that you are executing the correct program. See my post #207.

    how to test whether or not the connection is open?
    Call the isClosed() method to determine if the connection is open.
  14. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    257
    Rep Power
    0
    Originally Posted by NormR
    Are you executing the correct program? Add some println() statements to the code so that you know that you are executing the correct program. See my post #207.


    Call the isClosed() method to determine if the connection is open.
    Give me one example. what code to use? How to avoid NPE?

    I want to do

    connection = open?

    if open bla bla bla
    if close bla bla bla, how to do that?
  15. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    How to avoid NPE?
    If you are getting a NPE, what variable has the null value?
    Make sure that variable has a value before using it.

    Compare its contents to null to see if it is null:
    (variable == null)
    and don't use it if it is null.

    Or test: (variable != null)
    and then it is OK to use if it is not null

IMN logo majestic logo threadwatch logo seochat tools logo