0

I want overlay canvas on progress bar.Please find the below image: I have created a progress bar and i have created a canvas. but i was not getting any info how to overlay canvas on progress bar as shown in image

    //program for horizontal progress bar
public class Progress extends JFrame {

    // create a frame
    static JFrame f;

    static JProgressBar b;

    public static void main(String[] args) {

        f = new JFrame("ProgressBar demo");
        JPanel p = new JPanel();
        p.setBorder(BorderFactory.createLineBorder(Color.RED));

        b = new JProgressBar(SwingConstants.HORIZONTAL);
        b.setValue(0);

        b.setStringPainted(true);
        p.add(b);
        f.add(p);
        b.add(new SwingDemo());

        // set the size of the frame
        f.setSize(500, 500);
        f.setVisible(true);

    }

}




//code for canvas
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
B R
  • 11
  • Please tell the details of what exactly you mean by "overlay a canvas on a progress bar" – Hovercraft Full Of Eels Feb 15 '20 at 14:44
  • means we have to insert canvas on progress bar as shown in the link. i have created a progress bar and canvas separately. but i need to insert canvas on progress bar – B R Feb 15 '20 at 14:46
  • Again, what do you mean "canvas on progress bar"? The picture shows the progress bar sitting on a canvas (or other container), the opposite of what you're requesting, not the canvas *on* the progress bar. – Hovercraft Full Of Eels Feb 15 '20 at 14:48
  • no .a rectangular box (canvas) which is marked with red color is sitting on progress bar.how can we achieve that using swing.any idea? – B R Feb 15 '20 at 14:51
  • 1
    Ah, I get you now. That is useful information and should be placed in your question, I think. If this were my application, I'd just create my own component that draws the bar and the image, and moves it along similar to a scroll bar's scrollbox. – Hovercraft Full Of Eels Feb 15 '20 at 14:55
  • Could you please give me idea, so that i can work on it – B R Feb 15 '20 at 15:02
  • Better still, have a look at MadProgrammer's answer [here](https://stackoverflow.com/a/28909255/522444). It is truly beautiful (1+) – Hovercraft Full Of Eels Feb 15 '20 at 15:35

0 Answers0