User Interface buttons on an image view - java

cell image
Im using this picture above for my app I am making on android studio. As you can see, the image has different cells; I want to the user of the app to be able to tap each cell and the colour will change.
I have tried putting buttons on top of each cell but the buttons do not overlap directly on top of the selected cell.
Please if anyone has suggestions on how I can create a user interface with each cell of the image, let me know.
Thanks

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.

LibGDX how to make scene2D notification label scroll inside container

I am making a small game with LibGDX, and for this game I need a small container, which is a scene2D Stack, and inside that container is a label.
My problem is, that this label may only be on one line, and if the label text is longer than the container width, then it has to slowly move/scroll from right to the left, so the player can see the entire notification text. and when all the text has been shown, then the sliding should start over.
The best example I can come up with, for the behavior, is a digital text sign like in the image below
Hope anyone has some guides or can show me some code, to get me going :)
If it was me, I'd create a table (label container) and a label(text) and change the position of the label accordingly and then reset it. Respecting all of the label.getwidth and so on

How to link JTexfeilds and their positions to JSlider?

Is it possible?
For example I have JTextfeilds which i use to label an image via a mouse pressed listener(makes new label every time the mouse is clicked).
I then move on to the next image and add more label(the images are attached to the JSlider).
So what im asking is whether or not it is possible to attach the labels i create for each image to the jslider? or possibly the image?
At the moment when i create new labels on the next image it keeps them when i return to the previous image.
Any help would be appreciated.
The images are depends on the JSlider by the user uploading a folder of images, the image names then get put into a list. Using a loop i then change which image is shown depending on the slider value.
1 partially labelled image
So this is the first images labelled with JTextfeilds.
New labels added on new image
This is a new image with some added labels, what i want to be able to do is return to the previous image without the new labels, while being able to go back to this image with the new labels.

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.

Categories

Resources