• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Help on Applet idea

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone-
I'm new here and I'm a java beginner. What I want to do is make an applet (or japplet) where I have a .bmp or .gif that covers the whole applet plus extends beyond the borders of the viewable area. Then, when the user clicks, I'd like to have the screen move towards the direction of the click and stop when the click area is in the middle of the applet window.
For example, if I had a .bmp of a big painting, but the applet window was zoomed in so i could only see like 1/10th of the picture, I would want to click in the upper right hand corner, and see the applet scroll diagonally to where i clicked, and stop when that's in the center.
Is this possible? I would really appreciate any help with the general logic on making that happen, or if there are any code examples that do something similar, that would be great!
Thanks in advance
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could easily make a custom JPanel that draws part of an image. This is covered pretty well in the Java Tutorials, on Sun's site. The key method to override is paintComponent(Graphics g). You can also make that JPanel listen for mouse events, change the display region in response, and repaint() itself. Hopefully that will get you started.
P.S. I imagine it would also be pretty easy to do with a JScrollPane. You would just shut off the scroll bars and handle scrolling programatically in response to mouse events.
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic