JavaFX 2.0 :: TableColumn CellValueFactory Invoked For Every Cell Update - Normal?

Apr 10, 2015

I have a JavaFX 8 TableView with multiple columns.  The CellValueFactories for the columns are set as:
 
xxxColumn.setCellValueFactory(new ItemCountFactory(itemName));  

where itemName is a String identifying a different item for each column.
 
ItemCountFactory returns a StringBinding as the cell value, as follows:
 
    public ObservableValue<String> call(CellDataFeatures<Category, String> rowData) {
        return new ItemCountBinding(rowData.getValue(), itemName);
    }
 
where
     class ItemCountBinding extends StringBinding {
     ...
          protected String computeValue() {
                    String cellValue = ...;
                    return cellValue;
          }
     }

The StringBinding depends on properties of the Category instance for the table row.  The correct data is displayed okay, but I have noticed that every time one of the Category properties changes (i.e., every time a cell value changes), ItemCountFactory is called again to create a new StringBinding.  I would have expected the Factory to be invoked just once for each cell during initialization, and then the table column would monitor the returned Observable object.  Instead it seems to be creating a new Observable object every time the cell value changes.  Is this normal, or am I doing something wrong?  Same behavior on Java 8u20 and 8u40.  If it is not the expected behavior, I will write an example test program; I do not want to post the current full source code.
 
The table items are set just once, with:

     countTable.setItems(categoryList);

where categoryList is of type ObservableList<Category>.  The list itself is not modified after being associated with the table; i.e., no rows are added or deleted or replaced.

View Replies


ADVERTISEMENT

JavaFX 2.0 :: Set Callback Which Is Invoked When MenuItem Focused

Apr 14, 2015

I would like set a callback which is invoked when a MenuItem is focussed. Is there a way to do so?

View Replies View Related

JavaFX 2.0 :: Why Bind Of Width Of TableColumn Is Not Working

Oct 1, 2014

I would like to bind the width of the second column of my TableView with the width of my TableView.
My custom TableView class :

public class CustomTableView<T> extends  
TableView<ObservableList<Pair<String, Object>>> implements Cloneable {  
private static Logger logger = Logger.getLogger(CustomTableView.class);  
private double prefWidth; // optionnel   private double minWidth; // optionnel  
private double maxWidth; // optionnel   private double height; // optionnel  
private List<InfoColumnBean> cols; // optionnel 

[Code]....

View Replies View Related

JavaFX 2.0 :: Change Justification Of TableColumn Headers?

May 26, 2014

I have a table column and I want to change the columns header justification from center justified to left justified. How do I do this, either via code or via CSS.

View Replies View Related

Swing/AWT/SWT :: Update JTable Cell Values Inside A Loop

Jan 5, 2015

I have a program where i want to indicate the user when i have completed a task which i am running inside a for loop. Below is my code.

for(Map.Entry<Double,SimplestCopyInstance> entry : myList.entrySet()){
double key = entry.getKey();
SimplestCopyInstance scp = entry.getValue();
Copy cp = new Copy();
cp.putLocations(scp.getSrc(), scp.getDes());
scp.setStatus(cp.baseCopy()+"");

[Code] ....

I have used netbeans to build my app. So there creating jTable is out of my control as that part was inside auto-generated code. I have just used the jTable.setValue().

My problem is, above method is inside a button click event. Updated values not displaying until the loops ends.

View Replies View Related

JavaFX 2.0 :: TableView Cell Colouring

May 12, 2014

Here is another cell colouring question with a different take. Say you have a TableView with three columns - Category, In and Out. You add an empty row and then you start editing the Category column. When you have added a category you would like to see a change in the colour of the other two column cells in the same row depending on the category value. 
 
Say if the category is 'income' then the 'In' cell will become green and the 'Out' cell becomes red. The important point here is that these cells and the underlying domain object does not have any values associated with these columns yet. The cells are empty and colour change is to show the user where the value should be put for the given category (into the green cell ).
 
Therefore after the category value is committed a 'message' needs to be propagated from the category column to the current row (or the whole table) to repaint itself. I have tried calling the following methods from the Category column's 'commit()' method but neither of them triggers a repaint:
 
- getTableRow().requestLayout();
- getTableRow().updateTableView(getTableView())
- getTableRow().updateIndex(getTableView().selectionModelProperty().get().selectedIndexProperty().get());
 
Once the re-paint is triggered then both In and Out column table cells can take the current category value from the underlying domain object (say MyRecord) like this
 
        MyRecord record = getTableView().getItems().get(getTableRow().getIndex());
         String category = row.getCategory();
and call the setStyle(".....") on the cell to change the colour.

View Replies View Related

JavaFX 2.0 :: TableView Single Cell Selection Styling

Jun 6, 2014

TableView selection model allows selecting single cells in the table but the default styling highlights the whole row regardless of the actual column selected in the row.

I am just wondering what options are there to change this behaviour so that the actual cell (row/column) get highlighted rather then the whole row.

Something like the $18,000 cell in the  "Figure 1 Table overview"  in [URL] ....

View Replies View Related

JavaFX 2.0 :: Styling A TableCell To Indicate Focused Cell In TableView

Sep 15, 2014

I am trying to style the TableCell that has focus in a TableView to simulate how Excel does it. Excel uses a white background with a 3px black border which seems to be centered on the nominal cell edges. That is (and this is issue I am having), the border extends outside of the nominal cell boundaries.
 
My first naive attempt was to to override the CSS for .table-cell as follows:
 
.table-cell:selected:focused
{
  -fx-background-color: white;
  -fx-text-fill: -fx-text-base-color;

[Code]....

Doing this fixed problem (1) from the first attempt since this approach tweaks the background colors without affecting overall TableCell size. However, it still puts the black border completely inside the cell. My attempt to set -fx-background-position to a negative value in an attempt to offset the background seems to be ignored.
 
Having done this before using a Flex AdvancedDataGrid, my solution was to add a layer on top of the grid which renders the focus rectangle. I wonder if I would have to do a similar thing here.

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

JavaFX 2.0 :: Unable To Bind Text Property Of Selected Cell Of TreeView To Label

Jun 5, 2014

I try to bind the text-property of a selected cell of a TreeView to a label. So if the user click on a cell in the treeview the label should show the cell text. Now I am quite confused about the options I got to do so. Should I use label.textProperty().bind( ... ??? ... ) The treeview.onMouseClicked()property? or something different?

View Replies View Related

JavaFX 2.0 :: How To Prevent User From Leaving Tableview Editing Cell In Case Of Errors

May 14, 2014

I have a TableCell that will hold numbers in a tableview. All is working work nicely, but I want the following behavior:
 
- when the user begins to edit such a cell, if it doesn't enter a number, the cell will not call commitEdit, but rather display a red border and prevent the user from changing the focus to anything else until he either: enters a correct number or presses ESC.
 
I don't know how to keep the user in that editting cell if while he has an incorect number. Currently he can click other row/control and he will break the edditing state. I repeat, I don't want the user to be able to click on any row/control until he has a correct number.

Here is my cell implementation:
 
public class EditableIntegerCell extends TableCell<Person, Integer> {
    private TextField textField;
    @Override
    public void startEdit() {
        if (!isEmpty()) {
            super.startEdit();
            createTextField();
            setText(null);

[Code] .....

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

JavaFX 2.0 :: Update Observable List From Database At Certain Time Intervals Using Threads?

Dec 9, 2014

i have a table UI and want it to be to be in sync with tabledata in the database... How can i go about it?

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

EJB / EE :: Verify If Interceptor Is Invoked

Oct 20, 2014

I have an interceptor (configured with beans.xml from the following link, IBM Specs) on JAX-RS resource method for checking user entitlements. How can i verify if the interceptor (method annotated with @AroundInvoke) is being invoked?

View Replies View Related

Swing/AWT/SWT :: TableColumn - Cannot Set Text

May 30, 2014

I recently encountered a scenario where attempting to set the text for an SWT TableColumn widget fails with an InvocationTargetException / SWTError and the message "Cannot set text". There is nothing special about the column text, i.e. no special characters or mnemonics. It just fails. The same code works for other scenarios.

I took a look at the SWT source for the TableColumn class and found only one place where the "Cannot set text" error is thrown - see code fragment below - but I cannot see why I should have encountered a problem.

/*
* Bug in Windows. When a column header contains a mnemonic character, Windows does not measure the text properly. This causes '...' to always appear at the end of the text. The fix is to remove mnemonic characters and replace doubled mnemonics with spaces.
*/

boolean replace = !OS.IsWinCE && OS.WIN32_VERSION <= OS.VERSION (4, 10);
long /*int*/ hHeap = OS.GetProcessHeap ();
TCHAR buffer = new TCHAR (parent.getCodePage (), fixMnemonic (string, replace), true);
int byteCount = buffer.length () * TCHAR.sizeof;
long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
lvColumn.mask |= OS.LVCF_TEXT;
lvColumn.pszText = pszText;
long /*int*/ result = OS.SendMessage (hwnd, OS.LVM_SETCOLUMN, index, lvColumn);
if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
if (result == 0) error (SWT.ERROR_CANNOT_SET_TEXT);

View Replies View Related

JavaFX 2.0 :: How To Define Cell In The Table By Table Event

Mar 23, 2015

How to define Cell in the table by table event?
 
I need to process one component drag to the table. I misunderstand, how I can see to which Cell fall the component. I tried to use Event and Mouse event handlers in my custom Cell, but they do not work. I can copy the drag event to the table and table handles it, but how to get needed Cell I cant understand.

View Replies View Related

Java Array Update Without Using ArrayList - Add Values And Update Size?

Feb 9, 2015

I am trying to create an array list without using the built in arrayList class that java has. I need to start the array being empty with a length of 5. I then add objects to the array. I want to check if the array is full and if not add a value to the next empty space. Once the array is full I then need to create a second array that starts empty and with the length of the first array + 1.

The contents of the first array are then copied into the new array without using the built in copy classes java has and then the new array ends up containing 5 elements and one null space the first time round. The first array is then overwritten with the new array containing the 5 elements and the null space. The process then starts again adding values until the array is full which will be 1 more value then recreating the second array empty and the length of the first array + 1. This is my attempt at creating this but I have run into multiple problems where I get only the last value I added and the rest of the values are null:

public class MyArrayList {
public Object arrayList[];
public MyArrayList(Object[] arrayList) {
this.arrayList = arrayList;

[code]...

View Replies View Related

JSF :: Update Action Does Not Update Bean Attribute

May 14, 2014

I have a strange behaviour when trying to update a bean. Here is the edit page:

<h3>Edit Post</h3>
<div class="row">
<h:form>
<div class="small-3 columns">
<label for="right-label" class="right inline">Title</label>

[Code] ....

Here is the bean class:

package com.airial.controllers;
import com.airial.domain.Post;
import com.airial.service.PostService;
import com.ocpsoft.pretty.faces.annotation.URLMapping;
import com.ocpsoft.pretty.faces.annotation.URLMappings;
import org.springframework.beans.factory.annotation.Autowired;

[code]...

postToUpdatet is always NULL. Why the title property is not binded ? What is wrong here ?

View Replies View Related

How To Check PDF Is 3D Or Normal In JAVA

Jul 14, 2014

I just want to check that the given PDF file is 3D PDF or normal PDF file. how can I do this in JAVA?

View Replies View Related

How To Run A Normal Java Program Without Main Method

Nov 19, 2009

Is it possible to run a program(a method) without a main method?

View Replies View Related

Calculate And Display Normal / Overtime And Total Pay

Sep 12, 2014

The pay rate is php 35.00 per hour. any hours worked after 40 hours is paid at rate of 2 times the normal hourly rate. Calculate and display the Normal Pay, The overtime pay, and the total pay.

OUTPUT MUST BE:

Sample 1 :

Enter Hours Worked: 40 (Sample)
Normal Pay: 1400 (Sample)
Overtime Pay: 0 (Sample)
Total Pay: 1400 (Sample)

Sample 2 :

Enter Hours Worked: 41 (Sample)
Normal Pay: 1400 (Sample)
Overtime Pay: 70 (Sample)
Total Pay: 1470 (Sample)

Here is my code or something, but i cant finish it.

import java.util.Scanner;
public class Workpay {
public static void main(String[]args) {
Scanner in = new Scanner (System.in);
int hours;
int normalpay = 35;

[Code] .....

View Replies View Related

Possible To Make Vertical Menu Instead Of Normal Horizontal One

Sep 18, 2009

I was wondering if it is possible to make a vertical menu instead of a normal horizontal one. Like this:

Menu 1

Menu 2

Menu 3

And when you then click on one of them you get:

Menu1

Menu2

Menui tem 1

Menui tem 2

Menui tem 3

Menu 3

Is this possible?

View Replies View Related

JSF :: Passing Parameters From Normal List Object Without Using DataModel

Oct 9, 2014

How to use the id parameter in my documents entity to download documents from a list of documents. Normally I use ListDataModel and the getRowData method. I would like to know how to achieve the same thing using an ordinary List object.

My list of documents is called List<CountryDocs> selectedDocs;

<h:form>
<p:dataTable value="#{countryDocBean.selectedDocs}" var="docs">
<p:commandLink id="download" value="Download" ajax="false">
<p:fileDownload value="#{countryDocBean.downloadedFile}"
contentDisposition="attachment"/>

[Code] ....

Clicking on the download link calls the following method in my managed bean:

@ManagedBean(name = "countryDocBean")
@SessionScoped
public class CountryDocBean {
private List<CountryDocs> selectedDocs;
public StreamedContent getDownloadedFile() {

[Code] ....

Debugging shows the value for the id is 0 and this results in a NullPointerException. I've tried several methods for grabbing the document id in my backing bean, but no luck yet. I also read about the the ViewParams and ViewAction method but they caused validation errors to do with the <f:metadata> tags. I don't know how to obtain this value using a normal List object.

View Replies View Related

How To Get Normal HTML JavaScript Function Value To Java Code

Sep 15, 2014

I am executing html file in the browser with out server , i want get the data executing html file javascript function value to java code.

View Replies View Related

Can Change Arraylist To Have Number Images Rather Than Normal Text Numbers

Apr 9, 2014

I was wondering if it would be possible if i can change the arraylist to have number images rather than NORMAL text numbers?

View Replies View Related







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