JavaFX 2.0 :: TreeView Select Item 0 When Losing Focus
Oct 31, 2014
I have a case where I have a TreeView and I use it to select items from the tree. After I select each item I then clear the TreeView selection. Then, when I select outside of the window, the setFocused is called which in turn selects item 0 from the tree. I see in the TreeView.java the code,
private InvalidationListener focusedListener = observable -> {
// RT-25679 - we select the first item in the control if there is no
// current selection or focus on any other cell
MultipleSelectionModel<TreeItem<T>> sm = getSelectionModel();
FocusModel<TreeItem<T>> fm = getFocusModel();
[Code] .....
Is there anyway to suppress this behavior?
View Replies
ADVERTISEMENT
Apr 28, 2014
I'm making an application that will allow users to view several displays simultaneously. I'm trying to make it so that the user should be able to select one of the items from a list then hit a radio button add them to the display. And there will be a second button to remove them from the display. Oh and there will always be alteast one display.
View Replies
View Related
Jun 24, 2014
I am trying to have a user select from a printed out array list, instead of having the user type in the "bill type" each time there is a bill to avoid user error as much as possible. For example I would like to have it print out like this:
"Select bill type from list:
1. Rent
2. Car
3. etc..."
and I would like the user to choose a number and not type in the "bill type". I don't want to use "Switch case" because it would need to be an expanding and I don't think "switch case" can do that.
Here is the code:
package homebudget;
class Spending
{
//Do i need a totalAmount variable?
String type;
double amount;
int year, month, day;
public Spending()
[Code] ....
case 2:
//Give option to enter a new expense or pick from list.
//How to do this? If Statement that doesn't list duplicates, or a while search?
resp = JOptionPane.showInputDialog("Enter the type of expense:");
type = resp;
resp = JOptionPane.showInputDialog("Enter the amount of the expense:");
amount = Double.parseDouble(resp);
[Code] .....
View Replies
View Related
Oct 2, 2014
I have a JSF application with this code in the xhtml page:
<h:selectOneListbox id="selectProduct" size="10" style="width:10em; font-family:monospace" value="#{mybean.product}">
<f:selectItems value="#{mybean.products}" />
</h:selectOneListbox>
and the corresponding snippets of the Java code are:
// Class member variables
// ...
private String product;
private ArrayList<String> productValues;
private ArrayList<String> productLabels;
private SelectItem[] products;
// ... Various properties etc.
public String getLocation() { // Displayed on a page
[code]....
Most of this works correctly using only ArrayList SelectItem products without the two ArrayList and the separate SelectItem[], and the values and labels are put directly into products here. The menu works and I can select an item. However, I am unable to find the correct method for finding the index in the submit method,namely:
public void submit(ActionEvent e) {
showProduct = true;
prodNum = products.indexOf(product); // --- Here is the problem!
updateProduct();
}
which has not been changed here. In spite of trying out various ideas, prodNum always returns with -1, which means it cannot find the index of the selected product, where product is a String. Everything else seems to work correctly, and products.get(prodNum).getLabel() works if I manually give prodNum a valid index, but because it's -1 it fails.
View Replies
View Related
Jun 5, 2014
I create my own TreeCell class to customize the look of the tree items of a TreeView which is displaying java.nio.file.Path information.
To setup the CellFactory of the TreeView I used the following:
pathTV.setCellFactory( (TreeView<Path> tv) -> {
return new MyCustomTreeCell();
} );
This works... Now I tried to do some other things with my custom tree cell class so I created an instance of it
MyCustomTreeCell mctCell = new ...
Later I changed the code to setup the CellFactory
pathTV.setCellFactory( (TreeView<Path> tv) -> {
return mctCell;
} );
This doesn't work ... I did not see anything in my TreeView...
Here is the MyCustomTreeCell class:
public class MyCustomTreeCell extends TreeCell<java.nio.file.Path> {
private final ImageView icon;
public MyCustomTreeCell() {
super();
icon = new ImageView();
[Code] .....
View Replies
View Related
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
Jun 2, 2014
I want to ask if there is an option to set the vertical position of the node handles of the TreeView-control.
I used a custom TreeCell factory with icons of sizes between 24 and 64 pixel and the location of the handle is regardless of the size of the icon on top of the cell. So if you got large icons the view did not look so nice.What I want is a property or something to center the handle in the cell depending on the size of the cell. Is there such an option?
View Replies
View Related
Jun 3, 2014
Is there some equivalent of the Swing TreeWillExpand-listener for TreeView?
In my particular case I want to check whether some constrains are set to show some children before they will populated in the view.
View Replies
View Related
Mar 26, 2015
I want to do something when the treeitem collapsed or expanded,but both clicked the tree item icon and double clicked tree item can collapsed or expanded the tree item.so how to listen collapse and expand event?
View Replies
View Related
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
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
Feb 23, 2015
I am struggling to get a way to click within a Pane and select a Line. The Line has been drawn by the user and there can be numerous.
For example if you select a Vertex I can just ask if it contains the point. How would you do this for a line?
View Replies
View Related
Jun 20, 2014
I want to develop simple example in which I can select TreeView Nodes with Buttons(in some cases clicking on image and etc). I created this simple sample:
<pre style="" _modifiedtitle="true" jivemacrouid="_14032555963537721" ___default_attr="java" jivemacro="code" class="jive_text_macro jive_macro_code jivemacrouid_14032555963537721">
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.geometry.Insets;
[Code] ....
The question is how I can select tree Node when I click on a button. For example when I click on a button Item A1 I want to select tree idem Item A1.
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
May 15, 2014
1) Is it possible to have an item take up all the remaining space on a ToolBar?
2) Is it possible to align one or more items to the right side of a ToolBar?
View Replies
View Related
May 13, 2014
I made a simple test case using a ListView<String>.:
@FXML
ListView<String> listView2;
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
listView2.getItems().clear();
[Code] ....
Using Java8 I see that I see this wrong behavior:
select 3 elements from the list: you'll see the log of the ChangeListener that tell you every time all items selected
remove 1 element from previous selection: you will not receive the notification!!!
remove the other two elements: only when the selection is empty you will see a new notification from changeListener...
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
Jun 14, 2014
I have a multithreaded java program. I have a few worker threads which process data over a udp server. Then I have another thread for console input. The problem is when there is an error with one of the worker threads, and it prints to the console, my console thread loses "focus", that is, the while loop seems to no longer run. Here is the console thread:
Java Code:
public void run() {
Console c = System.console();
if (c == null) {
Logger.writeError("No console.");
System.exit(1);
}
while(true){
String login = c.readLine(">>>: ");
System.out.println("You entered: " + login);
}
} mh_sh_highlight_all('java');
When an exception is raised, it prints it to the console, and suddenly the program no longer shows the >>> prompt from above.
View Replies
View Related
Mar 30, 2014
I am trying Single signon to a different application from my application. i use redirect to open the new URL in a separate window. MY single signon works well. But i am losing the session values in my application.
Because of this when i close the new window and click on any link in my application, i am getting error sicne all application objects inside session are reset to null. how to retain the session values after Redirect.
View Replies
View Related
Jan 20, 2015
I've been using Java Advanced Imaging to convert tiff images to jpeg. The code I'm using is pretty simple, and I'll include it below:
Java Code: private static void convertImage(File tiff_src, File jpg_dest)
{
if (tiff_src == null || !tiff_src.exists()) throw new IllegalArgumentException();
try
{
SeekableStream stream = null;
[code]...
The problem when I run this code is that during conversion, the decoder or encoder seems to drop a good deal of black. I'd like to include examples, but the tiff images are about 30 MB...I've tried configuring the decode parameters, as well as the encode parameters, but like I said, somewhere during conversion I drop a good deal of the black from the image.
View Replies
View Related
Jun 20, 2014
A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting?
A. Looser coupling
B. Tighter coupling
C. Lower cohesion
D. Higher cohesion
E. Weaker encapsulation
F. Stronger encapsulation
View Replies
View Related
Apr 4, 2015
I'm creating a simple login screen and I need to focus on the first field "login" after I click a submit button, so when the page return. I tryed using JS :
window.onload = function() {document.forms[0].elements[0].focus();};
but it not worked. I need a solution if possible without using JS. I'm using raw JSF implementation without PrimeFaces or anything else like this.
View Replies
View Related
Feb 23, 2014
I want to focus at a JTextField, how to do that? Can setfocusable work?
View Replies
View Related
Aug 31, 2014
I have two JFrames: frame1 and frame2. frame2 currently has focus, and I want to determine which component of frame1 would have focus if I were to switch focus to frame1, hopefully without actually temporarily changing focus.
Is it the KeyboardFocusManager who keeps track of which element in each frame has focus? Or does each container itself keep track? How does Java figure out which element in a frame gets focus when I switch to that window?
View Replies
View Related
Apr 29, 2014
I'm facing a problem in controlling the focus traversal mechanism inside a jframe...as i want the focus to travel from top to bottom by pressing tab key regularly , but it travels left to right and then top to bottom through the textfields... The form looks like
textfield1 textfield4
textfield2 textfield5
textfield3
The focus travels from 1 to 4 , 2 to 5 and then rests at 3. but i want it to be like from 1 to 2 to 3 and then 4 and 5....
View Replies
View Related
Aug 1, 2014
I am working on a Java program to monitor meal consumption by members of an organization. They swipe their ID cards, enter PIN, and number of meals they want. System knows if dining room is open and what meal based on time. The system then prints out a receipt on an Epson TM-T88IV receipt printer.
The system is running in console mode. My problem is that when the system prints, a Notepad window pops up for milliseconds and then the Java program loses focus. The screen reverts back to Windows home screen. I'm using Windows XP, SP3 and the latest Java build.
How to prevent the loss of focus?
View Replies
View Related