Search code examples
javaswingprogress-barbreadcrumbs

using breadcrumb in Swing


I am working on a project where user faces 5 frames . Each frame contains the data to be filled . so when he completes the one frame and goes to next frame it has to confirm that the data is filled for that I want to use BreadCrumb(or progressbar).

so how to create a BreadCrumb(or progressbar) in java swings

I want to make similar to below image in java swings

enter image description here


Solution

  • I suggest that you

    • create 5 images to use as your breadcrumb images. Any basic image editing program can help you with this.
    • Put the 5 images in ImageIcons, and put the ImageIcons in either an array or an ArrayList<ImageIcon>.
    • Display the current Icon in a JLabel that is part of your GUI. You can easily set the JLabel's Icon via its setIcon(Icon icon) method.
    • I would strongly urge you not to use "5 frames" since that is an irksome user experience and is not what the user experiences when using a professional application.
    • Instead create 5 JPanels that handle each part of the process.
    • Swap these JPanels in and out of your GUI via a CardLayout-using JPanel, one that I assume will sit on top of the JLabel that displays your breadcrumb ImageIcons.
    • When you swap a JPanel view, you also swap an ImageIcon. This swapping will likely be done in the same method.
    • Remember that it is Java "Swing", not "swings". Good luck.