简体   繁体   中英

java progress bar animation

So I googled and searched for this, but I could find anything on it: I called this method in my code

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception exc) {
        System.out.print("failed to load look and feel");
    }

I then added a JProgressBar called progressBar and called upon this code when I click a button on my gui:

    progressBar.setBorderPainted(true);
    progressBar.setValue(progressBar.getValue()+1);
    Progresslabel.setText("Progress... "+progressBar.getString());

Progresslabel is just a label to display the progress. Now when I do this, The progress bar appears like this:

http://i.imgur.com/gXp5ByH.png

instead of like this on other applications:

http://i.imgur.com/M61Cd59.png

See how mine is very rectangular, and fills only part of the progressbar, not the outside? I want to know if there is a way to use the default system look and feel, but able to use the progress bars, and have them look like they do on other programs. Is there a way to do this? Thanks.

You can use SWT to make native widgets appear. Swing progress do their best to emulate the OS's widgets, but they are not the real thing. The lack of animated Windows progress bars is one of Swing's downfalls.

On the other hand, SWT uses real native widgets that look really nice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM