• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

JProgressBar not appearing properly

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic