I am making a Class that extends JFrame and have my custom background image on it..
I have two problems..
1) I want my background image to stay fixed sized that covers whole screen when maximized. How can I do that?
2) I want to add a transparent button and panels on the frame that does not disturb my background. Is there any easy way to do that?
help will be greatly appreciated... thank you
Load the image into a BufferedImage.
Add a ComponentListener to determine when the frame is resized. Use the frame size to calculate scaling and call BufferedImage.getScaledImage(xScale, yScale) to obtain a scaled image.
In your class you should be overriding paintBackground() to do the painting. Just call g.drawImage(scaledImage, getWidth(), getHeight(), this) to paint the image.
Any components you add to the frame need to call setOpaque(false) so the background gets painted underneath them.
Related
I am trying to create an image map where there is one main image, and when you hover over certain areas different images come up.
Something like this How to apply Hovering on html area tag? but instead of creating an outline it would show different images.
I do not want to usse jQuery and would prefer to rely on CSS and HTML.
Thanks in advance.
You could cover smaller blank images over the large main image and use the hover code separately for each image
The non hover image is a "blank" png and the hover is the desired result
Just use the code for each "blank" image with the main image in the background with z-index of "0"
As said in previous answer, you could do this by using the z-index property. But try setting the main image's z-index as 0, and all small images(that you want to show over main image) as lower than 0.
And finally, activate by swapping the z-index between values lower or higher than 0 on mouse hover.
Hope this helps :)
I'm using Adobe Edge Animate and I'm really having trouble with all the different screen sizes and resolutions. I see that Adobe is coming out with new products which may address this issue. Basically all I'm tryng to do is have an image display (like a banner for example) that fills the width of the user's screen. I see the following questions, but answers are old and I know that there has been a lot of development in this area. Any ideas greatly apprciated.
Stackoverflow questions
From the splash screen. In the Properties tab change the switch next to the width to make it 100%. Select the Max W parameter and change this to too. All these tweaks will make the layout responsive. Next drag the image onto the stage and position in the top-left corner. In Properties click on Use Presets for Responsive Layout and choose the Center Background Image option, then Apply. This means the image will stay central whenever the stage morphs. Drag the bottom-right corner handle so the image fits over the entire background. Notice the image doesn’t scale or stretch but stays in the centre. In the Position and Size tab is an expand button; click this and add a Max W of (how many px your image is). Change the width to 100% and press Enter. It will jump right back to 75% but it has accepted the change. Click on the resize marker and drag to the left to see what happens when the stage is resized to a smaller layout. As you can see, the background is clipped but the image resizes to fit.
Here is a link to the tutorial I think this will better answer your question if you do this tutorial. http://www.webdesignermag.co.uk/tutorials/create-a-responsive-animation-with-adobe-edge-animate/
First time on stackoverflow, also my first time with HTML and CSS.
Basically I want a transparent image to be kind of "hooked" on to one specific point on the background, i.e. if I resize the browser window, the image should maintain its position relative to the background and should get smaller accordingly.
The reason I need this is because the image is animated and positioned to a certain spot on the background.
The easiest way I could show it is by actually showing it so: www.opinionoto.com
As you can see I want the speech bubble to always be right beside her face and maintain its position no matter what device or browser size.
This would be great help for me, I'm a super begginer! Thanks in advanced!
why not use multiple background images and position the second one accordingly where ever you need it?
Does the bubble move after the initial move? Can you just make the background a GIF image?
I just started learning flash on my own and I decided to make a cool little image gallery (somewhat of a family album). When I test the movie the first image loads in the center. Below the image are little thumbnail sized buttons which can be clicked and the image will load in the center. Since I am going to be incorporating a lot of photos I would like to use a Slider (left to right) so I can scroll back and forth through the photos and find the one I want to click on to display.
Since I have no experience with Action-script I was hoping someone could get me started with that process and maybe explain how the Slider works.
Thanks!
You can create easily your own slider, and learn something in process :) .
In slider - moving of knob, must correspond to moving of gallery where size of gallery is translated to size of slider. That is basically it. So you will need some mathematical formulas and basic elements:
gallery.width/slider.width - to determine if gallery is wider than
slider (so you would want to proceed with sliding), you can also use this proportion to determine a size of the knob. So if gallery would be smaller than slider - then you may not render slider, or make knob the size of slider, so it would be not movable. Or make knob proportional size to size of overflow of gallery - just experiment with everything I'm writing here.
You would need to use also those elements:
gallery (Display Object),
mask/container for gallery (the visible part of gallery),
slider,
knob.
Rectangle object
Gallery would be just a Display Object that contains all images as children.
Mask/container would be display object that would provide boundaries of area where part of gallery would be visible
Slider - any Sprite
Knob - any Sprite
Rectangle - would be of course Rectangle object, with width of slider.width - knob.width, and height of 0, so it would allow to drag knob along a slider without going outside of it, by using function:
knob.startDrag(false, rect); // Use it at MouseEvent.MOUSE_DOWN of knob
knob.stopDrag() // Use it at MouseEvent.MOUSE_OUT of knob
You can create rectangle with this code:
new Rectangle(0, knob.x, slider.width - knob.width, 0);
And you would need to translate moving of knob to moving of gallery which would be something like this:
// When moving knob you can use this formula:
gallery.x = knob.y / (slider.width - knob.width) * (gallery.width - mask.width); // Use it at MouseEvent.MOUSE_MOVE of knob
I think that should be it, I wrote it from the top of my head based on some library I wrote some time ago, so please tell me if you will encounter any problems, but I think that are all basics you need.
Have a look at the ScrollPane
Add your thumbnails in a container and use that as the Scrollpane's source and scrolling will be taken care of
I'm working on a swing program to display several pictures. And one can rotate the picture (implemented each as a JComponent).
Problem is, when a picture gets rotated, the border of the JComponent doesn't change so that the picture gets clipped.
Is there any way to also rotate the border so that the picture can be fully drawn?
(I know one can calculate the new size of the border, but it leaves empty space on the edge. When a rotated picture overlaps with another and one want to move the one underneath, one cannot do that because the event will be passed to the picture above, onto the transparent edge. So it is more ideal if one can just rotate the border).
Execute another pack() on your top-level JFrame after rotating.