How to use NinePatch image in Scene2d but not as button? - java

I'm having no problems using NinePatch images as buttons, but my problem is this:
I have one rectangle (An ImageButton using a NinePatch image) that when clicked on calls "clickedOn()".
Over-top of this rectangle I draw another ImageButton (using a NinePatch image) that doesn't have a listener attached, but it still cancels out the listener underneath.
Is there a better way to add a NinePatch image to the stage so that it is just a plain old image and doesn't block listeners? Or are NinePatch's added to a regular SpriteBatch rather than a Stage? (I was hoping I could just use a Stage as my renderer)
I tried stage.addActor(NinePatchDrawable) but that doesn't work.
Thanks

To let the click pass through I have found you can set the image to not be touchable
tempimagebutton.setTouchable(Touchable.disabled);
If anyone is aware of a better class to use than ImageButton to simply display a NinePatch on a stage though I'd appreciate the help

Related

How do I make it possible to scroll over an Image in Codename One?

I have a Codename One App that has Images in it.
However, whenever I'm trying to scroll when the cursor is on the image it doesn't work.
Edit:
1: (Some Component) Scrolling works;
2: (Image) Scrolling doesn't work
Link is HERE
Image img = Image.createImage(FileSystemStorage.getInstance().openInputStream(i.getImagePath()));
imgViewer.setImage(img);
imgViewer.setHeight(img.getHeight());
imgViewer.setFocusable(false);
This is the code that creates the ImageView.
The Image View is inside a Container which has the Layout BoxLayoutY (vertically scrollable)
That Container is in the Form which is the most bottom Layer, also set to BoxLayoutY
I suppose there must be some function that I can call to make it possible to scroll when the cursor is on an image, but I have no idea, which one that is.
Don't use ImageViewer use Label or ScaleImageLabel. ImageViewer grabs your pointer events to pan the image and allows zooming into it. It's designed for use over the entire Form and won't work well in a scrolling scenario.
If you want that functionality I suggest putting a small thumbnail in a Button then when it's clicked show the ImageViewer in a separate Form at the center of a BorderLayout.

Javafx ImageView real image position

I'm trying to realize a mouse over effect on a button.
What I have is a button with an ImageView in it. The ImageView displays a image in shape of a triangle. So there are areas inside the ImageView in which no picture is displayed.
Can someone explain me how it's possible to only start the mouse over event when the mouse move over the actual image (not the blank areas).
Many thanks in advance.

How to allow the user to resize an image in a JEditorPane by using arrows in the border's image

I have a JEditorPane with custom HTMLFactory which include some images. I want to let the user to resize the image with some arrows in the border of the image.
I'm using a custom view for resizing the image.
When I resize an image, the paint method is getting executed indefinitely and make me loose the positions of the images in the document.
Do you have some suggestions please ?
Thank you so much in advance

Java Swing : best way to set background image clickable

I try to find the best way to make an image clickable with different action depending on the area you click. For now, my window display an EFTPOS (image found on google image) using :
getContentPane().add(new JPanelBackground("./img/background.png", "./img/eftposAboveBackground.png", this.getWidth(), this.getHeight()));
Now, I would like to click on every EFTPOS's buttons. I was thinking of create some transparent buttons at the buttons's positions but :
First, I don't want to use an absolute layer
Second, the Swing GUI design editor (Netbeans) doesn't display my background image since I used the code above.
I'm pretty sure there is another way than setting my eftpos on the background, maybe using the ImageIcon class..
Any help would be greatly appreciated!
You can to create an ArrayList of Rectangles (or Shapes) to represent the area of each button on the image.
You need to add a MouseListener to the image.
In the mousePressed() event you need to iterate through all the Rectangle in the ArrayList using the Rectangle.contains(mouse point) method to see if the user clicked in a Rectangle.
When you find the Rectangle that was clicked you execute your custom code.

Android animation picture change

I want my program to do the following:
In frame there is a button and some image. When button is clicked I want this image move to the left until it will not be visible on frame (be outside of frame) and at the same time next image should come from outside of the frame to the center of it and stops there until the button is clicked again.
Should I inflate some ImageView everytime the button is clicked and change their x coord. though property animation? Or I can make two ImageView on frame and one of them would be transparent while other will be visible? And then change their positions and transparency level ("alpha") when button is clicked?
Which is the right way to do it?
A ViewFlipper might do what you want. From the javadoc:
Simple ViewAnimator that will animate between two or more views that have been
added to it. Only one child is shown at a time. If requested, can automatically
flip between each child at a regular interval.
Presumably, you can add two ImageView instances as children of the ViewFlipper and then animate between them with a slide animation. There are some answers on SO detailing this. Try searching for ViewFlipper.

Categories

Resources