JavaFX 2.0 :: Drag Events Destroyed By Window Resize?

Jan 24, 2015

I've been having great success developing a drag-drop component for a JavaFX app, but I've run into an issue that has me completely stumped.
 
Specifically, I create a component that can be dragged around inside an anchor pane.  That anchorpane is nested in a split pane, which is nested in another anchor pane (the control's root element).
 
The issue can be described this way:
 
Case #1:  If I start the application as a small window, I can reposition the control by dragging it around the screen as I please.
Case #2: If I start the application and maximize the window, again, I can drag the control around the screen as I please.
Case #3: If I start the application, drag the control around a bit, then resize the window, the drag event handling breaks as follows:

1.  The control drag events will fire normally only within the bounds of the anchor pane's previous size.
2.  The mouse cursor's drag icon changes as I pass in or out of those bounds
 
I'm absolutely certain the anchorpane is resizing to match the parent window, otherwise Case #2 would not succeed.  I'm at a complete loss as to determine why the drag events don't fire within the bounds of the resized window after they've been fired within the bounds of it's previous size.
 
Understand the mechanism I'm using to establish the drag handling:  Once the controller is instantiated and added to the scene, an event listener on the class's parentProperty fires to attach the drag event handling to the parent node.
 
Previously, I was setting / clearing the drag handling on the parent node in the drag detection / drag dropped event handlers.  I had suspected that adding / removing drag events was causing the trouble and opted for this solution to ensure that the same event instance was being used each time.  Both methods have had the same result.
 
If you want to see the UI in action, here's a youtube link (it does not demonstrate the problem I'm having):
 
[URL]
 
Here's the code that I'm using, redacted for clarity:
 
public class FileSystemNode extends AnchorPane {
@FXML private AnchorPane fs_node_title;
private FileSystemType mFsType;
private Point2D mDragPoint;

[Code]....

View Replies


ADVERTISEMENT

Resize Window To See Programs

Jan 21, 2014

Whenever I make something in Swing, I always need to resize the window for me to see the graphics on the window. I have been told to use the pack() method on it, which I have, but the problem with it is that it just sets the window to a minimal size, only displaying the x + and -.For one of the "games" I made, it at first didn't work until resize, then I added a repaint() after the constructor and it worked for me, but when my friends download it they cannot see it.

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize

Jan 19, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). URL...

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implimentation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize?

Jan 16, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). Someone suggested to me to use this custom stretch icon class, found here:

[URL] ....

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implementation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Getting Jlabel Icons To Change Size With Window Resize?

Feb 20, 2014

I'm trying to create a chess program in java swing, and for the board I'm using an 8 by 8 array of jlabels stuck inside a jpanel with a grid layout. I would like the board to change size when the window changes size, and the grid layout accomplishes this succesfully, until I add the actual icons to the jlabels. Then the board just stays a fixed size. Someone suggested I use their "Stretch Icon" class, found here:[URL] ...., so I tried initializing the icons using one of the constructors in the class (the one that takes an image name and a boolean value for whether or not you want the resisizing to be proportionate (to maintain the aspect ratio)). However, the same thing happened. The board appears, but it does not resisize. To attempt to fix this problem, I tried simplifying my code, reducing the program to two jlabels within the jpanel, for which I then tried to set the image in the same way. Here is my simplified code:

import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;

[Code] ....

I'm misusing the stretch icon class, or just generally what's going wrong/how to fix it?

View Replies View Related

JavaFX 2.0 :: Manipulating Several Windows (Window Inside Window)

Apr 6, 2015

I am new to javafx I start using it instead of swing i used the scene builder for my forms the problem i faced i don't know how to have main screen with menu bar at top and depending the select from the menu it will open other windows and those window must be inside my window just like for example netbeans.

I don't need to open new window in separate i need all windows inside my main window and controlling over them minimize maximize perhaps.

View Replies View Related

JavaFX 2.0 :: Gesture Events In JFXPanel

Jun 30, 2014

I'll try to catch gesture events (ZoomEvent, SwipeEvent, etc.) from fx controls (e.g., an ImageView) that are embedded in a JFXPanel. However, no gesture events are thrown for the embedded fx controls.

I've read How to integrate javaFX gesture management in a complex Swing application? and it seems that "there is no gesture recognition in a JFXPanel".
 
But I've also tried this code SwingHtmlDemo - Pastebin.com that embedds an fx WebEngine in a JFXPanel. In this example, I can Zoom and Swipe the google map displayed in the WebEngine.
 
My Questions are:
How does the gesture recognition in the WebEngine work?
Can I reuse the gesture recoginition of the WebEngine for other fx controls embedded in a JFXPanel?

View Replies View Related

JavaFX 2.0 :: Drag And Drop TilePane

Jan 27, 2015

Any example of a drag and drop tilePanel with VBox as the children? Basically we would like to reorder the list based on user dragging a VBOX.

View Replies View Related

JavaFX 2.0 :: Using Events For Additional Mouse Buttons

Mar 14, 2015

Is there a possibility to use events for additional mouse buttons, like the next or previous mouse buttons, in javafx? If I use the setOnMousePressed event on a node, it only throws an event for the "PRIMARY" "SECONDARY" and "MIDDLE" buttons.
 
node.setOnMousePressed(new EventHandler<MouseEvent>() {   
      @Override public void handle(MouseEvent mouseEvent) {
          System.err.println("mouse button: " + mouseEvent.getButton());
     }
});
 
If I use this java application [URL] .... it is also possible to throw events for the next or previous mouse buttons of the mouse. But not in my javafx application.

View Replies View Related

JavaFX 2.0 :: How To Enable Multiselection In TableView Via Mouse Drag

Jun 11, 2014

I have multiselection working in my TableView but only via shift-click or using the keyboard but how do I enable the selection of several table rows via a mouse drag? It does not seem to work out of the box.

View Replies View Related

JavaFX 2.0 :: TreeView - Performing Drag / Drop With No Selection

Jul 14, 2014

How do I keep an item (TreeItem) from being selected when performing a drag -n- drop? I don't want it to be selected because it will end up making the target disappear (selection of TreeItem changes target panel).
 
Related question: Is there a way to "veto" a tree selection change as well?

View Replies View Related

JavaFX 2.0 :: Resize Animation For Stage / Scene?

Sep 18, 2014

I am looking for a way to find a resize animation for an application I'm developing.  I found this answer but I figure there could be a better method out there,
 
Java - How do I create a Resize animation for JavaFX stage? - Stack Overflow

I am just looking to select something in a list, then press a button which would enable the animation and enlarge the stage.  This will happen twice.

View Replies View Related

ActionEvent New Window JavaFx And Scenebuilder

Apr 8, 2014

I am trying code that When i press a button(New user), i want the event to send me to a new windows that i have created in Scenebuilder... I dont know why it wont work, i get this exception:

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)

[Code] .....

My controller.

package controllers;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;

[Code] ....

The main windows does work, but just when i press the button i get that nasty exception...

View Replies View Related

JavaFX 2.0 :: How To Set Divider Positions For SplitPane After Window Resizing

Sep 30, 2014

I would like to keep the same values of the positions for dividers (SplitPane) even if the width or the height of the window changes. I want to keep the proportion of the differents dividers. After resizing the window, the values of positions are not the sames ! I use this source without success :

  stage.widthProperty().addListener(new ChangeListener<Number>() {
  @Override public void changed( ObservableValue<? extends Number> observableValue, Number number, Number number2) {
               sp.setDividerPositions(0.40f, 0.02f, 0.54f);

[Code] ....

View Replies View Related

Events Associated With JMenuItems

Apr 24, 2015

So I am trying to finish this assignment I am not sure how to approach the last part of it. Basically, I need to give the drop down menu functions. For example if you press tennis it will give explanation about tennis lessons.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Color;
public class JMenuFrame extends JFrame implements
ActionListener {
private JMenuBar mainBar = new JMenuBar();

[Code] ....

Attached image(s)

View Replies View Related

Swing/AWT/SWT :: Multiple Key Events?

Feb 5, 2014

Can you have multiple key events? by that I mean say you press the right arrow key, or a number on the numeric pad, then you press the letter c. does the second key event get fired? and i can catch both events?

View Replies View Related

How To Use Events In Place Of For Loop

Jun 30, 2014

I have two questions:

1. I read somewhere that instead of looping through every player (below), you use could Events to do it for you:

for (Player player : this.getPlayers()) {
if (player.getLocation().getX() == 10) {
}
}

I'm not sure as to how to use Events in place of a for loop. I've been thinking on this for days, but I'm still stuck. Any example of using an Event instead of a for loop?

2. Is there any way to accept multiple connections on a server without using a while loop? Maybe use Events to handle the acceptance of connections?

View Replies View Related

Testing Events Within Inner Class Using JUnit?

Apr 17, 2015

How do you test the events within an inner class using JUnit

// File: : events/SomePanel.java
// Purpose: Show use of named inner class listener.
 
import javax.swing.*;
import java.awt.event.*;
class SomePanel extends JPanel {
private JButton myGreetingButton = new JButton("Hello");
private JTextField myGreetingField = new JTextField(20);
 
[Code] .....

Code extract taken from: Java: Inner-class Listeners

Taking the above example, do I need to use myGreetingButton.doClick to trigger this event to test the respective variables/values being used ? Also the Actionlistener inner classes is private so doubt I can access this from JUnit Test class.

View Replies View Related

JSP :: Drag And Drop Form Fields

Feb 28, 2014

I have a web application. I want to generate the UI part(basically html/jsp pages) to be generated dynamically using drag and drop of elements.So is there is any way that I can:

1: Have drag and drop of elements in jsps?
2: How I can create and store back the form attributes dynamically?

View Replies View Related

How To Drag JLabel Correctly Across JFrame

May 26, 2014

I am currently trying to make a method that will enable a jLabel to be dragged across the screen. I want to be able to drag the object pretty much anywhere on the screen(I hope to eventually make a destination for it where it can be dropped but I will get to that later). I have looked on various places on the internet on how to achieve this and the most simple solution does something like this:

Java Code:

jLabel6.setText("jLabel6");
jLabel6.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
jLabel6MouseMoved(evt);
}
});
private void jLabel6MouseDragged(java.awt.event.MouseEvent evt) {
x = evt.getX();

[Code]...

This actually works somewhat but it is very faulty. For example the jLabel keeps appearing and reappearing as I drag it. Furthermore when I drag it I can see a duplicate Jlabel being dragged as well in the top left hand screen. So how might I fix this?

View Replies View Related

Move Object During Drag And Drop

Jan 23, 2014

I am just trying to understand during a drag and drop how can I transfer the actual object instead of just creating a new one. I believe I am close but I cannot nail down where I am going wrong. Here is my code I am using to test this.

First/Main:

Java Code:

package main;
import javax.swing.SwingUtilities;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable(){

[Code] ......

When I drag the JPanels it just copies and makes a new one. I tested this by having a sysout send to the console a private int that I set during the initial creation of the object.

View Replies View Related

Drag And Drop Using Robot Class

Jun 4, 2014

Is it possible to do drag and drop using robot class instead of using TransferHandler class?

View Replies View Related

I/O / Streams :: Continuously Reading Watch Events

Dec 6, 2014

I'm trying to synchronize two folders and their sub directories between a client and a server. I have a modified version of this class which I've posted below. In my Client class, I create a WatchDir object and call its processEvents() method in an infinite loop. The method returns a myTuple object (a struct containing the event type and a path object) if an event is registered and null if not.

The problem is that this only seems to work for the first event to happen in the directory (i.e. if I add a file to the watched folder, my WatchDir object.processEvents() returns one Tuple with an ENTRY_CREATE event and never returns another Tuple for other file additions/deletions/modifications that happen after). I'd like for processEvents to be continuously called (hence the infinite while) returning a Tuple each time some event occurs.

My modified WatchDir:

import static java.nio.file.StandardWatchEventKinds.*;
import static java.nio.file.LinkOption.*;
import java.nio.file.attribute.*;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;

[Code] ....

View Replies View Related

JSP :: Java Server Sent Events Not Working Correctly

Oct 10, 2014

Code structure :

Server : Java Servlet
Client : Simple JSP
Communication : Server Sent Events every 1 second
Here is the problem.

My code needed the server to send updates every one second to the client as stated above. Hence, I added a while loop with a sleep of 1000 milliseconds in the servlet code as shown below. The following strange behavior is observed:

- While the server is sending updates to the client, and the client window closes by mistake, the server does not stop sending updates It continues sending the data.
- When the client is re-opened, it sends data much faster (almost double). For example, the server sends 60 seconds worth of updates (60 updates) in just 25-30 seconds. The server sends faster updates not only for this round of updates, but also for any subsequent updates.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
PrintWriter writer = null;
try{

[Code]......

This server behavior is much unexpected. Am I writing the server side code wrong? I have looked around a lot and only found while loop method for modifying the server update interval. Is there any other method which I am missing?

View Replies View Related

Capture OS Event And Reproduce Sequence Of Events

Feb 10, 2014

Need to develop a Java application to listen to all user events occurring in the (initially only Windows) operating system to record some kind of record and to reproduce the sequence of events below ...

View Replies View Related

Drag N Drop MP3 File Using JFilechooser To JTable

Jan 21, 2014

including Drag n Drop a mp3 file using jFilechooser to jTable

View Replies View Related







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