I’m creating a client window that retrieves from a javaSpace, this is the code I’m using.
/**
* Create the frame.
*/
public Client()
{
space = SpaceUtils.getSpace();
if (space == null)
{
System.err.println("Failed to find the javaspace");
System.exit(1);
}
initFrame();
setVisible(true);
processPrintJobs();
}
The window is generated inside of initFrame(); and then processPrintJobs checks to see if there are any new messages. If I comment out the processPrintJobs() method call then the window draws correctly but if the method call is there, the window just shows a blank square.
Its like the window is not being created correctly due to the process being checked lots of times, which makes no sense as the window is created before the while loop is run.
public void processPrintJobs()
{
while (true)
{
try
{
Message template = new Message();
if (channel == null)
{
System.out.println("No channel given");
} else
{
template.Channel = channel;
// System.out.println(channel);
template.position = new Integer(getNumber() + 1);
Message msg = (Message) space.read(template, null,
Long.MAX_VALUE);
messageList.append(msg.execute());
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
Use
But in general, the architecture of your application is missing some aspects.
Like a thread or whatever.
More:
You could for instance use a swing Timer, for one single job every tick.
To be called at the end of the Client constructor.
For the rest, consisting naming would have been fine: just class names starting with a capital and other names with a small letter.