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
ADVERTISEMENT
Jul 25, 2014
I would like to have a touchable listview and two image buttons underneath.
Eclipse allows me to do this but I suspect the touchable listview won't work.
public class MainActivity extends ListActivity implements OnClickListener {
.....
But I can't use
insClick.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
.......
}
});
Because the IDE does not like setOnClickListener, OnClickListener and onClick. How to allow a combination of listview and image buttons..
View Replies
View Related
Jul 5, 2014
SceneBuilder 2.0 on my computer shows no onAction for ChangeBox. How to get around this? Several of the Java coding options listed online do not work with JavaFx 2 and SceneBuilder.
View Replies
View Related
Jul 21, 2014
I have a ListView with ListCells that are complicated things containing other nodes. I want to turn of ListView selection behavior (so not allow selections) without turning of events to the ListCell nodes in the ListView.
View Replies
View Related
Jul 1, 2014
I can't figure out how using binding on selectionModelProperty in a ListView that is using MULTIPLE selection model. I want bind my bean in which I've a list of item A and the selection of that items into the List.
ListView<A> listView; listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
My bean return a ReadOnlyListProperty<A>
So I don't know how do:
listView.selectionModelProperty().bindBidirectional(bean.getItems());
View Replies
View Related
May 14, 2014
I have a selection listener attached to a TreeView as shown below
treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<Pair<VideoSourceType, String>>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<Pair<VideoSourceType, String>>> observable, final TreeItem<Pair<VideoSourceType, String>> oldValue, final TreeItem<Pair<VideoSourceType, String>> newValue) {
// do something
treeView.getSelectionModel().clearSelection();
}
};
What I want to do is to "do something" and then clear the selection so that it can be selected again. However, I cannot re-select the same item from the TreeView until I first select a different item.
View Replies
View Related
Oct 19, 2014
I want to synchronize a List<String> with the selected items of a ListView. In the real project, I want to synchronize the selected items of a TreeView and the selected images of a galery (custom control).
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
[Code] ....
In most cases, the program works as expected but sometimes there are some issues.
- For example, when I launch the application and select all the items with Ctrl-A, the event { [One, Two, Three] added at 0, } is fired so the list of strings contains incorrectly 4 elements [One, Two, Three, One].
- Another example, when selecting all the items (with Shift+End), two events are fired { [One] removed at 0, } and { [One, Two, Three] added at 0, }, that's correct. But when I remove the last element with Shift-Up, 3 events are fired { [Two] removed at 1, }, { [Three] removed at 2, } and { [Two] added at 1, } and an exception is thrown:
java.lang.IndexOutOfBoundsException: toIndex = 3
at java.util.ArrayList.subListRangeCheck(ArrayList.java:1004)
at java.util.ArrayList.subList(ArrayList.java:996)
at com.sun.javafx.binding.ContentBinding$ListContentBinding.onChanged(ContentBinding.java:111)
View Replies
View Related
Apr 20, 2015
I'm trying to add filtering content in ListView by selected date from DatePicker. Every position(movie) has it's emission date saved, so when you choose date that you're interested in, it will show just matching titles. I was trying to use this solution:
@FXML
private void initialize() {
titleList.setCellFactory((list) -> {
return new ListCell<Movie>() {
@Override
protected void updateItem(Movie item, boolean empty) {
super.updateItem(item, empty);
[Code] ....
But when I add new position and change date, that I'm filtering by, every title disapear and don't reload. How can I make this work with every change?
View Replies
View Related
Jun 16, 2015
I only want the context menu to be showen if the user is clicking on an actual listview item, not if they click anywhere else in the listview. I know this is possible and I found answers to similar problems, but in the end they didn't provide enough infomation for me to solve my issue. I found this example on how to do it with a list view containing String objects, but what if my list view contains another object, in my case a wrapper class? I have a wrapper class to keep track of the key, but I only display the value variable in the listview, through calling the toString method. So the cells still contain a wrapper.
class Wrapper(int key, String value) {
..
}
public String getValue() { return value; }
public SimpleStringProperty getValueAsProperty() { return new SimpleStringProperty(value); }
public String toString() { return value; }
[Code]....
But line 05 gives me a NullPointerException, why? I do this after I've set the items of the list view by doing listView.setItems(..).
View Replies
View Related
Dec 1, 2014
If I "embed" a ProgressIndicator inside a ListView it has an ugly border and a white background. It looks like there's a TextField below the ProgressIndicator.
Why does it behave like that and how to solve it so that the progress indicator is transparent.
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.ProgressIndicator;
[Code] .....
View Replies
View Related
Oct 3, 2014
I am using:
Java:..... 1.8.0_20JavaFX:... 8.0.20-b26
I have this class:
public class Person {
private SimpleStringProperty name;
public SimpleStringProperty nameProperty(){
if(this.name==null){
this.name=new SimpleStringProperty();
[Code] .....
I have this:
lista = FXCollections.<Person>observableArrayList();
lista.addAll(new Person("uno"),new Person("due"),new Person("tre"));
myListView.setItems(lista);
The problem is if I add /remove an item all is fine, the listView refreshes correctly:
Person p = new Person(tfld_textAdd.getText());
lista.add(0, p);
But if I change a value on an item into the observable list it doesn't:
lista.get(0).setName("new value");
I also have a table linked in the same way and the table workd correctly after I updated my Java version...
View Replies
View Related
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
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
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
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
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
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
Apr 10, 2014
I have a program thats ran over a network and is multi-player. However whenever I fire any bullets they do not fire on the other clients screen. Here's the code
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import java.util.*;
public class TankWar {
[Code] ....
View Replies
View Related
Oct 8, 2014
I am writing a program that solves sudoku puzzles. It has a Swing GUI with a "solve" button. I have written an actionListener class with an actionPerformed method that is invoked when the user presses this button. It is the following:
public void actionPerformed(ActionEvent event) {
try {
worker = new SudokuSolveWorker();
worker.addPropertyChangeListener(this);
worker.execute();
SolveFrame sf = new SolveFrame();
} catch (Exception exc) {
System.out.println(exc.getMessage());
exc.printStackTrace();
}
}
The code creates a worker, a new instance of SudokuSolveWorker. The worker.execute() statement causes the doInBackground() method of this class to be called. This solves the Sudoku. A property change listener "picks up" the result:
public void propertyChange(PropertyChangeEvent event) {
try {
System.out.println("" + javax.swing.SwingUtilities.isEventDispatchThread());
SudokuModel solvedModel = (SudokuModel) worker.get();
} catch (Exception exc) {
System.out.println(exc.getMessage());
exc.printStackTrace();
}
}
As I wrote, this works without freezing up the user interface in the sense that the program seems unstable. However, the user interface does not respond to "commands" (mouse clicks) anymore until the worker thread has finished.
In the first code fragment I create an instance of SolveFrame which is an extension of a JFrame. It is a simple frame with a "cancel" button. It is drawn on the screen, even though it is called after the worker.execute() statement. I'd like the user to be able to click this "cancel" button, after which the solving of the sudoku puzzle should be stopped. However, since the program does not respond to mouse clicks anymore, the "cancel" button cannot be pressed.
View Replies
View Related
Apr 22, 2014
I'm making a class in Android that takes a photo, list a photos in Listview, and then sends them all to server. I'm stuck on listing them. How to send them all to server.
Here is my code :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.photo_upload);
Button picBtn = (Button) findViewById(R.id.buttonPhoto);
setBtnListenerOrDisable(picBtn, mTakePiconclickListener,
MediaStore.ACTION_IMAGE_CAPTURE);
[Code] ....
Executing this code i can take a first photo and place it into listview. But on second photo listing it crashes..
View Replies
View Related
Dec 22, 2014
I have started to create a calculator using Java SWING. I am new to this and don't know a huge amount. I don't know what to do now.
How do I add actions to the buttons? So when the button is pressed it will appear in the text area?
Where do I put these commands also? Within public void gui?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
lic class Calc extends JFrame implements ActionListener {
private JButton ZeroButton = new JButton("0");
private JButton OneButton = new JButton("1");
[code]....
View Replies
View Related
Sep 7, 2014
I am learning out design patterns and doing a little fun project on Model Control View (MCV). I got the concept down, it is pretty simple for the most part. However my buttons are not working.
Here is the code:
public class Controller
{
private Model model;
private View view;
Controller(Model model, View view) {
this.model = model;
this.view = view;
[code]....
It runs but nothing. My other questions is how can I make a box that will print the results.
View Replies
View Related
Sep 18, 2014
Right now, i'm trying to do is when a user clicks on my GUI button, it would display a text of information on the button they selected. I'm using an arraylist of objects and i'm trying to input the function inside the mouse click function. But I'm not sure how to properly display that information. Here is my GUI code. I'm working on the raven button. I have animal interface, with a parent class of Bird, and child class of Raven. How I could display this correctly...
public class AnimalJF extends JFrame {
private JPanel contentPane;
private JTextArea textArea = new JTextArea();
/**
* Launch the application.
*/
public static ArrayList<Bird> Birdlist = new ArrayList<Bird>();
public static void main(String[] args) {
Birdlist.add(new Eagle());
[Code] .....
View Replies
View Related
May 22, 2014
So I have a Jframe that has a set of functions that act on a node. What I want to do is allow the user to expand the gui by creating new sets (copies) of these functions when they have more nodes.I thought of hiding extra sets and making it appear they are adding them by making them visible.
View Replies
View Related
Nov 6, 2014
I have made two classes. See below. But in my second class the buttons will not be show if I run the application.
class 1:
package h01;
import java.awt.Color;
import javax.swing.*;
public class kopieer extends JFrame{
public kopieer()
{
JFrame venster = new JFrame();
[code]....
class 2:
package h01;
import javax.swing.*;
import java.awt.event.*;
public class kopieerpanel extends JPanel implements ActionListener
{
private JTextField veld1;
private JTextField veld2;
private JButton actieknop;
[code]....
View Replies
View Related
Feb 21, 2015
In my if statement on line 46 & 47 im trying to add the buttons to the screen if the player has lost and the "game over" screen have popped up. But the buttons aren't showing... what am i doing wrong?
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
[code]...
View Replies
View Related