JavaFX 2.0 :: Scene Not Laying Out Properly

Mar 12, 2015

Have have just started working with JavaFX and SceneBuilder having been a long time Swing developer.
 
My first foray into the world of JavaFX involves building a rather simple desktop application to parse text based log files with regular expressions.
 
Currently I am working on the main window for this application.  I built a scene in SceneBuilder using a BorderPane for my root.
 
I placed a TitledPane which contains a TableView in the center section of the BorderPane and a VBox which contains several Buttons in the right section of the BorderPane.  When I view the layout in SceneBuilder using the Preview menu item to show the preview in a Window, SceneBuilder shows the scene laid out exactly as it is in the work are and as I would like it laid out.
 
When I close SceneBuilder and go back to my IDE (Eclipse) and build and run the application the scene is displayed in a window differently than in SceneBuilder preview.  When the application executes the scene is laid out as if there has been something placed in the top section of the BorderPane, the TitledPane containing the TableView is centered in the window and the VBox containing the buttons are not aligned with the top of the TitledPane containing the TableView because it is as if there is a "null control" in the top section of the BorderPane.
 
Why is there a difference in the way SceneBuilder displays the scene and the way the executed application displays the scene?
 
Also, I recently made some changes to the layout of the controls in SceneBuilder (e.g. changed some padding and location of some controls in their containers and again the scene looks perfect in SceneBuilder but when I execute the application now some components in the container where I made the changes are truncated when the scene is displayed when the application executes.
 
It is almost as if SceneBuilder is interpreting the FXML one way and the JavaFX API during run time is interpreting the FXML another way.

View Replies


ADVERTISEMENT

JavaFX 2.0 :: How To Save A Scene As Image

Apr 9, 2015

I am new in JavaFX, I download/installed JDK8 with NB. I am trying to save a scene as image (png or jpg), but the result png is blank.

Here is the Java simple code:
----------------------------------------------------------------------------
import java.io.File;
import static javafx.application.Application.launch;
import javafx.embed.swing.SwingFXUtils;
import javafx.print.PrinterJob;
import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
import javafx.scene.image.WritableImage;

[Code] ....

View Replies View Related

JavaFX 2.0 :: Set Busy Cursor For A Scene

May 15, 2014

My problem is simple. Just set busy cursor on a scene. The scenarios is like this: I have simple application with a button on it. When I click the button, I will:

1. Set mouse cursor to BUSY
2. Do some work
3. Set mouse cursor back to DEFAULT.
 
I search the web and found some sample codes to set cursor. But they don't satisfy my need. So I wrote a simple application:
 
public class MainFormApp extends Application {
  @Override
  public void start(Stage stage) throws Exception {
       stage.initStyle(StageStyle.DECORATED);
        Pane root = new Pane();
        root.setPrefSize(500, 300);
        Button btn = new Button("Click me");       

[Code] ....
 
When I run application and click the button, cursor does not change to BUSY. I also tried to use Platform.runLater() but no luck.

View Replies View Related

Integrating MySQL Into JavaFX Scene Builder

Jul 4, 2014

I am new to javafx and my goal is to basically just test if my java code works with Mysql. What I'm planning to do is to display one data of the sakila database into a Label named greetingLabel. And I can't seem to find where i went wrong so i'll show you my whole code.

Here is the main code for my controller class from scene builder:

package main;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;

[Code] .....

Here is the error displayed when pressing the button

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)

[Code] .....

View Replies View Related

JavaFX 2.0 :: Access Scene Graph Data From EDT

May 11, 2014

I have following methods, which I call from the Event Dispatcher Thread:
 
public void setTitle(String title) {       
Platform.runLater(() -> stage.setTitle(title));}   
public String getTitle() {       
return stage.getTitle(); // <- Access from outside JFX App Thread ok?} 

Is it thread-safe, when the getter-Method just return the value like the example show? Or must I create a Runnable, so stage.getTitle() is called inside the Java Application Thread? How I return the value then?

View Replies View Related

JavaFX 2.0 :: Scene Builder On High DPI Screen

Jun 6, 2015

I'm trying to follow the Scene Builder tutorials on a 3200 X 1800 screen which makes the size of the content pane 3'' x 2" ....

View Replies View Related

JavaFX 2.0 :: Resize Animation For Stage / Scene?

Sep 18, 2014

I am looking for a way to find a resize animation for an application I'm developing.  I found this answer but I figure there could be a better method out there,
 
Java - How do I create a Resize animation for JavaFX stage? - Stack Overflow

I am just looking to select something in a list, then press a button which would enable the animation and enlarge the stage.  This will happen twice.

View Replies View Related

JavaFX :: Slot Machine In Netbeans - Scene / Stage

Oct 21, 2014

I want to create a slot machine in NetBeans, with JavaFX library (without using JavaFX Scene Builder) but i have some problems to create UI.

I created algorithm already but without visuals.

Now my code is:
 
public class BEST extends Application {
private ImageView var; //init imageview of images
public static void main(String[] args) {
launch(args);
 
[Code] ....

createbottom(); and creategr(); i wrote already (and my program creates grid pane of random images with double dimension array, random and imageview) and program runs, but i don t know how to keep track of credits balance,in the same time to create new random gridpane of images and to get rid of every gridpane.

Here is creategr();
 
private GridPane creategr(){
final GridPane creategr = new GridPane();
int[][] newarray=new int[3][3];
int w=100;
for(int i=0; i<3; i++){
for(int j=0; j<3;j++)

[Code] ....

Button "SPIN" is created in createbottom();.

View Replies View Related

JavaFX 2.0 :: Custom ComboBox Implementation Not Recognized By Scene Builder 2.0

Jun 3, 2015

I did an implementation which is an extension of javafx.scene.control.ComboBox

Inside I imported the Class ComboBoxListViewSkin

import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin;
 
I think this might be the reason as this comboBox is not recognized at the import to the scene builder library. I can show up the import dialog of custom controls, but my custom ComboBox is not showing up. All other implementations are there correctly as they are loaded from my customControl.jar file
 
I use the ComboBoxListViewSkin for the functionality to scroll to an item in the combo as a user types a letter on the keyboard.

I do this by:

/**
     * This method scrolls the itemView of the items to the first item starting
     * with the given char or string
     *
     * @param pressedKey
     */
    public void scrollToChar(String pressedKey) {
        String value = pressedKey.toUpperCase(); 
        for (Object userEntry : getItems()) {

[Code] ....
 
I really need to show up my custom Combo in the scenebuilder, as otherwise the rest of my fxml is not editable in sceneBuilder 2.0 ....

View Replies View Related

JavaFX 2.0 :: Why Does Scene Builder Constantly Create New Instances Of Nodes

Nov 28, 2014

I thought I had a simple idea for creating a control that would let me get some of the behavior of a card pane.  This is the entire control:
 
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;

[Code] ....
 
The idea is pretty simple; extend StackPane, add an active property, bind the visible and managed properties of the pane to the active property, and, whenever the active property is changed to true, iterate sibling nodes de-activating any siblings that are also of the type Card.
 
However, this doesn't work with Scene Builder.  While trying to debug, I created an ExtStackPane:
 
import javafx.collections.ListChangeListener;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
public class ExtStackPane extends StackPane {
    {
        getChildren().addListener((ListChangeListener<Node>) c -> {
            System.out.println("ExtStackPane children change: " + c.toString());
        });
    }
}
 
All this does is log list change events.  However, I was very surprised by the output when working in Scene Builder.  I added both controls to Scene Builder and did the following:
 
0) Added an ExtStackPane
1) Added a Card to the ExtStackPane
2) Added another Card to the ExtStackPane
3) Added a Label to the first Card
4) Added a Label to the second Card
5) Changed the text of the first Label to Hello
6) Changed the text of the second Label to World
7) Set the first Card to active
8) Set the second Card to active
 
I get the following output:
 
1)
ExtStackPane children change: { [Card@5b9067b3] added at 0 }

2)
ExtStackPane children change: { [Card@6b6328bd] added at 0 }
ExtStackPane children change: { [Card@6aca8cc5] added at 1 }

[Code] ....
 
This is what things look like in Scene Builder:
 
Does Scene Builder recreate the entire hierarchy every time I make a small change?  Here's an application that does the same as the manual steps I performed in Scene Builder:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class CardApplication extends Application {

[Code] ....

The output when running the above is:

1)
ExtStackPane children change: { [Card@6dfaa767] added at 0 }

2)
ExtStackPane children change: { [Card@6aa2c411] added at 1 }

[Code] ....
 
The behavior is obviously a lot different than when I'm working with the control in Scene Builder. What Scene Builder is doing to change the behavior of my Card control so much?  Does my Card control break some rule(s) I'm not aware of?

View Replies View Related

JavaFX 2.0 :: Multiple Scene And Passing Variables With FXML Files

Mar 21, 2015

Lets say I have a desire to convert and entered value to Centigrade or Fahrenheit and that I have two Radio Buttons to designate the type of conversion with the Answer posted to a TextField on Scene Two from a button click event on Scene One ok Now I would like to convert the value in the TextField on Scene Two to Kelvin and reflect the value on Scene Three in a TextField by clicking a button on Scene Two
 
lets say  I have 4 FXML files sceneONE sceneTWO and scenMain and I created 4 controllers ControllerONE and MasterController

So far I can navigate to the different scens with just the MasterController code below...

BUT because I have two FXML files I can not capture the value in the first FXML file and pass it to the second scene
 
This project is my attempt to adapt the FXML style code from this web site

Switching to Different Screens in JavaFX and FXML | JavaFXTutorials

Which uses this code to switch scenes

    //get reference to the button's stage                stage=(Stage) btnS1.getScene().getWindow();
       //load up OTHER FXML document
       root = FXMLLoader.load(getClass().getResource("ATTwo.fxml"));

But will not permit variable transfer due to scope of variables which reside in two different FXML files
 
public class MasterController implements Initializable{@FXML public Button btnS1;
@FXML public Button btnS2;
@FXML public Label lblS1;
@FXML public Label lblS2;
@FXML public TextField txfS1;
@FXML public TextField txfS2;
@FXML public AnchorPane root;

[Code] .....

View Replies View Related

JavaFX 2.0 :: Scene Implementation With ScrollPane - Dynamic Node Scaling

Apr 23, 2015

I'm trying to implement a scene with a ScrollPane in which the user can drag a node around and scale it dynamically. I have the dragging and scaling with the mouse wheel working as well as a reset zoom.
 
Here's my issue:

     I'm having trouble with the calculations to fit the node to the width of the parent.
     If I zoom in or out, the fit to width does not work.
     If I change the window size after running fitWidth() once, the fit to width does not work the second time.
 
Here is my code as an SSCCE and how it works...

1. (works) Mouse wheel will zoom in and out around the mouse pointer
2. (works) Left or right mouse press to drag the rectangle around
3. (works) Left double-click to reset the zoom
4. (doesn't work) Right double-click to fit the width
 
My calculations to re-position the rectangle to the upper left of the pane and fit it (i.e. scale it up or down) to the width of the parent are incorrect.
 
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;

[Code] ....

View Replies View Related

JavaFX 2.0 :: Correct Way To Make Stage Respect Its Scene Minimum Size?

Jun 25, 2014

I noticed that all my stages can be resized to zero size regardless of their contained scene, which is very ugly. How do I keep them from doing that? Is there some sort of intelligent way to bind the stage's min size to the size of the scene so that no part of the scene is cut off?

View Replies View Related

JavaFX 2.0 :: ImageView Image Created In Scene Builder 2.0 Doesn't Display In Running App

Sep 9, 2014

I'm using Scene Builder 2.0 and have added an ImageView to the parent AnchorPane.  I've added my PNG files for the app icon and the various buttons. I select the ImageView in Scene Builder and then crawl the filesystem to the project package folder and select the PNG for the Image.  The assigned image is displayed in the Imageview in Scene Builder in both design mode and Preview mode.
 
While everything else shows up properly when the app is executed, the image assigned to the ImageView does not display.
 
From the FXML file:

<ImageView fx:id="ivBRULogo" fitHeight="64.0" fitWidth="64.0" layoutX="14.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0">
         <image>
            <Image url="@BRU_PE_B_64.png" />
         </image>
      </ImageView>
 
What might be occurring between the compiled app and what Scene Builder generates?

View Replies View Related

JavaFX 2.0 :: How To Properly Customize Text Label Of ComboBox

Jun 8, 2014

Switching from Swing to JFX 8, I am trying to find out how to do something I would normally do in a super-simple ListCellRenderer, i.e. customize the String displayed for an item. I tried this:

ComboBox<Integer> combo = new ComboBox<>();
    combo.getItems().addAll(1, 2, 3);
    combo.setCellFactory(new Callback<ListView<Integer>, ListCell<Integer>>() {
        @Override
        public ListCell<Integer> call(ListView<Integer> param) {
  
[Code] .....
 
However, when I do this, the customized String is not used for the selected Item (rather the standard toString() value of the item). Apart from that it is no longer selectable using the mouse (I submitted a bug report for this at [URL] .... but that is not really the point of my question.

Anything else I have to do to make sure the selected item is also rendered using the custom cell or is there a different mechanism for this?

View Replies View Related

Interface Not Updating Properly

Mar 20, 2015

The program runs well , it adds the applet but it dosn't update the interface unless I press "_"(Minimize) . To be more clear , the object paints a spring wich goes through 4 stages , it is added to the JFrame but it dosn't uptade until I minimize the frame , that is when it goes to the next stage .

The main class which calls the spring to be added to the frame :

public class principal implements ActionListener ,Runnable{
JTextField field;
JFrame frame;
private class Action implements ActionListener {
public void actionPerformed(ActionEvent event) {
  frame.repaint();

[Code] .....

View Replies View Related

Swing UI Not Responding Properly?

Nov 27, 2014

Here's the code to my UI and it runs but output doesnot shows properly..

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*;
import java.io.*;
public class LoginPage extends JFrame{
JLabel lblLoginAs;

[code]....

and when I hover over the Login Button its border gets distorted..

View Replies View Related

Images Not Displaying Properly

Nov 16, 2014

My code:

import javax.imageio.ImageIO;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.lang.*;
import java.awt.image.*;
import java.net.URLDecoder;

[Code] .....

I my images (including the one I created) are all 32x32. I'm trying to get a player Icon and have them be on a field of grass. Currently, I just get:

(see Attached)

I don't know where my Images are rendering.

B = blank
. = grass
p = player

.
.
.
.
. p
.
.
b

View Replies View Related

OnItemLongClickListener Not Working Properly

Apr 19, 2014

I created a dialog file:

Java Code:

package com.example.classorganizer;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

[code]...

When I long click item in the list nothing happens. I get no errors at all and I believe that either I put the code in the wrong place or I missed something else that stops Dialog from starting.

View Replies View Related

Using HasNext Properly In Program

Apr 16, 2015

Why do I get an error on the hasNext line when I try to compile this?

public static void main(String args[]) throws Exception
{
BufferedReader infile = new BufferedReader(new FileReader( "woodchuck.txt" ));
HashMap<String, Integer> histoMap = new HashMap<String,Integer>();
String word;
while((infile.hasNext()) !=null) {
if(histoMap.get(word)==null)
histoMap.put(word,1);
else
histoMap.put(word, histoMap.get(word)+1);
}
infile.close();
System.out.print(histoMap);

View Replies View Related

Array Will Not Fill Properly

Dec 8, 2014

my validAccounts array will not fill properly and has a null value in it.I added a print statement that prints the contents of the array and it is filling correctly but the very last value is null. I am supposed to be asking the user for a account number and password and it is not printing out correctly due to the fact that the array is not filled correctly.

import java.util.*;
import java.io.*;
public class ATM2 {
public static Scanner kbd;
public static final int MAXSIZE = 50002;

[code]....

View Replies View Related

JSF :: CDI With Primefaces Charts Not Rendering Properly

Jun 3, 2014

I have 4 Primefaces bar charts which sometimes renders, sometimes not. In one of them, I inject a http user session attribute and use it to render the chart (the idea is to show only the data that corresponds to the (logged in) user department).

There are 4 session beans which I'm using the javax.enterprise.context.RequestScoped. Sometimes, the Glassfish destroys the instance as expected, but sometimes not.Based on Exception below, how can I resolve it?

The xhtml below shows the main code for only 2 of the 4 bar charts:

<p:tab title="Horas de Treinamento (por Funci)" closable="true" >
<p:barChart id="horasBars" value="#{chartHorasFunci.modelHoras}"
legendPosition="ne"
orientation="horizontal"
seriesColors="AA5555, 00438F"
xaxisLabel="Horas" yaxisLabel="Funcis"
title="34 Horas de Treinamento (Orçado/Realizado) por Funci"

[Code] .....

The Exception:

SEVERE: Error Rendering View[/capacitacao/capacitacao/index.xhtml]
javax.el.ELException: /WEB-INF/include/capacitacao/capacitacao/List.xhtml @145,38 value="#{chartHorasFunci.modelHoras}": org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke private void br.com.bb.upb.diage.atb.capacitacao.beans.ChartHorasFunci.initialize() on br.com.bb.upb.diage.atb.capacitacao.beans.ChartHorasFunci@3e9c727c
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)

[Code] .....

View Replies View Related

Tree Not Updating Values Properly

Aug 20, 2014

I am trying to create a tree that is like a take on 21 Questions. The tree pretty much just starts with three default values: the root/first question "Is it a mammal?", a left child "is it: human?", and a right child "is it: fish?", and then it builds off from there. It goes left for YES and right for NO. If the program guesses the wrong animal the user must enter the correct answer and a question that will distinguish the correct answer and the failed answer. That new question then becomes both the the failed answer and new answers's parent.

A little visual:

....................Is it a mammal?

...........It is: human?........Is it: fish?

*lets say it is a mammal but not human, ie a dog

Updated tree:

.....................Is it a mammal?

.....Does it have a tail?............Is it: fish?

Is it: dog?......Is it: human?

My problem is that after I update the tree 3rd time the values do not change properly. Lets say it is a mammal and its does have a tail, BUT its a cat, then, the updated question, which would now go before "is it: dog?" would be something like: "does it chase rodents?", which its left child would be cat and right would be dog.

However, when my program displays the values it would go something like this:

//first run: GOOD
Think of an animal and I will guess it!
Is it a mammal? Enter yes or no:
yes
Is it: human?
no

[Code] .....

So pretty much I can't understand what I'm doing wrong since the values in the print statements are right, but they are wrong during the actual run. Where is my error?

View Replies View Related

Keyboard Class Is Not Configured Properly

Jul 4, 2014

package com.vesron.primes;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;

[code]....

The parameter for the starting y is "fy" (Half of the screen). When I use the keys "z" and "x" it translates one pixel at a time left and right. That is good, but when I use the keys "a" and "s" it will double each time (good), but the starting y will drop significantly (bad). I tried manipulating the "x" and "fy" variables, but to no avail.

View Replies View Related

Program Won't Scan Properly The Text

Nov 19, 2014

I was trying to do a short program that scans a text for a given word and then tells you how many times that word was repeated in the text. The result was this:

var text = prompt("Write the text to be searched through");
var word = prompt("Write the word to be looked for. Beware of capitals!");
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === word[0]) {

[Code] ....

However, this doesn't scan the text properly. I think the problem lies in one of the lines from 4 to 8, but, even after thinking quite a lot, I couldn't understand what was it. I thought that by saying that the letter of the text in position [i + k] shuold be equal to the letter of the word in position [k] I could make it work, but it doesn't.

View Replies View Related

Program Not Moving To The Next Line Properly?

May 14, 2014

I am trying to only allow the user to input numbers. But I need to enter a number twice before it moves to the next line statement and also skips a line when i enter th number a second time.

How can I go around fixing this.

My code for this is

case 1:
do{
Event event = new Event();
out.println("Please Enter the name.");
event.setEvent(input.next());
input.nextLine();

[Code]...

View Replies View Related







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