Solved

Performance problem loading XML message on a applet in order to display them on a text scroll view.

Posted on 2007-12-04
3
206 Views
Last Modified: 2013-12-29
Hi,
   I got a problem trying to load XML messages from a URL on an Applet update() method. The applet is used to diaply a text scroll; what happes is when the update method is called (because the current messages are about to passed) is freezing the scrolling effect for a sec. Any ideas how I can handle this?

Regards,

Carlos M.  
public synchronized void update(Graphics g) {
		
		int limit = theListOfList.size();
		for (int n = 0;n<limit;n++){ 
		 
			for (Message m : theListOfList.elementAt(n).messages) {
				m.X--;
				
				
				
			}
			if ((theListOfList.elementAt(n).messages.lastElement().X + theListOfList.elementAt(n).messages.lastElement().messageSize)- totalLarge == theListOfList.elementAt(n).totalListBufferSize) {
 
			
				currentListPoss = nextListPoss;
				
				loadMessages(theListOfList.elementAt(n).messages.lastElement().X+ theListOfList.elementAt(n).messages.lastElement().messageSize);
            
			}
 
		}
		
 
		 paint(g);
	}
 
 
This is the loadmessages method:
 
public synchronized void loadMessages(int X) {
		System.out.println(currentListPoss);
		ListOfMessages currentList = new ListOfMessages();
		
 
		try {
			
			DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
					.newInstance();
			DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
			Document doc = docBuilder
					.parse("http://65.38.219.91/29960/test/getmessages2.php");
			NodeList listOfitems = doc.getElementsByTagName("item");
 
			for (int s = 1; s < listOfitems.getLength(); s++) {
 
				Node item = listOfitems.item(s);
				receiver.add(item.getTextContent().trim());
 
			}// end of for loop with s var
 
		} catch (SAXParseException err) {
		
 
		} catch (SAXException e) {
			Exception x = e.getException();
			// System.out.println(e);
			((x == null) ? e : x).printStackTrace();
 
		} catch (Throwable t) {
			t.printStackTrace();
			// System.out.println(t);
		}
		
 
 
         int i =0;
		for (String s : receiver) {
			
			Message currentMsg = new Message(s, X);
			
			
			currentList.messages.add(generateImg(currentMsg));
			currentList.totalListSize += currentMsg.messageSize;
			
			X = X + currentMsg.messageSize;
			
			i++;
		}
		currentList.totalListBufferSize = (int) (currentList.totalListSize * 0.30);
 
		theListOfList.add(currentListPoss, currentList);
		if (currentListPoss == messageQueueLimit - 1) {
			nextListPoss = 0;
		} else {
			nextListPoss = currentListPoss + 1;
 
		}
 
	}

Open in new window

0
Comment
Question by:cmercado_miranda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20408060
you need to handle the loading of xml in a seperate thread.
0
 

Author Comment

by:cmercado_miranda
ID: 20411413
How can I do that, any example of calling a tread on a applet?
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 20415858
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to execute a Python program and gather return output in Java 2 49
swing controls 2 23
What browser will run Java? 7 127
learn programming 8 72
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question