Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Java
  4. How to make a scrolling background for a JPanel in java?

How to make a scrolling background for a JPanel in java?

Scheduled Pinned Locked Moved Java
javaalgorithmstutorialquestion
9 Posts 2 Posters 86 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Corona
    wrote on last edited by
    #1

    How to make a scrolling background for a JPanel in java? I tried searching google but couldn't find a helpful one.

    L 1 Reply Last reply
    0
    • M Mr Corona

      How to make a scrolling background for a JPanel in java? I tried searching google but couldn't find a helpful one.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Do you mean manual scrolling, or something that scrolls by itself? And how would that affect any other controls that are in the panel?

      M 1 Reply Last reply
      0
      • L Lost User

        Do you mean manual scrolling, or something that scrolls by itself? And how would that affect any other controls that are in the panel?

        M Offline
        M Offline
        Mr Corona
        wrote on last edited by
        #3

        I have a jpanel with an image as a background . how can i make that scroll like in a game ?

        L 1 Reply Last reply
        0
        • M Mr Corona

          I have a jpanel with an image as a background . how can i make that scroll like in a game ?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          See this suggestion: java - Scrollable JPanel - Stack Overflow[^]. And this How to Use Scroll Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)[^]

          M 1 Reply Last reply
          0
          • L Lost User

            See this suggestion: java - Scrollable JPanel - Stack Overflow[^]. And this How to Use Scroll Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)[^]

            M Offline
            M Offline
            Mr Corona
            wrote on last edited by
            #5

            sir i don't want scroll panes . i want my jpanel background image to scroll horizontaly automatticaly.i am making a game. :(

            L 1 Reply Last reply
            0
            • M Mr Corona

              sir i don't want scroll panes . i want my jpanel background image to scroll horizontaly automatticaly.i am making a game. :(

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Maybe a JPanel is not the right control to use. There are many game engines that you can use to do what you want. Take a look at Unity Real-Time Development Platform | 3D, 2D VR & AR Engine[^]

              M 1 Reply Last reply
              0
              • L Lost User

                Maybe a JPanel is not the right control to use. There are many game engines that you can use to do what you want. Take a look at Unity Real-Time Development Platform | 3D, 2D VR & AR Engine[^]

                M Offline
                M Offline
                Mr Corona
                wrote on last edited by
                #7

                But I have seen many people making that using pure java. Sir please if it is not possiblie Please help me for this:- I am using this code to make an image the background of a jpanel -

                @Override
                protected void paintComponent(Graphics g) {

                super.paintComponent(g);
                    g.drawImage(bgImage, 0, 0, null);
                

                }

                Sir how can make the background a gif using this code. Sir please help me. I beg.

                L 1 Reply Last reply
                0
                • M Mr Corona

                  But I have seen many people making that using pure java. Sir please if it is not possiblie Please help me for this:- I am using this code to make an image the background of a jpanel -

                  @Override
                  protected void paintComponent(Graphics g) {

                  super.paintComponent(g);
                      g.drawImage(bgImage, 0, 0, null);
                  

                  }

                  Sir how can make the background a gif using this code. Sir please help me. I beg.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  You need to try a few things, this is not a simple case of adding one component which will automatically do it. There is another suggestion at java - Making image scrollable in JFrame contentpane - Stack Overflow[^] but I have no idea if it will be exactly what you want.

                  M 1 Reply Last reply
                  0
                  • L Lost User

                    You need to try a few things, this is not a simple case of adding one component which will automatically do it. There is another suggestion at java - Making image scrollable in JFrame contentpane - Stack Overflow[^] but I have no idea if it will be exactly what you want.

                    M Offline
                    M Offline
                    Mr Corona
                    wrote on last edited by
                    #9

                    Sir you are the only one who replied to my questions. I am very very thankfull for you.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups