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.

View Replies


ADVERTISEMENT

JavaFX 2.0 :: ImageView Image Created In Scene Builder 2.0 Doesn't Display In Running App

Sep 9, 2014

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.
 
From the FXML file:

<ImageView fx:id="ivBRULogo" fitHeight="64.0" fitWidth="64.0" layoutX="14.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0">
         <image>
            <Image url="@BRU_PE_B_64.png" />
         </image>
      </ImageView>
 
What might be occurring between the compiled app and what Scene Builder generates?

View Replies View Related

How To Get Coordinates Of Transparent Area In Image

Mar 25, 2015

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);

[Code] .....

View Replies View Related

How To Make Image Transparent In JLabel And Put On Top Of Another

Feb 19, 2014

i want to make a image transparent and to place it on top of anotherHere's the code:

Java Code:

import java.awt.*;
import javax.swing.*;
public class gameWorld extends JFrame {
public static void main(String[] args) {
new gameWorld();

[code]...

View Replies View Related

Unable To Remove White Background Of PNG Image Added In Transparent JPanel

Sep 25, 2014

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;

[Code] .....

View Replies View Related

Trying To Create Clickable Applet But Won't Compile

Apr 18, 2014

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;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: How To Enlarge The Clickable Area Of A JButton

Jan 30, 2015

what I have already tried:

to set the margin of a button - didn´t work
to set anything like padding - didn´t found something for java
to set an empty border - didn´t work

I don´t know what to try next.

My main problem is to enlarge the clickable area without resizing the buttons image.

View Replies View Related

JavaFX Will Not Display Image

Oct 21, 2014

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.

All I get is a blank new window, but no images.

Here's my code:

package javafxapplication3;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.image.Image;

[code]....

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.

View Replies View Related

JavaFX 2.0 :: How To Save Image As JPG

Apr 10, 2015

My JavaFX code like this:

WritableImage image = scene.snapshot(null);             
File outputFile = new File("C:PSBJavaFXApplication1src est0.jpg");
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "jpg", outputFile); 
 
When open this jpg, its background is in orange color. For png type, it works great.

View Replies View Related

JavaFX 2.0 :: Superscript Over Image?

May 28, 2014

I have an image (16x16 icon). I want to put a superscript 10 on it -- so a 10 above and to the right.

I can probably do this with a TextFlow node, but that seems very heavy for such a simple thing.

Is there some simpler way to do this?

The 10 isn't a fixed constant (so I can't just edit my image).

View Replies View Related

JavaFX 2.0 :: Show SVG-Image In WebView

Dec 2, 2014

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>
 
So why it doesn't work.

View Replies View Related

JavaFX 2.0 :: How To Save A Scene As Image

Apr 9, 2015

I am new in JavaFX, I download/installed JDK8 with NB. I am trying to save a scene as image (png or jpg), but the result png is blank.

Here is the Java simple code:
----------------------------------------------------------------------------
import java.io.File;
import static javafx.application.Application.launch;
import javafx.embed.swing.SwingFXUtils;
import javafx.print.PrinterJob;
import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
import javafx.scene.image.WritableImage;

[Code] ....

View Replies View Related

JavaFX 2.0 :: Display Image In WebView From External Directory

Jun 18, 2014

I have a WebView and a Javascript that appends an <img> tag in a webview.
 
Like so:
 
function insertImg(src) {
   $("body").append("<img src='" + src + "'/>");
}
 
I call this function with the following code:
 
String path = "file://Users/rod/Desktop/123.gif";
webengine.executeScript("insertImg('" + path + "')");
 
However, this does not work and no image is displayed.
 
How can this be achieved?

View Replies View Related

JavaFX 2.0 :: Image Overlay Rotation Interpolation Error

Jun 12, 2015

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).

Here I surrounded the errors:
 
The image:
 
The stencil:
 
And here is the code:
 
import javafx.application.Application; 
import javafx.geometry.Insets;
import javafx.scene.*;
import javafx.scene.effect.BlendMode;
import javafx.scene.image.*;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

[Code] .....

View Replies View Related

Transparent Panel Drawing

Apr 23, 2015

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??

View Replies View Related

JavaFX 2.0 :: How To Dynamically Load Image Into TableView When Its Row / Cell Becomes Visible

Jan 24, 2015

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.

View Replies View Related

Allow Clicks To Pass Through Transparent Portions Of JPanel?

Nov 15, 2014

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.

View Replies View Related

Swing/AWT/SWT :: Loading SVG Images On JPanel With Transparent Background

Mar 27, 2014

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 ?

View Replies View Related

Swing/AWT/SWT :: Image Manipulation - Create Application Where Image Is Displayed On One Label

Apr 7, 2014

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.

View Replies View Related

Retrieve Image From MySQL DB And Display In Jtable If Image Type Is Medium Blob Using Swings And Hibernate

Jan 5, 2015

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 .

View Replies View Related

JSP :: String URL For Image In Database And Show Image In File

Dec 24, 2014

I had string url for image in mysql database and I want show image in mu jsp file bu I can't.

<c:forEach var="urun" items="${listUrun.rows}">
<tr>
<td><c:out value="${urun.kitapresim}" /></td>
<img src="<c:url value="${urun.kitapresim}" /> " width="270" height="190"/>

URL...

View Replies View Related

JButton Image Does Not Show On Background Image

Feb 23, 2014

I successfully added a background image on the Panel but I can't create my JButton image on top of my background image.

ImageIcon piano = new ImageIcon("src/img/piano_backgrd.png");
JLabel backlabel = new JLabel(piano);
panel.add(backlabel, new Integer(Integer.MIN_VALUE));
backlabel.setBounds(0, 0, piano.getIconWidth(), piano.getIconHeight()); 
JButton volup = new JButton(new ImageIcon("src/img/volup.png"));
volup.setLocation(10, 0);
panel.add(volup);

View Replies View Related

How To Turn Image Into Tiled Image

Nov 21, 2014

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;
}

View Replies View Related

How To Hide Image In Another Image

Mar 3, 2014

how to hide an image in another image in java

By using Steganography we can hide text in an image. But how it works for image.

View Replies View Related

How To Add Image To GUI

Jan 27, 2015

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?

View Replies View Related

How To Add Image In JPanel

Mar 18, 2015

how do i add image in JPanel

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved