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


ADVERTISEMENT

Swing/AWT/SWT :: Paint Application - Mouse Events In Same Class

Apr 15, 2015

I have my paint application, i use the following mouse event to draw my shapes (mousePressed, mouseReleased, mouseDragged). Now after the user paint a circle for example, he must be able to drag the shape; to be able to do this. i think i must again implement the different mouse Events. I have done it and the drag is not working. How can i achieve this. can we implement multiple (mousePressed, mouseReleased, mouseDragged) in the same java class??

View Replies View Related

Program Must Draw Line In A Panel Using Mouse Events

May 6, 2014

//this program must draw line in a panel using mouse events ..
  
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Line2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MouseTest {

[Code] ....

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 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 View Related

JavaFX 2.0 :: How To Set Mouse Position

Jun 19, 2014

How can I set a new Mouse position ?

Is there any class that represent the Mouse ...

The cursor class is without this ability ...

View Replies View Related

JavaFX 2.0 :: Detect Mouse Click In TreeView?

Jun 12, 2014

I want to create mouse click event. I tested this code but I cannot make it work:
 
treeView.setCellFactory(new Callback<TreeView<DynamicTreeNodeModel>, TreeCell<DynamicTreeNodeModel>>()
{
@Override

[Code].....

View Replies View Related

JavaFX 2.0 :: Mouse Event For Tree Node

Jun 10, 2014

I have a TreeView insight TabPane
 
treeView.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                if (mouseEvent.getClickCount() == 2 && mouseEvent.getButton() == MouseButton.PRIMARY) {
                    // Some action
                }
            }
        });

For some reason when I click on a tab body I can also perform the listener action. How I can add additional statement to perform the action only if I select node?

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 :: Stage Icon In Windows 7 Taskbar Mouse Event

Jan 15, 2015

I develop a desktop soft use javafx8, and remove default border (e.g. title and close/min/max button), now use mouse left key click the taskbar icon is nothing,i want click the taskbar icon,if stage it's show then hidden, if stage it's hidden then show it,the problem is I can't capture any mouse click event,so i can't show or hidden my stage.

View Replies View Related

JavaFX 2.0 :: Fancy And Animated Buttons

Jul 12, 2014

Can I make buttons like on this link:

Radioactive Buttons with RGBa and Animations | Playground from ZURB ?

In this link is of course code, but this code is in normal CSS, and when I was copying to editor JavaFx isn't work...

View Replies View Related

JavaFX 2.0 :: Scrollable Buttons Into VBox

Dec 26, 2014

I have a menu similar to this but wiht 20 buttons into a VBox:
 
How I can make scrollable, the elements it contains? (Buttons). Like a ListView in Android.

View Replies View Related

How To Access Methods From Other Classes Using Buttons In Javafx

Jun 4, 2014

I have a javafx class that has buttons and textfields. Here is the code for a button, and i want the button to make a new object but im having trouble setting the constructor

Label label = new Label("Type");
GridPane.setHalignment(label, HPos.RIGHT);
TextField textField = new TextField();

Label label2 = new Label("First Name");
GridPane.setHalignment(label2, HPos.RIGHT);
TextField textField2 = new TextField();

[Code] ....

after i create the object i will insert the object in an arraylist of person objects

View Replies View Related

JavaFX 2.0 :: Buttons In ListView Not Firing OnAction

Jun 2, 2014

I have an app that was working with JavaFX 2 on JDK 7 but seems to no longer work in JavaFX 8 on JDK 8.  The story is that I have a ListView where I have provided my own CellFactory.  Within the class that extends ListCell, in the updateItem() method, I create an HBox that contains some text and a new button. 

I register an onAction() callback for the button.  The end result should be a list with entries which contain buttons and when a button is clicked, the onAction() callback is invoked.  However, when I run it and click the button, the callback is NOT being fired.  This exact code was working on JavaFX 2 and JDK 7. 

View Replies View Related

JavaFX 2.0 :: Abnormally Closing A Dialog With No Buttons

Apr 14, 2015

I have a Dialog with no buttons (the dialog pane contains some graphic elements which act as my buttons). I show the dialog and try to click the close window button on the dialogs title bar, and the dialog does not close! I read the docs and it appears that only dialogs that have one or more buttons can be abnormally closed (and only under certain well defined sensible conditions). How can I abnormally close a dialog with no buttons?

View Replies View Related

JavaFX 2.0 :: VBox Scrollable - No More Buttons Ignore Swipe Gestures?

Jan 28, 2015

I have several Buttons wrapped into a VBox. I used setOnSwipeUp and setOnSwipeDown for up and downs the buttons. But when there is no more buttons the scroller continues but shows nothing, is empty. How do I do when there are no more buttons ignore swipe gestures?
 
[Java] // Menu Swipe Up menubox.setOnSwipeUp(new EventHandler<SwipeEvent>() {

View Replies View Related

Additional Methods From Specific Classes That Implement Interface

Jan 8, 2014

I am writing a game in Java for Android (although my question isn't Android or Game Dev specific).

I have a SceneManager class and a Scene interface and then various other classes that implement the Scene interface (Code at the end of this post).

Basically, in my MainGame class (which also implements the Scene Interface for Touch Event capturing purposes) I hold the bulk of my game code. Methods in this class are then called from my Level classes. (most of these are needed in all levels so it makes sense to hold them here and call them from the levels to eliminate unnecessary code duplication)

So, I have Level1, Level2......... Level20 classes which all implement Scene.

Now, the problem comes because in only 2 of my Levels something can happen (that can't in the other 18) and I need to run a response method in these 2 levels (the method isn't exactly the same, the response to this event happening is different for both levels).

To run common methods from my classes, I use my Scene Manager like this:

SceneManager.getInstance().getCurrentScene().updateLogic();
SceneManager.getInstance().getCurrentScene().render();

(The above is from my gameloop) - So it will run the updateLogic(); and render(); methods from whichever is the current scene (Level).

Scene is changed like so:

SceneManager.getInstance().setCurrentScene(LevelX);

This works great as all Level's have an updateLogic(); and render(); method.

So from my mainGame class, I am doing something like : (pseudo code)

public void checkIfSomethingHappened(){
if (something happens){
if (currentLevel==5){
Level5.response();}

[Code]....

The above would be called from my 2 level classes. So something like:

MainGame.checkIfSomethingHappened(); //Called in addition to the normal methods that make up that level

I don't really want to have this (second) 'if' statement here in the middle of my performance critical game loop.

What I'm after is something like this:

if (something happens){
SceneManager.getInstance().getCurrentScene().response();
}

However, this would require me to put stubs in the other 18 classes.

I'm thinking there must be a way to do this as the SceneManager already knows the current scene so it seems a waste checking it again via an if (or switch) statement. What is the best way to do this without having to put stubs into classes that don't require this method?

View Replies View Related

Swing/AWT/SWT :: Add JTextField And Additional Output Within ComponentEvent Handlers

Jan 30, 2014

Using the code from the Java Docs (listed below) I am getting behavior that was a bit unexpected. The only changes were to add JTextField and additional output within the ComponentEvent handlers. Run the code and when the frame appears, think of each side as North, South, East (right side) and West (left side) as you are looking at it. This was run using JDK 1.7.0_25.

Run the code.

1 - Click the East edge (right) of the frame and drag to be wider or more narrow. Only the "Resized" is executed for all components which makes sense.

2 - Click the West edge (left) of the frame and drag to be wider or more narrow. This time "Resized" is executed for all components EXCEPT it is "Moved" for JFrame. Why is it "Moved" here for JFrame but not in Step 1?

3 - Click the South edge (bottom) of the frame and drag to be taller or shorter. This time only 2 components are affected. JPanel is "Moved" while JFrame is "Resized".Why isn't both JFrame and JPanel just "Resized"?

4 - Click the North edge (top) of the frame and drag to be taller or shorter. This time only 2 components are affected again but the output is slightly different. JPanel is "Moved" while JFrame is BOTH "Resized" and "Moved".

There just doesn't seem to be consistency here. What are the guidelines or criteria for when these Events are to be executed?

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ComponentEventDemo extends JPanel
implements ComponentListener,
ItemListener {

[code]....

View Replies View Related

Adding Additional Field - No Suitable Constructor Found

Feb 9, 2015

I need to add an additional field (called client). When I try to do this, I get the "no suitable constructor found" error. I don't understand what I am doing wrong or where else to look.

package com.voxware.impl.wem.reports;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

[Code] ....

View Replies View Related

Servlets :: Multipart Form Data - Sending Additional Data?

Feb 21, 2014

I am using apache-commons-fileupload to get file from client to the server.(using JSP and Servlet).

JSP/HTML

<form method="POST" action="GetFile" enctype="multipart/form-data">
<input type="file" name="datafile">
<input type="text" name="text1">
<input type="submit" value="Next">
</form>

Servlet: GetFile

System.out.println(request.getParameter("text1"));

I am able to upload the file to the server, but I am not able to get the value of text1 in the servlet (I am getting null value of text1 in the servlet), I need this textfield in the form to submit some additional information while uploading it to the server.

--> Is enctype="multipart/form-data" option of form doesn't allow other form data to be submited? if it doesn't allow it then what are the other options I have to send this additional textfield to the server.

--> Or is there any other problem in my 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

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







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