View Single Post
  #1 (permalink)  
Old 11-17-2007, 04:02 AM
ibanez270dx ibanez270dx is offline
Member
 
Join Date: Nov 2007
Location: Bay Area, CA
Posts: 13
Rep Power: 0
ibanez270dx is on a distinguished road
Default JPanel won't update
Hello,
Everything in my applet works except for one thing - When I click the JButton and the event takes place, it is supposed to change a JPanel to say "please wait", but instead, it freezes up for a few seconds while it completes the next commands and goes to the JPanel that is supposed to display after the commands are made, completly bypassing the "please wait" JPanel. The code looks like this:

Code:
 public void actionPerformed(ActionEvent pt)
     {
      if(pt.getSource() == init_Button)
	{
 	  overallLayout.show(cardPanel, "2"); // please wait JPanel
	  try
	    {
        // Construct data
         String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
         data += "&" + URLEncoder.encode("key2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
    
	// Send data
         URL url = new URL("http://www.loaded-designs.com/posttest/posttest.php");
         URLConnection conn = url.openConnection();
         conn.setDoOutput(true);
         OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
         wr.write(data);
         wr.flush();
    
       	// Get the response
       	 BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
       	 String line;
       	 while ((line = rd.readLine()) != null) 
	   {
            getback_Label.setText("The PHP variables are below:");
            getback_Label2.setText(line);
	    System.out.println(line);
 	    overallLayout.show(cardPanel, "3");
           }
       	 wr.close();
         rd.close();
    	    }
	 catch (Exception ex)
	    {
	     ex.printStackTrace();
   	    }
        } 

     }
Does anyone know how to fix this? I tried repaint() but it didn't work... I'm really new at Java, so I think I might not have implemented it correctly. Any help is appreciated!

Thank you very much,
- Jeff
Reply With Quote