Problem with adding a Node in a Scene from a Node initialization

Hi all! I am trying to create a custom Button, then I create a class that extends Rectangle, then this class add a Text on the button... but the Text is never shown!
import javafx.scene.Cursor;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.effect.DropShadow;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.input.MouseEvent;
public class Button extends Rectangle {
    public var text: String;
    postinit {
        cursor = Cursor.HAND;
        width = 90;
        height = 25;
        arcWidth = 15;
        arcHeight = 15;
        effect = DropShadow {radius: 6};
        fill = LinearGradient {
            startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
            stops: [
                Stop {offset: 0.0, color: Color.WHITE}
                Stop {offset: 1.0, color: Color.LIGHTGRAY}
        insert Text {
            x: this.x + 5, y: this.y + 5
            content: text
            font: Font {size: 13}
        } into scene.content;
        onMouseEntered = function(e: MouseEvent): Void {
            fill = LinearGradient {
                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                stops: [
                    Stop {offset: 0.2, color: Color.WHITE}
                    Stop {offset: 1.0, color: Color.LIGHTGRAY}
        onMouseExited = function(e: MouseEvent): Void {
            fill = LinearGradient {
                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                stops: [
                    Stop {offset: 0.0, color: Color.WHITE}
                    Stop {offset: 1.0, color: Color.LIGHTGRAY}
        onMousePressed = function(e: MouseEvent): Void {
            fill = LinearGradient {
                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                stops: [
                    Stop {offset: 0.0, color: Color.LIGHTGRAY}
                    Stop {offset: 1.0, color: Color.WHITE}
        onMouseReleased = function(e: MouseEvent): Void {
            fill = LinearGradient {
                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                stops: [
                    Stop {offset: 0.0, color: Color.WHITE}
                    Stop {offset: 1.0, color: Color.LIGHTGRAY}
}If I print scene.content from this class, there is no nodes in the scene! If I print content from the scene, the output show only the button, but not the Text...
Can somebody tell me why this doesn't works?

Based on your code, do you even need to extend or create a CustomNode? I believe you can accomplish your desired result by adding a stylesheet to your scene and then specify a styleClass for a basic button.
Here are a few snippets:
The scene:
scene: Scene {
                stylesheets: uiCSS
                content: [ //your button ]               ]
            }The button:
Button{ styleClass: "myButton"}The css:
.myButton:hover{
   -fx-text-fill: linear (0%,0%) to (0%,100%)
        stops (0%, rgb(220, 220, 220)) (25%, rgb(190, 190, 190))(50%, rgb(190, 190, 190))(100%, rgb(220, 220, 220));
.myButton:pressed{
  -fx-text-fill: linear (0%,0%) to (0%,100%)
        stops (0%, rgb(100, 100, 100)) (25%, rgb(100, 100, 100))(50%, rgb(100, 100, 100))(100%, rgb(100,100, 100));
}You can modify the look and feel of any JavaFX control in this manner. An important resource to access is the caspian.css which can be found in the JDK library in the javafx-ui-controls.jar under the com.sun.javafx.scene.control.skin.caspian. You can essentially copy and paste any of the controls css into your css file and modify as desired. This allows you to skin your components without having to change any of the behavior which becomes a big hassle.
Hope this helps.

Similar Messages

  • Problem with adding Sun JSF RI v1.2 as a new library in JDeveloper 10.1.3.1

    Hi,
    I have a problem with adding a latest JSF 1.2 RI from Sun (https://javaserverfaces.dev.java.net/files/documents/1866/44998/jsf-1_2_03.zip) to JDeveloper as a new library.
    I created a new User library and added into it jsf-impl.jar and jsf-api.jar from JSF 1.2 RI.
    Then I try to create two new JSP Tag libraries based from .tld files.
    When a .tld file is placed in "TLD File:" field there is no information below about Library Version and Required JSP Version. If I check "Execute Tags in JSP Visual Editor" and click "Customize" button - list of tags in "Customize Tag Library" window is empty.
    I have errors when I try to use JSF Tags from this new library in JSP page like :
    "Can't create tag instance: f:view (class: null). Make sure, that the tag class or a library contained this class is available in this application"
    (free translation to English)
    Is this possible to add JSF RI v1.2 as another library in Jdeveloper 10.1.3.1 ?
    thanks for help
    koli

    Hi,
    This solution is not exactly for Jdeveloper 10.1.3.x I think.
    - "Create a JSF system library." section, point 2. - there is not possible to add library in folder other than User I see, so I added it in User folder.
    - "Register the JSF JSP tag libraries." section, point 5. - in JD 10.1.3 there is no dialog box, I checked checkbox "Show Tag Library in Palette". A new library was added to User folder but there is no new libraries in component Palette.
    Even as I use "Edit tag libraries .." from Component Palette context menu and add manually new tag libraries to selected, there is no libraries in Component Palette after it.
    I feel so problem is with different .tld files format, not with adding libraries method.
    Sun RI tld file (from version 1.2_03) fragment:
    <taglib xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
    version="2.1">
    <!-- ========== Tag Library Description Elements ========================= -->
    <description>
    The core JavaServer Faces custom actions that are independent of
    any particular RenderKit.
    </description>
    <tlib-version>1.2</tlib-version>
    <short-name>f</short-name>
    <uri>http://java.sun.com/jsf/core</uri>
    tld included in JD:
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <!-- ========== Tag Library Description Elements ========================= -->
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>f</short-name>
    <uri>http://java.sun.com/jsf/core</uri>
    <description>
    The core JavaServer Faces custom actions that are independent of
    any particular RenderKit.
    </description>
    Did JDeveloper 10.1.3.x maintain with taglib version 1.2 ?
    Regards
    koli

  • [SOLVED] Problem with adding a SSH connection to startup

    Hi guys. I have a problem with adding ssh connection to startup. i want this command to run before kde login screen  and keep running all time.
    ssh -D 9292 remoteuser@remotehost
    but it doesnt connect. Thanks for help!
    Last edited by alperenel (2011-03-11 00:10:27)

    cactus wrote:
    ssh -fN -D 9292 remoteuser@remotehost
    you need -f, which sends ssh to the background, and -N which does not execute a remote command.
    If you need it to run as a user other than root, then you probably need to utilize su as well.
    it didnt work either. i am putting it in rc.local but doesnt work.

  • Problem with adding new field to the mass change screen in FBL5N

    Hi,
    We have a problem with adding the field XREF3 to the mass change screen. We followed steps described in the SAP Note 640908, but the result is that when we try to mass change some documents in FBL5N and enter some values in the mass change screen, a message appears: "Please enter at least one new value" and nothing is changed.
    If you have faced with such a problem, we would be grateful if you give us some tips.
    Regards,
    Miłosz Włodarczyk

    The problem has been resolved: we didn't activate a code in SE80.

  • Problems with adding Library for a MySQL JDBC driver

    Good day,
    I am new with the JDeveloper package, so the following could be a user fault.
    I found the following:
    - I downloaded and installed Oracle JDeveloper 10.1.2.1.10 (latest version).
    - I downloaded the latest JDBC drivers for MySQL. ( mysql-connector-java-3.1.10 )
    Now, I did the following steps extracted from the link http://www.oracle.com/technology/products/jdev/tips/duff/mysql_and_oc4j3.html it should be quite easy to add the JDBC Drivers to the project.
    I did the steps with the following results:
    When I Edit the Project properties, follow Profiles -> Development -> Libraries
    When I do ' New' , fill in at JS2E the value 'MySQL' and fill in the Class Path (in my case 'C:\javaInstalls\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin.jar').
    In that case the [OK] is disabled. I should expect the [OK] button was enabled!
    My question: Is this a bug? When not, what am I doing wrong!
    Regards,
    Mike

    I tried it on an other system and had no problems with adding the libraries. It still is a problem on that particular system using the Dutch version of XP. The problem is that the Ok button stays disabled !
    Could it bw a version problem with Java? How ever no changes are made to the original configuration, so it should pick up as default the java version of JDeveloper self.

  • Problems with adding funds

    Hey guys , I have a problem with adding funds in my PSN account with my debit card . I have used the same card in the past with no problems at all but now for some reason it keeps on saying that the card number is invalid every single time ! Please help me , is there any solution ? Does it maybe has to do with Capital Control ( I live in Greece ) 

    Thanks I use this
    2.) You can make one of your buttons the default
    button of the frame:
    this.getRootPane().setDefaultButton(confirm);
    well, did you implement the first suggestion of quitte?
    here is an idea that might work!
    JTextField username;
    JPasswordField password;
    JButton confirmButton;
       username.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
             password.requestFocus();                    
       ActionListener l = new ActionListener(){
          public void actionPerformed(ActionEvent ae){
             //optional check for username and password length>0
            //process logon.
       password.addActionListener(l);
       confirmButton.addActionListener(l);

  • Problem with program hanging randomly on certain commands from win 7 pro client to SB Server

    Having a problem with program hanging randomly on certain commands from Win-7 Pro Client to SB Server Both 64-Bit
    Five other slower XP-Pro 32 Bit systems though they are older and slower systems do not seem to hang as readily if at all.
    It has been very frustrating as the Client-System, SB-Server and Program should work w/o any hitches, but this seems to work fine @ times and then hang randomly.
    Would appreciate any and all suggestions in assisting.... JimBAgde-MSS  

    You can try this, as I have had similar problems with another MS Access .MDB file and slow access before. This fixed my problem for me. On the slow computer, make sure the program is set to see the .mdb file via UNC path, not a mapped drive letter. ex.
    USE:  \\yourserver\shared\dental\file.mdb
    DO NOT: S:\\shared\dental\file.mdb
    hope this helps

  • I updated the firmware to 5.0.1, then began a problem with my gadget I try to restore from a backup firmware, Itunes an error 3194, if I can, and if I do get to shsh ios 5?

    I updated the firmware to 5.0.1, then began a problem with my gadget I try to restore from a backup firmware, Itunes an error 3194, if I can, and if I do get to shsh ios 5?

    Good morning
    This may indicate a hardware issue with your device. Follow Troubleshooting security software issues, and restore your device on a different known-good computer. If the errors persist on another computer, the device may need service.
    http://support.apple.com/kb/TS3125
    Hope this helps
    Cheres

  • Problems with email account on ipad2 when changing from mobileme to icloud

    Problems with email account on ipad2 when changing from mobileme to icloud

    Would you please give us some more information about your problems.

  • HT4889 After using migration assistant I have had problems with some apps that were brought down from App store, as well as IntelliJ that just doesnt want to start at all. Does it have anything to do with the UID being changed?

    After using migration assistant I have had problems with some apps that were brought down from App store, as well as IntelliJ that just doesnt want to start at all. Does it have anything to do with the UID being changed?
    13-07-03 6:24:12.447 PM com.apple.launchd.peruser.502[1632]: ([0x0-0x5be5be].com.jetbrains.intellij[5805]) Job failed to exec(3) for weird reason: 13

    What is the exact name of the application you're trying to launch? Is it in the Applications folder?

  • Problem with adding artwork manually in itunes

    I'm having trouble manually adding artwork to several albums in itunes 10.7 on macbook pro (the 'get album artwork' facility won't pick these discs up presumably because they're too obscure).
    I go to 'get info', select the relevant check box, then add a  non-read only, apparently normal jpg to the artwork box. This image then displays successfully in the artwork box, I press ok, but when I return to the albums list it won't display at all. This has been consistent problem that I haven't only experienced in this version of itunes and it's very irritating having just a few blank albums that refuse to change.
    Any ideas what might be causing this. Or is there a workaround or an alternative method I can use to add artwork?

    Thanks both for the responses.
    Limnos - I can't find an equivalent 'show artwork' function in the view menu in my version of itunes, and I'd rather not have step back to an older version of itunes if I can avoid it.
    BUT having thought about it I think the root of the problem must be that they are all albums with .flac files that have been imported into itunes using the 'Fluke' software. I suspect this might be what's causing the problem - and I'm wondering whether that means the problems with Fluke itself. It's annoying that there isn't a quality music player on mac that handles .flac and I have to use these crappy converters.
    If anyone has an idea about how to solve this please pitch in, but I suspect this goes beyond the remit of these forums.
    och well.

  • Problems with Adding Fields/Columns to Crosstab in XI

    Post Author: ph03nix
    CA Forum: General
    I am having problems with formatting a crosstab report in CRXI and am hoping that someone has a solution. 
    The crosstab report is a subreport, and requires the following columns, grouped by Firm (also not working optimally, but at least working):
    Evaluator,   Factor1Rate,&#91;Factor2Rate, .., FactorNRate&#93;, Summary, UpdateDate, UpdatedBy
    Where:
    Evaluator is the person that did the evaluation that resulted in each rating (formula field)
    Factor1Rate, etc, may have one, many, or all of these be applicable - there can be up to 15 of these.  Each FactorRate column is to  display the "rating" given by the Evaluator in the corresponding row/column (this much works).  The table heading is a formula, but the corresponding rate is not.
    Summary should display "Complete"  if and only if there is a Comment field (not displayed) filled out for each FactorNRate that has a value of 0, 1 or 5 - otherwise it is blank
    DateEntered is one of 2 fields ("last_updated" , or "creation_date" if  last_updated is null - a formula field)
    UpdatedBy is the last name of the person who last touched the ratings (formula field)
    I have gotten the FactorRates to display in the headers, and gotten the corresponding rates to display underneath them, but I cannot seem to add any other columns to the report - they are either added as headers with the factor_rating columns repeated as subgroups (with incorrect data), or are added under existing headers with duplicates of the ratings.  I just want to add one column for each field as if it were a normal (non-crosstab) table. 
    TIA!

    the 3 last files
    Attachments:
    Z1&Z2.vi ‏19 KB
    tau_inn (SubVI).vi ‏16 KB
    tau_ut (SubVI).vi ‏10 KB

  • Problems with added music sound tracks

    Please Help. My music sound files added to iMovie 09 are stuck on full volume and when I close and re-open my project the sound has slightly shifted and is out of sync with the video. The project is over 1 hour long with many varied added sound effects.
    I would really appreciate any help
    Thanks
    Joe

    If you go to page 8 of this forum, you'll see that over 1,200 of us have experienced basic audio problems with iMovie 09. I guess you should pick and choose your solution from those who responded on that post...(?)

  • Problems with adding IOS IPS to IPS MC

    Hi,
    We are having problems in adding Cisco IOS IPS (Running on Cisco 1701,12.3(14)T2) into IPS-MC (Version: 2.1.0).
    The IPS MC is able to create the Trust Point on the Router and the Router is also able to download the IPS-MC certificate chain. However after that the process fails with the error
    ++++++++++++++++++++
    Import of sensor x.x.x.x failed.
    Error : Error importing configuration files from the sensor - Unable to import sensor config from IOS IPS: null
    ++++++++++++++++++++
    Any ideas ?
    Thanks \\ Naman

    I am having the same issue and open TAC case for several days..with 1841 and 2811's..same software and IOS
    It works with advipservices but not with advsecurity

  • Nokia n97 problem with adding last widget

    Hi all, 
    After updating my software to v 21.0.045 i found my phone is working better than before with one exception. I can't add the last widget on the main screen. It can only let me change wallpaper?!?
    I tried to reset using phone, using code, restarting a few times etc Nothing helped.
    I even sent a message to Nokia helpline explaining all what has happened and they send me a silly email back with simple ""use "add content" in order to add widget to your mainscreen ""
    Somebody help! If you know how to add the last widget please let me know. 
    Ps 1. I didn't have this problem with my old software
    Ps 2. I attached a photo to prove it
    Attachments:
    nokia.jpg ‏106 KB

    If you do it , do another soft reset , back up Contacts, Calendar and Notes ONLY (your settings can cause conflict between new and old software, which is why this is advisable) Dial *#7370# followed by 12345, then set up your phone again manually, a bit of work, but should get the phone working like new !
    Good Luck
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

Maybe you are looking for