import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JProgressBar; import javax.swing.JWindow; import javax.swing.SwingUtilities; public class InditerminateProgressBar { public InditerminateProgressBar() { initFrame(); createProgressBarWindow(); } private void initFrame() { JFrame frame = new JFrame("Progress Bar"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 300); frame.setLocationRelativeTo(null); frame.setVisible(true); } private void createProgressBarWindow() { JProgressBar pb = new JProgressBar(); pb.setPreferredSize(new Dimension(200, pb.getPreferredSize().height - 4)); pb.setIndeterminate(true); JWindow win = new JWindow(); win.add(pb, BorderLayout.CENTER); win.setSize(pb.getPreferredSize()); win.setAlwaysOnTop(true); win.setLocationRelativeTo(null); win.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(() -> new InditerminateProgressBar()); } }