How to upgrade the style sheets when running?

Strangely the style does'nt changes if I manually change the rules of css class in one of the css document and switch between the 2 files.

@Override

Public Sub initialize (URL url, rb ResourceBundle) {}

final String cssUrl1 = getClass().getResource("/tracker/view/fxmlgui1.css").toExternalForm ();

final String cssUrl2 = getClass().getResource("/tracker/view/fxmlgui2.css").toExternalForm ();

rootPane.getStylesheets () .add (cssUrl1);

rootPane.addEventHandler (KeyEvent.KEY_PRESSED, new EventHandler < KeyEvent > () {}

@Override

{} public void handle (KeyEvent keyEvent)

If (keyEvent.getCode () .equals (KeyCode.DIGIT1)) {}

rootPane.getStylesheets () .clear ();

rootPane.getStylesheets () .add (cssUrl1);

msgLabel.setText ("Css1 selected.");

} ElseIf (keyEvent.getCode () .equals (KeyCode.DIGIT2)) {}

rootPane.getStylesheets () .clear ();

rootPane.getStylesheets () .add (cssUrl2);

msgLabel.setText ("Css2 selected.");

}

}

});

}

The event occurs and the style change of css1 and css2, as it was at the scene is rendered, but if I change one of the rules in the sylesheets after step is planned, the does'nt lifestyle changes more.

So who is the General method to change the style of nodes change the css document at run time?

It's like the original stylesheets in css documents someway implemented cache and does'nt update to any switch.

Is the purpose of being able to edit the css file, and then press a key or press a button "recharge style" on the user interface and see the models updated? I don't think that's really the purpose of the css style: intent is really that the css file that will be provided in the your application jar file and never even extracted, both and edited and reloaded. (It can even be converted to a binary format that is faster to load).

That said, however, the following works fine for me. (JDK 1.7.0_25, JavaFX 2.2.25). Run the application, you see the label in blue. Edit the css and save (without leaving the app), press the button reload the style, and you see all changes take effect. Who does not work for you?

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class CssReloader extends Application {

 @Override
  public void start(Stage primaryStage) {
  final VBox root = new VBox(5);
  final Button reloadButton = new Button("Reload style");
  reloadButton.setOnAction(new EventHandler() {
            @Override
            public void handle(ActionEvent event) {
                loadStyle(root);
            }
        });
  final Label label = new Label("A message");
  root.getChildren().addAll(reloadButton, label);
  loadStyle(root);
  primaryStage.setScene(new Scene(root, 300, 150));
  primaryStage.show();
  }

  private void loadStyle(Parent node) {
      node.getStylesheets().clear();
      node.getStylesheets().add(getClass().getResource("editMe.css").toExternalForm());
  }

  public static void main(String[] args) {
  launch(args);
  }
}

editMe.css:


@CHARSET "UTF-8";
.label {
 -fx-text-fill: blue ;
}

Update: of course, this code will not work if you combine this as a jar file and run it from there. getClass () .getResource (name) produces a URL that represents a resource loaded from the same location as the class underway (in this case the jar file), and toExternalForm() that allows to convert to a string. Of course to edit a css won't help in the bundled jar file. (Try to view as follows. Launched from a file system class loader, you will get a file:// url; launched from a jar class loader, you will get a pot: / / class loader.)

private void loadStyle(Parent node) {
      node.getStylesheets().clear();
     String resource = getClass().getResource("editMe.css").toExternalForm() ;
     System.out.println(resource);
      node.getStylesheets().add(resource);
  }

To force a system file URL, even if you run from a jar file, you can do this:

privatevoid loadStyle(Parent node) {
      node.getStylesheets().clear();
      try {
            final String resource = Paths.get("/path/to/editMe.css").toUri().toURL().toExternalForm();
            System.out.println(resource);
            node.getStylesheets().add(resource);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
  }

Now, of course you have something of a headache of deployment; you will need to make sure somehow that there is a css file in the correct location - outside packaging jar - as part of the deployment of your application. You can check for its existence at startup, and if she's not here read a default version of your jar file and write it in the location in which you expect to find; or find another strategy.

Post edited by: James_D

Tags: Java

Similar Questions

  • How to upgrade the ArrayCollection collection when running?

    Am facing a problem with the arraycollection collection...
    will have an arraycolelction like that...
    var dpHierarchy:ArrayCollection = new ArrayCollection([)
    {Region: "Application1"},
    {Region: "Demand2"},
    {Region: "Demand3"},
    [{Region: "APPROVISIONNEMENTS4"}]

    now what I'm looking for is... How to upgrade this arraycollection collection during execution using actions script?
    I need to update this collection table something like this...

    var dpHierarchy:ArrayCollection = new ArrayCollection([)
    {Region: "Application1", year: '2008'},
    {Region: "demand2', year: '2008'},
    {Region: "Demand3', year: '2008'},
    [{Region: "APPROVISIONNEMENTS4", year: '2008'}]

    How to add the year field in to existing collection arraycollection as shown in the example...

    Thanks in advance
    Pratap

    Hey get...

    I have to just give

    dpHierarchy [0] ['year'] = '2008 '.

    :-)

  • How to upgrade the enum labels when enum is inside an array of clusters?

    Hello gurus of LabVIEW,.

    I'm stuck with one aspect of the design and I was wondering if you could share some ideas on how to move beyond this: I want to fill an array of strings, and then complete an enum inside a table with string values.

    For the purposes of discussion, I'll break you in two actions steps, where it takes place before the second (sequential, not in parallel)

    Action - the user will first ask you to fill a table with 'strings '. The table might look like,

    row0 - "string0".

    Row1 - 'string1 '.

    row2 - "word2".

    and so on...

    Action 2 - whenever the user "action selects two" I would like to fill out an ENUM inside a cluster with the values of 'Action '. In other words, I am trying to dynamically write enum values.

    The cluster has several objects such as Boolean controls, String, control, AND YEAR ENUM (see attachment .png)

    I tried using the ring and enumerations at this stage and have failed him. I read somewhere that the enum/ring is in a cluster and the cluster within a table, what I'm trying to do is simply not possible. If this is the case, can you please throw my ideas, my ideas? :-)

    In advance, thank you very much.

    See you soon,.

    First of all, the question is your cluster is a strict type def and preventing you from updating the ropes of the ring then I turned into a normal type def.  I've also got rid of the sequence and the while loop they were not useful anyway.  Just unzip and run the VI then enter values in the table, as you enter data, that the ring is updated with the new value.

  • How to load the resource network when running

    I want to load this cartoon in my Flex application: http://www.bestanimations.com/Earth & Space/Earth/Earth-02-june.gif
    with the code below:

    <? XML version = "1.0" encoding = "utf-8"? >
    "< mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml" > "
    "" < mx:Canvas xmlns:mx = ' http://www.adobe.com/2006/mxml " width ="610"height ="124"backgroundColor ="#AAAAD1"borderColor =" #8CA9BD ">
    < mx:Image source="@Embed(' http://www.bestanimations.com/Earth&amp;) (Space/Earth/Earth-02-june.gif') ' scaleContent = "true" autoLoad = "true" id = "logo" top = "10" left = low "202" = "10" width = "212" / >
    < mx:Label text = "Earth, Moon" height = "17" y = "107" width = "212" x = "202" fontSize = "10" / >
    < / mx:Canvas >
    < / mx:Application >

    I got errors
    Impossible to transcode http://www.bestanimations.com/Earth & Space/Earth/Earth-02-june.gif
    Network resource cannot be incorporated at the time of the compilation; Please use local file or load the resource at run time

    Maybe just stir not, because I don't think that you can embed a resource network at compile time (as indicated by the error).

  • How to disable the button submit when running

    Hello

    I create a page with buttons createEmployee, deleteEmployee and updateEmployee employee management.

    I want to disable the buttons send above if the user is "OPERATIONS".

    My code as follows:

    String userName = pageContext.getUserName ();

    {if ('Operations'. Equals (username))}
    OAPageLayoutBean page = pageContext.getPageLayoutBean ();
    page.prepareForRendering (pageContext);
    OAGlobalButtonBarBean buttons = (OAGlobalButtonBarBean) page.getGlobalButtons ();
    OAGlobalButtonBean button = (OAGlobalButtonBean) buttons.findIndexedChildRecursive ("CreateEmployeeButton");
    button.setDisabled (true);
    }

    but he throws NullPointerException.

    For this code, I guide the OAF Dev R12.

    can you explain what is function_name in the next line

    Button OAGlobalButtonBean = (OAGlobalButtonBean) buttons.findIndexedChildRecursive ("< function_name >");

    I tried with the id of the button, but I didn't work.

    Can you explain about this clearly.

    Thanks in advance,
    SAN

    Hello

    I think that your button on the page is in the region of pageButtonBar.

    Use code below.

    String userName =pageContext.getUserName();
    
    if("OPERATIONS".equals(userName)){
    OASubmitButtonBean button = (OASubmitButtonBean) webBean.findChildRecursive("CreateEmployeeButton");
    if(button!=null)
    {
        button.setDisabled(true);
    }
    } 
    

    Kind regards
    GYAN

  • How to detect the operating system when running?

    I have a library that I use a mobile (android) and the office-air projekt. I want to code something like this (pseudo-code):

    If (OS is mobile/android)
    this.addFieldUIs (myPopUpList);

    ElseIf (OS == desktop)

    this.addFieldUIs (myDropDownList);

    Is it possible to archive this?

    You can try Capabilities.version. I used it to make the distinction between IOS and Android, and you can probably find Windows or Mac from that, too.

  • Why layer handles disappear when I remove the absolute positioning in the style sheet

    Why layer handles disappear when I remove the absolute positioning in the style sheet, and I can't shift the most in the property inspector. Thank you, bryan

    Layers are positioned absolutely. That's what their positioning coordinates
    makes them "layers."

    Once they are positioned absolutely (via the CSS details), they are
    withdrawn from circulation of the code of the page and 'float' on the page, as a
    overlay, which appear when the code indicates to start (from top left
    then, coordinate height x width).
    That's why you can drag the around anywhere you like view creation with
    layer handles - details are updated in the CSS by DW by dragging
    your mouse.

    Once you remove the absolute positioning, they are regular

    elements in
    the flow of the page with a height and width. So DW deletes the handles as well
    they cannot be dragged around because he no longer has all the details to
    update in the CSS.

    --
    Concerning

    John Waller

  • How to upgrade the Switch application icon

    Hello

    I'm working on a UiApplication in Java that runs in the background all the time.  I need support the 7290, some 8,000 s and the "BOLD".  The screen resolution is very different between the 7290 and "BOLD" and the icon that looks good on the 7290 seems jerky on the "BOLD". And the icon that seems good on the "BOLD" is not full screen on the 7290, and we know, that there is a problem.  So, I followed the information contained in these two links to update my icon based on that screen resolution that we, to make my icon looks good no matter what device has a user.

    BB in Knowledge Center article - how to set an icon of overview

    BB Forum of Discussion on the overview icon

    Now on the 7290, I use an icon of size 32 x 32 pixels and on the "BOLD", I use an icon of size 64 x 64 pixels.  I know that 64 x 64 is not the recommended size for the "BOLD"... and it looks better for what I do.

    OK, so to enter some details, I have a main entry point, which has an icon associated with it (which is the icon that I have 'default', you can tell).  And it's the icon of my startup code updates (via HomeScreen.updateIcon (getHomeScreenIcon (), 0) and is what you see in the Applications folder (or on the main Menu, depending on what device, of course).)  And on the menu, when you click this icon, it brings my application in the foreground and here we go. It works just as advertised and is great.  I have the icon on the right showing on the right screen resolutions.  No problem.

    Is then where I run into trouble.  I have another point of entry, who calls my startup code and gets my application running in the background.  It has an associated icon also (once again just the icon I want 'default' before I can get the Update icon.  It is the icon that can be found on the Ribbon for switching applications (when the user presses ctrl-esc).

    And once again, in my startup code, I try to use - HomeScreen.updateIcon (getHomeScreenIcon (), 3); -Please note the different entry point number that corresponds to this entry point.  I checked the CAP file to determine the correct entry point number and this update still does not take effect.  I also tried each number from 1 to 5, no chance.  I can't get this icon to update.

    How to upgrade the icon that appears on the Ribbon for switching applications?  And if I can't be updated for a reason, how can I specify a different icon for different screen resolutions?

    Thank you, Tara

    PS. I use JDE 4.1.0.185, simulators and devices of 7290, 8100, 8300, 9000 (Bold).

    The issue of the HomeScreen.updateIcon do not update the icon displayed in the application of task switch has been resolved in BlackBerry handheld software version 4.7.0.  The only work-around from earlier versions is to have several versions of the application that are built with different application icons.

  • I did a reset on my iPad 2 and now it has an error with iTunes saying that it requires a newer version of iTunes. How to upgrade the iPad I have tunes version?

    I did a reset on my iPad 2 and now it has an error message when I connect to my computer to access the backup. bed the error message, this iPad cannot be used because it requires a newer version of iTunes. How to upgrade the version of the ipad?

    Take a look at the article, download the latest version of iTunes - Apple Support

  • How to upgrade the proxy settings (.pac file is modified) without having to restart Firefox?

    How to upgrade the proxy settings without restarting Firefox?
    I have a .pac with a proxy configuration file.
    When I likely this .pac, I like that Firefox update settings in order to study the new .pac contents.

    You can do it with the Prefbar extension and Reload PAC button.

    https://addons.mozilla.org/en-US/firefox/addon/67148/ - PrefBar
    http://PrefBar.mozdev.org/buttons.html#reloadpac

  • Satellite U300 - how to upgrade the BIOS on a Linux system?

    Attempt to update the BIOS of my U300-153, which is described as an operating system independent on the download page, I find that the upgrade file is provided in
    http://Support1.toshiba-tro.de/Tedd-files2/0/BIOS-20090304140640.zip
    does not include the files to create a bootable CD, as described in the instructions to the
    IOS http://eu.Computers.Toshiba-Europe.com/innovation/FAQ.jsp?z=234&service=eu&from=faq_selection&CFID=B & FID = TRO0000000b07
    where Option 2 step 2 lists the files that are in the zip, and they are required to make a bootable cd. The files listed are not in the zip.

    It forces me to use Windows. My Windows is broken and I can't fix it, because Windows repairs destroy data (clearly indicated on the packaging of recovery CD) and installations of Linux. My Linux works very well, and I don't want the windows more.

    So how can I upgrade the BIOS? Either:
    1. use a true independent bundle of BONES (ie the promised approach of bootable CD). I can't find such a thing here.
    2 reinstall Windows, which trashes the laptop.

    Any suggestions?

    Sincerely,
    Aleksander K

    > How to upgrade the BIOS on a Linux system?
    Is not possible since the BIOS on Toshiba page is a victory-based BIOS version and if you want to update the BIOS then you need to install the Windows operating system and then you can run the exe file

    Welcome them

  • Add items to the combo box when running

    In my program, I want to add int '34' "43", "17"... and let the user choose one of them to the drop-down list box. How can I add items to the combo box when running. Create a property node 'String [] '? I try that, but its screen is "3443". I want to display as "34".

    43

    17

    See attached extract

  • How to change the style of picture frame

    I would like to know how to change the style of table on the front. For the example below, I would like to remove the covered framework of gray color.

    I could not find the table style editor.

    First option: use the table on the classic controls palette, which has no border.

    Second option-

    1. Select the painting tool.
    2. Right click on the border.
    3. With open color dialog box, click the space bar. This toggles the color picker to work on color FG, the background color, or both. It is also described at the bottom of the color picker.
    4. When the two have been selected, you can make the frame completely transparent by selecting the color of T.
  • How to upgrade the driver for my video card?

    How to upgrade the driver for my video card?

    Most often when a device does not work, it's because the driver has been corrupted.

    Try reinstalling your.

    http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly? SignedIn = 1

    http://captaindbg.com/how-to-update-drivers-on-Windows-7/

  • How to upgrade the version of Adobe Flash Player on my new Samsung Smart TV

    How to upgrade the version of Adobe Flash Player on my new Samsung Smart TV?

    I just bought a Samsung Smart TV. When I try to watch ESPN3, I get the message: insufficient Flash drive requirements.

    Click to update provides the following information:

    Adobe Flash Player version 11.2.202.243.

    Your system: 32-bit Linux, Safari.

    NOTE: Adobe Flash Player 11.2 will be the last version of target Linux as a supported platform. Adobe will continue to provide backports of security Flash Player for Linux 11.2.

    Select Version to download:

    YUM for Linux (YUM)

    . for other Linux tar.gz

    for other Linux .rpm

    APT for UBUNTU 10.4.

    When I select the first 3 options of Linux, I get the message: IMPOSSIBLE TO DOWNLOAD.  When I select APT, I get the message SERVER NOT FOUND.

    Hello

    As I mentioned earlier in this thread (15,17 and 37 positions), doesn't matter which drive Flash updates for Smart TV, if any, would come from the manufacturer, Adobe and certainly not some random site asking you to fill out a questionnaire before give you a file.  Please contact your support of manufacturer of Smart TVs.

    Please, please, please, do NOT go to some random website that asks you to fill out a questionnaire to get a file.  If you happen to get a file, it will likely contain a virus, malware, etc..  Adobe, or any legitimate manufacture, will display a file on some random site and ask you to complete the questionnaire in order to obtain the file.  It just opens your system to all kinds of bad things.  Please do not.

    --

    Maria

Maybe you are looking for

  • new updates of windows, firefox slow to open

    My computer installed two new windows updates... KB3021917 and KB3006137. Since then, Mozilla Firefox is slow to open. It takes at least 5 minutes. However, once the internet is in place, it works fine. It's just the process of the opening of the int

  • Why it is not a key board used in Cantonese phonetic?

    I am a Cantonese in mainland China, I select the language as Cantonese.But when I want to input Chinese, I have to use pinyin (which is based on mandarin).

  • Cannot access the Bios Uefi more on E535

    Hello community, I recently bought a new laptop E535, works like a charm so far. Access BIOS was possible by pressing enter directly after machine, that came a kind of JOB analysis which could be ignored by pressing any key and that came a kind of ta

  • Windows 8.1 on the function Fn + Z510 keys does not work and I see no Lenovo so that they work again

    This computer came with FreeDos and I had to buy a windows at retail, so it was not a custom set for the laptop and when I page driver Lenovo for Z510, the only touch pad driver and keyboard page is the touchpad drivers. Nothing for the keyboard. So

  • Want to dv6

    Hi all! I want dv6-7252eo laptop. I would like to replace my Intel Centrino Wireless - N with Intel Centrino Advanced-N dual band 6235 2230. This is especially because I would use 5 GHz network and I find my current NIC really unstable and unable to