Reputation: 19
Can anyone tell me how i can make a progress bar go from 1 to 100 percent in a JOptionPane. Its not meant to show anything in particular or have any significance, its just for fun and to simulate something happening in the game to the user. Thanks!
Upvotes: 0
Views: 2507
Reputation: 1171
Simple example presented below, I hope that what you looking for.
public static void main(String[] args) {
JFrame frame = new JFrame("MessageDialog");
JOptionPane pane = new JOptionPane();
pane.setMessage("long message...");
JProgressBar jProgressBar = new JProgressBar(1, 100);
jProgressBar.setValue(15);
pane.add(jProgressBar,1);
JDialog dialog = pane.createDialog(frame, "Information message");
dialog.setVisible(true);
dialog.dispose();
System.exit(0);
}
Upvotes: 2