• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need help making an applet work to display info..

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have my applet made and the code all wrote for it..
i have a separate peice of code that allows info to be added to simulate a print queue on the applet...
when i add all the info in and hit the display button to display the details of the queue in the display box on the applet it is only showing one result.. if i enter 3 sets of data it only shows the middle set.. i need it to show all the data..

heres the code for the main display method..
(CODE)
public String displayQueueApplet()
{
// Pointer to access the queue
QueueNode nextQueueNode = new QueueNode();

String statement;

// Test if queue is empty
if (start == null)
{
statement = "\n\nThe queue is empty!";
return statement;
}
else
{
// Start at the front of the queue
nextQueueNode = start;

// Output the next data value in the queue
statement = "\nQueue Contains:\n";

// Loop through all the details in queue
while (nextQueueNode != null)
{
// Update the pointer
nextQueueNode = nextQueueNode.next;

// Output the next data value in the queue
statement = "\nQueue Contains:\n" + "Document Name: " + nextQueueNode.string1 + "\n" + "Document Owner: " + nextQueueNode.string2 + "\n" + "Document Size(KB): " + nextQueueNode.number +"\n";
return statement;
}
return statement;
}
}
(END CODE)

and hers the code that calls it for the applet
(CODE)
// Test for Display Queue button
else if (arg.equals("Display Queue"))
{
displayWindow.setText(appletQueue.displayQueueApplet());
}
(END CODE)
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a section of your code with some formatting added:



First, note that the bold "return" statement aborts the loop the first time through; having only the return after the loop will allow the loop to iterate through the queue.

Second, even if you fix this, you're assigning the entire contents of the String "statement" on each iteration through the loop, so the return value will be a description of only the very last entry in the queue. You need instead to add more data to the String each time through the loop. Consider using a StringBuffer and the append() method rather than adding so many Strings with "+".

Finally, again, please don't post the same question in multiple forums, especially not after somebody has already warned you and deleted the other copies of that same message! If you must, it's OK to reply in your own thread and say "Anybody?" or something like that. Thanks.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic