JavaFX 2.0 :: How To Not Show ListView ContextMenu When Right Clicking On Null

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


ADVERTISEMENT

Use JTable To Show Contents From MySQL Directly Without Mouse Clicking

Jan 31, 2014

i want to make adding into mysql database and then when i click adds, jtable show those data automatically. but it seem to get error at display part, it shows " Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - illegal start of expression" and jtable do not show the added data but in mysql, data is properly kept.

private void jtPropertyChange(java.beans.PropertyChangeEvent evt) {
DefaultTableModel model = (DefaultTableModel) jt.getModel();
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url, user, password);
String sql = "SELECT * FROM `companya`";

[Code].....

the adding part seems to be fine

View Replies View Related

JavaFX 2.0 :: Turn Off ListView Selection

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

JavaFX 2.0 :: Binding On SelectionModelProperty In ListView

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

JavaFX 2.0 :: Re-selecting Item From ListView

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

JavaFX 2.0 :: Binding ListView Selected Items

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

JavaFX 2.0 :: Filtering ListView By Selected Date

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

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 :: Progress Indicator In ListView Has Border And White Background?

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

JavaFX 2.0 :: Modifying Item In Observable List Doesn't Update ListView

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

Clicking On TextField Will Show Some Required Text Under Text Field

Mar 15, 2015

I am trying to run a simple program in which on clicking on the TextField will show some required text under the Text Field .Here is my code:
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 class Awt
{
public static void main(String...s)

[Code] ....

I am expecting the on clicking anywhere inside the text field should show me the Text : "Mouse Clicked" . But i am getting this error:

Awt.java:77: error: cannot find symbol
tf.f.setText("Mouse Clicked");}
^
symbol: variable f
location: variable tf of type Awt
1 error

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 :: Why Splashscreen Of Application Doesn't Show

Jul 11, 2014

I built my application under Windows XP (x32), Eclipse Luna (x32), JDK 1.8 (x32 - beta version B116).
 
When i launch it, the splashscreen (preloader) appears !
 
I rebuilt my application under Windows 7 (x64), Eclipse Luna x64, JDK 1.8.0_20 (x64).
 
When i launch it, the splashscreen doesn't appear !!!
 
For information, The structure of my application :
 
app
     | libs
          | preloader.jar
 
myapplication.jar
 
runtime
 
The behavior of JDK 1.8.0_20 about the management of the preloading mecanism is it different of the behavior of JDK 1.8 (B116) ?

View Replies View Related

JavaFX 2.0 :: Sometimes Form (BorderPane) Does Not Show Correctly

Feb 11, 2015

We have a problem with a JavaFX application running on Java 7. Sometimes a form (BorderPane) does not show correctly – it seems to be transparent (i.e. content previously shown at the same place is still visible). Controls seem to be present and respond to events – e.g. we can close the form by blindly clicking the appropriate button. Once the issue happens it is persistent, i.e. next time we open the form, it behaves the same.
 
We have no reproducible scenario leading to the issue. It just happens here and there – we have not been able to identify any pattern yet.
 
Additional information:

The form (BorderPane) is loaded during application start-up but it is not shown initially,to show the form we remove previous contents from a StackPane and add the form instead,to hide the form we do the reverse. 

View Replies View Related

JavaFX 2.0 :: Adding Tooltip On Cell Of TableView In Order To Show Some Information To User

May 21, 2014

I'm trying to add a tooltip on a cell of a TableView in order to show some information to the user.
 
This is the code:

colonnaColore.setCellFactory(param -> {
            TableCell<Appuntamento, Template> cell = new TableCell<Appuntamento, Template>() {
                @Override
                protected void updateItem(Template item, boolean empty) {
                    // calling super here is very important - don't

[Code] ....
 
In few words: there is a cell factory on the cell to show a colored box, then I added a tooltip to the cell. I need informations that are in the item added to the TableView that has type "Appuntamento". So I try to get my element with these code (that in others part of my code works); but here I get a Null Pointer Exception on cell.getTableView() and also on cell.getTableRow().
 
I'm probably using these methods in a way that was not expected.

View Replies View Related

Null Pointer Access Variable Can Only Be Null At This Location

Apr 16, 2014

I'm getting an error on line 137 and all it is rsmd = rs.getMetaData();The error happens only after I press a JButton and it is

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionat softwareDesign.createAccount.actionPerformed(createAccount.java:137)

There is a lot more to it but that has nothing to do with my code it's just the stuff with Eclipse anyway I want to know how do I fix this problem?

View Replies View Related

New Lines Don't Show Up In File But They Do Show Up On Console

Apr 30, 2015

I have the following code.

class A {
List<StringBuilder> list;
public void output(List<StringBuilder> objectToOutput){
try(BufferedWriter bw = new BufferedWriter(new FileWriter("temp.txt"))){
for(StringBuilder row:objectToOutput) bw.write(row.toString());
}catch(IOException e){}

[code]....

Why don't the a's show up on the console? I put them in as part of the debugging process and now I don't understand why they don't show up in both places.

View Replies View Related

Touchable Listview And Buttons

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

Why To Get Result Brand Null / Colour Null

Feb 28, 2015

public class Test {
public static void main(String[] args) {
Car c = new Car();
c.setInf("toyota", "red");
System.out.println("name: "+ c.brand + " colour: " + c.colour);

[code]....

Why do I get the result brand null, colour null? I know what null means but what am I missing here?

View Replies View Related

Listing Photos Captured In ListView - Sending To Server

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

MouseListener - How To Increase A Value By Clicking It

Dec 25, 2014

I want to make a simple game and learn java by experimenting with it.I don't know how to increase a value by clicking it.I know how to make my objects move in my small game with mouse or keys, but I also got a score var that I want to increase per click. I can increase it over time, but after 2 hours of trying I couldn't progress any further.This is the piece of code I used, I imported the class, got getters n setters and all of that...

if(e.getButton() == MouseEvent.BUTTON3) hud.setScore(hud.getScore() + 555);
Whenever I click I get an error, if I remember right "NullPointerException" is when something is missing I'm probably not targeting the value correctly...
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.tutorial.main.MouseListens.mouseClicked(MouseListens.java:22)
at java.awt.Component.processMouseEvent(Unknown Source)

[code]...

View Replies View Related

Program Keeps Clicking On MM Continuously

Feb 3, 2014

I am writing a script for a program, now I am very new to Java. So, issue I am having is the program keeps clicking on the MM continuously. I just want it to click each spot 1 time.

Here is my code :

public class ToPortal implements Strategy {
Tile Portal = new Tile(2681, 2591);
Tile To = new Tile(2667, 2601);

[Code] ....

View Replies View Related

Double-clicking Jar Files?

Nov 10, 2009

I've been programming for a while, but I never made executables... just ran it from the compiler. Now, however, I really want to have an icon for one of my programs that would be conveniently located and clickable. So, I made a jar file, both in Eclipse and BlueJ. When I run this file in command line, it works fine (with "java -jar ..."). In case of Eclipse, this worked with both "jar" and "Executable jar" options. However, when I double click the icon, nothing happens. First I was getting "can't find main class" error, but that was an easy fix with the manifest file. But now, nothing seems to happen at all. Could this be because the program is supposed to run in the command line or whatever the compiler offers and there is nothing to force the computer to open one of those windows?

View Replies View Related

Clicking Href Button With Java

Dec 1, 2014

as there is a button on the website, that I need to click, but it returns a number using javascript that will access the page. Without that number, accessing the page won't work. Therefore, either I need to click the button, or return that data when I access the url. Here is the line in the html.

<a href="/missions.php?jid=11&cat=2&formNonce=49af09362db790 a6b364401c4ea52a08b515df4a&h=284e4fe4946e6fb8af3a6 62f4583454eebc8bd23" class="actionButton" onclick="return fsb11('5494');">Do It</a>

View Replies View Related

Applets :: Display A Picture By Clicking On Checkbox?

Jan 22, 2014

ItemListener: checkbox component

I want to display a picture by clicking on the checkbox.

Here is my code:

public class Dukes {
String action;
String friend;
public String getActionImage() {
return action;

[Code] .....

View Replies View Related

How To Change JLabel Text By Clicking On JButton

Feb 25, 2015

Here's my coding so far...I want to be able to change what the JLabel says when clicking on one of the buttons for example : when clicking on UP i want it to say "Going Up!"...how do i do this?

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
 public class BorderLayoutJFrame extends JFrame {

[Code] .......

View Replies View Related







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