• Post Reply Bookmark Topic Watch Topic
  • New Topic

JProgressBar not appearing properly

 
Stephen ODonnell
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i start up my application i want a progress bar to appear, but all that appears is a white box where the progress bar should be. The progress bar is in a class which extends a JWindow, and i call the JprogressBar using the following code:
import java.io.*;
import java.util.*;
public class columbaClient extends JFrame
{
ProgressBar progressBar = null;
.
.
.

public columbaClient(Vector AuthResponse)
{

progressBar = new ProgressBar();

progressInit();
.
.
}
private void progressInit()
{
progressBar.init(1,"initializing");
}

}
And this is my Progress class:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ProgressBar extends JWindow
{
public final static int ONE_SECOND = 100;
public static JProgressBar progressBar;
private Timer timer;
public static JTextField taskOutput;
JWindow frame = null;


public ProgressBar()
{
progressBar = new JProgressBar(0, 100);
progressBar.setValue(0);
progressBar.setStringPainted(true);
taskOutput = new JTextField();
JPanel panel = new JPanel();
panel.add(progressBar);
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout());
contentPane.add(panel, BorderLayout.NORTH); contentPane.addtaskOutput,BorderLayout.CENTER); setContentPane(contentPane);
//Create a timer.
timer = new Timer(ONE_SECOND, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
taskOutput.setText(taskOutput.getText() + ".");
}
});

}

public void startTimer()
{
timer.start();
}
public void updateBar(int nProg, String szProg)
{
progressBar.setValue(nProg);
taskOutput.setText(szProg);

if (progressBar.getPercentComplete()==1.0)
{
Toolkit.getDefaultToolkit().beep();
timer.stop();
frame.dispose();
}
}
public void init(int nTmpProg, String szTmpProg)
{
frame = new ProgressBar();
frame.pack();
frame.show();
frame.setVisible(true);


frame.setLocation(200 , 200);

updateBar(nTmpProg, szTmpProg);
startTimer();

}
}
any help would be greatly appreciated.
Stephen ODonnell.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!