Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

view before and after Tsunami

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can any java function let user drag left and right to view before and after Tusnami?
Please navigate to the following web site.
http://www.cnn.com/interactive/2011/03/world/slider.japan.photos/index.html?hpt=T2
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All you need to do is to change the crop of the overlay image.
 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:All you need to do is to change the crop of the overlay image.



I would like to lean and understand everything about Java, and I am wondering.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what Bear is saying is that you display one picture right on top of the other. then, one you change where the top one is cropped based on the mouse movement.
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tweaking JSplitPane could help you out. It will try to place the contents of both the left and right hand sides at the top left of its panes, but using either custom painting or a custom layout could help you out.

What may work (haven't tried it):
- create a JPanel with a FlowLayout set to have FlowLayout.LEFT as its alignment. Add a JLabel with the before image to it.
- create a JPanel with a FlowLayout set to have FlowLayout.RIGHT as its alignment. Add a JLabel with the after image to it.
- create a JSplitPane with those two panels
- tweak the JSplitPane (e.g. the divider size, divider location, etc) to get a better look
 
Rob Spoor
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right, and now I've tested it a bit. Quick and dirty:
The minimum sizes are required to allow one panel to be completely hidden by the divider. The setting of the preferred size of the JSplitPane is to prevent the left and right panels to both be shown initially (although this will still occur if the JSplitPane is resized).

Just one note: the setDividerLocation(0.5) doesn't work yet because if "the split pane is not correctly realized and on screen, this method will have no effect" (quoted from the Javadoc page of JSplitPane). Setting it to an int value based on the new preferred size should work though.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your could do that with Swing GUI components, such as JSplitPane as Rob showed, or by drawing the images yourself with the 2D graphics API.

You can find good tutorials here:

Creating a GUI With JFC/Swing
2D Graphics
 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for the program. I very appreciate you posting the program.



Rob Spoor wrote:Right, and now I've tested it a bit. Quick and dirty:
The minimum sizes are required to allow one panel to be completely hidden by the divider. The setting of the preferred size of the JSplitPane is to prevent the left and right panels to both be shown initially (although this will still occur if the JSplitPane is resized).

Just one note: the setDividerLocation(0.5) doesn't work yet because if "the split pane is not correctly realized and on screen, this method will have no effect" (quoted from the Javadoc page of JSplitPane). Setting it to an int value based on the new preferred size should work though.

 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Your could do that with Swing GUI components, such as JSplitPane as Rob showed, or by drawing the images yourself with the 2D graphics API.

You can find good tutorials here:

Creating a GUI With JFC/Swing
2D Graphics



Thank you for the tip.
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic