JavaFX 2.0 :: ImageView With Transparent Image Not Clickable
Dec 29, 2014
I created an ImageView with an image with transparent portions. I also did some scaling and moving, which I though might cause this effect, but that is not the case. When I click on the transparent portion of the image the onMouseClick event is not fired. Other mouse events (mouse enter, mouse move, mouse exit, ...) get fired. Only when I click on the non transparent part the click event is fired.
Image img = new Image(getClass().getResourceAsStream("barrel_icon.png"));
ImageView view = new ImageView(img);
view.setScaleX(0.5);
view.setScaleY(0.5);
view.setOnMouseClicked(new EventHandler<MouseEvent>() {
[Code] ....
The area between the barrel and the shadow belongs clearly to the image, however is transparent. I am wondering if there is a reason for this behaviour and what is the best way to work around this issue, as my image has large transparent portions and the non transparent parts are hard to click on. By the way this is all based on JavaFX 2.2.
I'm using Scene Builder 2.0 and have added an ImageView to the parent AnchorPane. I've added my PNG files for the app icon and the various buttons. I select the ImageView in Scene Builder and then crawl the filesystem to the project package folder and select the PNG for the Image. The assigned image is displayed in the Imageview in Scene Builder in both design mode and Preview mode.
While everything else shows up properly when the app is executed, the image assigned to the ImageView does not display.
How to find coordinates of transparent area in the image. I working on .png image which has transparent background and transparent area in the middle of the image. The transparent area in the middle look a like ellipse, so i want to find coordinate of top, bottom, left, and right of that area. I am using opencv.
I have tried to find pixels and from result that i got, i understand that pixel with rgb that equal to 255.0 255.0 255.0 is transparent. what i have in my mind is, if rgb with value that equal to 255 255 255 detected, i will put 1 into arraylist named transparent, and if it not equal to 255 255 255 i will put 0 into the list. So when i look into the list, if there is 1 0 or 0 1 it means that border between transparent area and colored area or vice versa. But, how to know if that border is between transparent area in the middle of image and the image, and not between background and the image. Am i doing this correctly?
Here snippet of code.
Mat imgMask = Highgui.imread(imgfile); double[] pixels = new double[3]; System.out.println("channel " + imgMask); for(int x = 0; x < imgMask.cols(); x++) { for(int y = 0; y < imgMask.rows(); y++) { pixels = imgMask.get(y, x);
I am unable to clear disappear the background of .png image added in a translucent JPanel. I have tried it using JLabel but the image added is with white background. How can i get rid of this white background...
import javax.swing.*; import java.util.*; import java.awt.*; public class HomePage { JFrame frame; JPanel pnl1, pnl2, pnl3; JLabel lbl;
On my code, I am getting errors to put ; after the public void's. I'm not sure where the problem is seeing as my textbook pretty much had the same code that I just transferred the different data to....
import java.awt.*; import java.awt.event.*; import java.applet.*; public class MoveIt extends Applet implements ActionListener { private Image cup; private Panel keypad;
I've been on this for a while and for some reason I just can't seem to get this to work. I know my code is solid, but it won't display my image. I've tried swithcing the image to different directories and also using different image sizes and types. I even used Orcale's guide to display your image, but still no go! All I get is a blank canvas? There are no errors. I'm also running NetbeansIDE 8 that supports JavaFX and I made sure the project is a JavaFX Application project.
The homework called for me to display it three times - the first one regular, second resized, and the last one rotated. I even deleted the extra images in hope at least one appears.
I would like to reopen the following discussion: Show SVG-Image in WebView (JavaFX 8)
In our IDE (Eclipse Luna) running with jdk1.8.0_25 we load a html page into the webengine. The html page contains <img> tags with '.png' and '.svg' as src. Everything looks fine.
But if we execute the programm with java -jar, the WebEngine doesn't display the svg-files. Instead it shows the 'File not find'-Icon. The .png files still work
The files are definitly included into the jar and will be displayed if we link to them via <a href="someSvg.svg"></a>
I'd like to draw an overlay on an image. The overlay is also an image with a black background and a white foreground. Now the white pixels should be drawn on the image in red. This is possible with the code I posted below. However, the problem arises when rotating the stencil (overlay). I get some interpolation errors from the rotation on the boundaries. I tried to clip them with setClip(), but this turns the background from transparent to white. How to remove those spots? Or maybe a completely other idea of achieving an overlay on the image? I'm aware of the pixelreader and iterating through the stencils pixels and draw the respective pixels as rectangles on a Canvas' graphicContext. However, this was extremely slow, compared to the code I posted below (although it doesn't work with rotations).
solve my problems regarding drawings on my JPanel(Transparent panel).My Jframe & other components are created by netbeans GUI builder & the transparent panel is created manually but one problem is that i can't impose this Transparent panel into JFrame like it is attached to the JFrame.Another problem is that,i want that transparent panel size should be counted in inch like my attached picture(TOTAL SIze 36 inch) & also when i clicked on that panel those mouse points highest distance should be measured in Inch.How can i do all of these three task??
I am building an application that shows tables with large amounts of data containing columns that should display a thumbnail. However, this thumbnail is supposed to be loaded in the background lazily, when a row becomes visible because it is computationally too expensive to to this when the model data is loaded and typically not necessary to retrieve the thumbnail for all data that is in the table.
I have done the exact same thing in the past in a Swing application by doing this:
Whenever the model has changed or the vertical scrollbar has moved:
- Render a placeholder image in the custom cell renderer for this JTable if no image is available in the model object representing the corresponding row - Compute the visible rows by using getVisibleRect and rowAtPoint methods in JTable - Start a background thread that retrieves the image for the given rows and sets the resulting BufferedImage in a custom Model Object that was used in the TableModel (if not already there because of an earlier run) - Fire a corresponding model change event in the EDT whenever an image has been retrieved in the background thread so the row is rendered again
Btw. the field in the model class holding the BufferedImage was a weak reference in this case so the memory can be reclaimed as needed by the application.
What is the best way to achieve this behaviour using a JFX TableView? I have so far failed to find anything in the API to retrieve the visible items/rows. Is there a completely different approach available/required that uses the Cell API? I fail to see it so far.
I have a class Tile that extends JPanel within the constructor for Tile I have set the opacity to false so that I can place tiles atop each other and see parts of the tiles below and the background through those parts of the tile that are not being drawn on. This implies that I am using paintComponent within Tile to display the image of the tile I want shown on this object.
The tiles are stacking perfectly. But I find that if I click on a tile through the transparent area of another tile, it is the top tile (transparent area) that retrieves the mouse click. This makes perfect sense, but is there a way to allow the mouse click to pass through transparent portions of the JPanel?
I've considered writing my own method to determine if the mouse click was within bounds then if it was outside the bounds of the object, find a way to pass the click event to the tile below. But this would be extremely challenging if the tiles were implemented as donuts (with holes in the center) or as some other obscure shape with transparent sections.
I'm working on loading SVG images on Jpanel using "Apache(tm) Batik SVG Toolkit" , but after the image get loaded it has "white background" and "not transparent" one like PNG images.
I checked "fill" of rect attribute on the xml file of the svg image and it was correctly set to none, I also Tested the image on html document and it was trasparent, but in my java app it has white background.
The Question is there any way to load SVG images with transparent background on Jpanel ?
Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.
I stored an image into MySQL database using swings and hibernate but I am struggling to retrieve that image from MySQL database and display same image in the jTable cell and same as on jLabel whatever I retrieve from the database using swings and hibernate .
I'm trying to make a method that takes an image and turns it into a tile image. So if the original image looks like this:
[URL] ....
then the output image should look like this:
[URL] ....
Here's a method that's supposed to do that but for some reason the output image looks the same as the original:
public static int[][] tile(int[][] arr){ int[][] tile = new int[arr.length][arr[0].length]; for (int i = 0; i < arr.length; i++) { tile[i]=arr[i]; } return tile; }
I recently changed the method and the error message I'm getting is "bad operand types for binary operator '+'. Here's the method:
public static int[][] tile(int[][] arr){ int[][] tile = new int[arr.length][arr[0].length]; for (int i = 0; i < arr.length; i++) { for(int j=0; j<arr[i].length;j++){ tile[j]=(tile[j])+(arr[i]); } } return tile; }
I'm trying to add an image icon to my application but since the code will be checked by another computer, I cannot use an image in my computer and use its file address. If I save the image in the project, is there a way to get the file address of the source code? Or is there a better way to add a unique image icon to the app?