How to change button label while loading content

I have this basic example with toggle buttons:
public class test extends Application
    @Override
    public void start(Stage primaryStage)
        final VBox vbox = new VBox();
        String pillButtonCss = DX57DC.class.getResource("PillButton.css").toExternalForm();
        // create 3 toggle buttons and a toogle group for them
        ToggleButton tb1 = new ToggleButton("Left Button");
        tb1.setId("pill-left");
        ToggleButton tb2 = new ToggleButton("Center Button");
        tb2.setId("pill-center");
        ToggleButton tb3 = new ToggleButton("Right Button");
        tb3.setId("pill-right");
        final ToggleGroup group = new ToggleGroup();
        tb1.setToggleGroup(group);
        tb2.setToggleGroup(group);
        tb3.setToggleGroup(group);
        // select the first button to start with
        group.selectToggle(tb1);
        final Rectangle rect1 = new Rectangle(300, 300);
        rect1.setFill(Color.DARKOLIVEGREEN);
        final Rectangle rect2 = new Rectangle(300, 300);
        rect2.setFill(Color.LAVENDER);
        final Rectangle rect3 = new Rectangle(300, 300);
        rect3.setFill(Color.LIGHTSLATEGREY);
        tb1.setUserData(rect1);
        tb2.setUserData(rect2);
        tb3.setUserData(rect3);
        group.selectedToggleProperty().addListener(new ChangeListener<Toggle>()
            @Override
            public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle)
                if (new_toggle == null)
                else
                    vbox.getChildren().set(1, (Node) group.getSelectedToggle().getUserData());
        HBox hBox = new HBox();
        hBox.getChildren().addAll(tb1, tb2, tb3);
        hBox.setPadding(new Insets(10, 10, 10, 10));
        hBox.getStylesheets().add(pillButtonCss);
        vbox.getChildren().addAll(hBox, (Node) group.getSelectedToggle().getUserData());
        StackPane root = new StackPane();
        root.getChildren().add(vbox);
        Scene scene = new Scene(root, 800, 850);
        primaryStage.setScene(scene);
        primaryStage.show();
    public static void main(String[] args)
        launch(args);
I noticed that if I put heavy business logic into the buttons while I switch the buttons it appears that the application hangs.
Is it possible to display "Loading.." instead of the button label while I switch the buttons?

Welcome to the world of multithreaded programming in JavaFX...
It's generally a mistake to perform any long-running task in the FX Application thread, as it will cause the UI to hang while it's running. You should use the javafx.concurrent package to perform background tasks; the Task class in particular will be useful to you. The javadocs have plenty of examples.
Note that it's also a mistake to modify the UI from a background thread, and that your Task implementation's call(...) method will be executed on a background thread. The Task class provides setOnSucceeded, setOnFailed, setOnCancelled methods to register a handler whose handle(...) method will be executed back on the FX Application thread.
For example, the basic strategy to respond to a button press by updating the UI, launching a long-running process, and then updating the UI with the results of that process is as follows. Replace 'T' with any data type.
myButton.setOnAction(new EventHandler<ActionEvent>() {
     @Override
     public void handle(ActionEvent event) {
          final Task<T> longRunningTask = new Task<T>() {
               @Override
               public T call() {
                    // perform long running operation:
                    T result = computeResult();    
                    return result ;    
          longRunningTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
               @Override   
               public void handle(WorkerStateEvent event) {
                    // get result of long running operation:    
                    T result = longRunningTask.getValue();
                    // now update UI on basis of result to indicate task is complete
          // update UI here to indicate task is about to run...
          // now start task:
          Thread t = new Thread(longRunningTask);
          t.setDaemon(true);
          t.start();
There's a bunch of other functionality in Task, such as a progress property and a message property. These can be bound, and updated on the FX Application thread via the appropriate updateXXX(...) methods.

Similar Messages

  • How to change a label of User Type in OIM 11g

    How to change a label of User Type in OIM 11g. If we have to change label of First Name or Last name then we can change in User.xml and some in resource properties file but what is the procedure to change for User Type.

    Follow this: http://download.oracle.com/docs/cd/E14571_01/doc.1111/e14309/uicust.htm#BABDEGFE
    i .Copy the $OIM_ORACLE_HOME/server/apps/oim.ear/admin.war/WEB-INF/lib/IdentityTaskFlow.jar to a local work directory, unzip it and locate UserAttributes.properties at /oracle/iam/resources/IdentityTaskFlow.
    ii. Update the userAttributes.properties file in the IdentityTaskFlow.jar/oracle/iam/resources/IdentityTaskFlow and create a new IdentityTaskFlow.jar
    iii. Copy the updated IdentityTaskFlow.jar to $OIM_ORACLE_HOME/ server/apps/oim.ear/admin.war/WEB-INF/lib/
    For "User Type", try putting the property name as "user_type" or try "role". One should work.
    HTH,
    BB

  • "error occurred while loading content" ?

    Curious if anyone is having the same problems with their Apple TV.
    It first started when we tried to rent episodes from Apple.  We'd purchase the episode, it would be ready for veiwing, and after about 5 mintutes the "error occured while loading content".  We'd go over to netflix and I could watch old episodes of various tv shows without a problem.  Downloading a movie rental in HD would also take up to 5 or 10 minutes. 
    I checked our wireless modem - everything was working fine.
    I reset the network settings on the Apple TV and checked that it was up to date.  Also reset all the username/password stuff.
    That did the trick for about a week and now we're having the same problem. 
    Thoughts anyone?
    Thanks

    I'm somewhat convinced that errors on the network (or for that matter over HDMI) can cause corruption of the Apple TV. In such cases restarting the Apple TV by removing ALL the cables for 30 seconds, usually does enough to reset things.

  • HOW TO CHANGE PROGRAMATICALLY LABELS OF BUTTONS AND ...

    I want to do a HTMLDB application is some languages that user choice in web page.
    I have resolve good how to change messages in pages, but I need to know how to change , labels in buttons, reports and in items.
    ¿How I can do this? Change this by program.
    Any help wellcome.
    Thanks in advanced.
    Regards everybody.

    Hi,
    Normally, to translate your entire application you would export the application using Shared Components=>Translation Services. There is documentation on how to do this:
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14303/global.htm
    You can also use Shared Components=>Manage Messages to translate individual items. If this is what you want, please let me know and I'll let you know what I did to achieve this.
    Normally, the user would select their preferred language using a browser setting. Do you intend for them to select a language on a page?
    Regards
    Andy

  • CR VS 2005 - How to change series label text?

    Hi...
    I got this problem while creating a chart in Crystal Report, hope someone can help me
    I'm using Crystal Report for Visual Studio 2005 and the type of the chart is 3D Riser.
    I would like to change the series axis (Y) label but it appears that its using the object name and I can't find anyway how to change it in designer.
    The only solution that I can find is change it in preview but I can't get it edited while in preview mode.
    Thanks before...
    Regards,
    Marry

    Obtain Crystal Reports 2008 and test the report design there. The Stand-alone versions of CR are way more featured, particularly when it comes to charts. Get  the report working in the CR2008 designer 1st, then see how it behaves at runtime. An eval of CR2008 can be downloaded from here:
    http://www.sap.com/australia/solutions/sap-business-objects/sme/freetrials/previous-versions/index.epx
    Report design questions should be posted to the SAP Crystal Reports Design forum.
    - Ludek
    Follow us on Twitter
    Got Enhancement ideas? Try the SAP Idea Place
    Share Your Knowledge in SCN Topic Spaces

  • JSlider: how to change tick label font?

    Hi,
    does anyone know how to change the tick labels font of a jSlider?
    Thanks for your help,
    Elke

    Just made this up, seems to work    Dictionary d = mySlider.getLabelTable();
        Enumeration e = d.elements();
        while (e.hasMoreElements()) {
          Object o = e.nextElement();
          if (o instanceof JComponent) ((JComponent)o).setFont(new Font("Dialog", 0, 9));
        }

  • Changing button label

    this is my program. i have created a grid of 20 * 20 and randomly assigned integers 0 to 4 into the cells (and colors corresponding to them).
    Now i need to put this program into a loop...i.e. the labels of the button should change with every loop....such that we can watch each transition for 5 seconds (hence there has to be some kind of pause, and some kind of dissolve older applet function). I should be able to change the button label by specifying the particular button (lets say [3][4]), finding the current value/label of the button, and then assigning a new label of the button.
    Can somebody help.
    import java.awt.*;
    import java.lang.*;
    import java.applet.*;
    import java.util.Random;
    <applet code="GridDemo" width=600 height=600>
    </applet>
    public class GridDemo extends Applet{
    static final int n = 20;
    static final int t = 10;
    Random r = new Random();
    public void init(){
    setLayout(new GridLayout(n,n));
    Color[] cols = {Color.WHITE, Color.YELLOW, Color.CYAN, Color.BLUE, Color.RED};
    for(int i=0; i<n; i++){
    for(int j=0;j<n; j++) {
    Button[][] myArray = new Button[n][n];
    int k=r.nextInt(5);
    Button b = new Button("" +k);
    b.setBackground(cols[k]);
    myArray[j] = b;
    add(b);

    I'm not sure if this is really what you want, make your class run a thread, that changes your labels after 5 second pauses. public class GridDemo extends Applet implements Runnable {
    public void init() {
       new Thread(this).start();  // starts the thread running.
    public void run() {
      while (someCondition) {
        // your for loops here..
        Thread.sleep(5000); // pause 5 seconds before running for loops again
    }

  • How to change a labels text which created at runtime?

    hi,
    i am creating label controls in runtime dynamically and adding them to a group component. this group component is in another custom component and i have lots of custom comp. in my app.
    my question is how can access (via id) and change a labels text whict created at runtime?
    i can change like this but i am setting id's and want to reach via id.
    var lbl:mx.controls.Label = mx.controls.Label(subMenu5.group_subMenu5.getElementAt(1));
    lbl.text = "good job";
    thank you, have a good day.

    First off, if you are already using a Spark Group, I would suggest you use a Spark Label instead of an MX Label. If you want to reference the Labels from the group, loop through the group's elements and check the if the element id matches the Label you want to assign text to.
    var lbl:Label;
    var n:int = myGroup.numElements;
    for (var i:int = 0; i < n; i++)
         lbl = myGroup.getElementAt(i) as Label;
         if (lbl && lbl.id == "myLabel")
              lbl.text = "newText";

  • How to change button colors in a loop?

    I am working on a task that should imitate an elevator. I have two vertical
    rows of round buttons "Up" and "Down" When a circle is selected randomly by
    the program, the circle becomes yellow and the elevator moves to that
    button.
    Here is what I did:
    1. created a class Circle where I save buttons' parameters
    2. saved Circle objects in an array
    3. drew the buttons depending on their parameters
    4. generated a random number, matched it with an array index and assigned
    the object color to yellow.
    Everything is fine except that I can't figure out how to change colors of my
    buttons in a loop.
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class Elevator3 extends JPanel
    private int n = 40;
    private int width = 200;
    private int floors = 10;
    private int interval = 1000;
    private boolean selected = false;
    private Circle[] buttons = new Circle[2*(floors-1)];
    public Elevator3()
    build();
    JFrame frame = new JFrame("Elevator3");
    setBackground(Color.WHITE);
    setFont(new Font("SansSerif", Font.PLAIN, Math.round(n/3)));
    frame.getContentPane().add(this);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(width, n*(floors+2) );
    frame.setVisible(true);
    public void build()
    Random r = new Random();
    int buttonPick;
    int timeUntilNextButton = r.nextInt(interval);
    for (int k =0; ; k++)
    if (timeUntilNextButton-- ==0)
    buttonPick = r.nextInt(2*(floors-1));
    //populate my buttons array here - how??
    timeUntilNextButton = r.nextInt(interval);
    //adding "Down" buttons
    for (int i=1, count=0; i < floors; i++, count++)
    if (count == buttonPick)
    selected = true;
    else
    selected = false;
    buttons[count]= new Circle(n*2, n*i, selected, Math.round(n/2));
    //build an array of "Up" circles
    for (int i=2, count=floors-1; i < floors+1; i++, count++)
    if (count == buttonPick)
    selected = true;
    else
    selected = false;
    buttons[count]= new Circle(n, n*i, selected, Math.round(n/2));
    public static void main(String[] args)
    new Elevator3();
    protected void paintComponent(Graphics g)
    super.paintComponent(g);
    //draw buttons
    for (int i=0; i < buttons.length; i++)
    g.setColor(buttons.getColor());
    g.fillOval(buttons[i].getX(), buttons[i].getY(), buttons[i].getWidth(), buttons[i].getWidth());
    class Circle
    private int x;
    private int y;
    private Color c;
    private boolean pressed;
    private int width;
    public Circle(int xCoordinate, int yCoordinate, boolean selected, int diameter)
    x = xCoordinate;
    y = yCoordinate;
    pressed = selected;
    width = diameter;
    if (pressed)
    c = Color.YELLOW;
    else
    c = Color.LIGHT_GRAY;
    public Color getColor()
    return c;
    public int getX()
    return x;
    public int getY()
    return y;
    public int getWidth()
    return width;

    hi,
    am sorry, i couldn't make out what exactly the problem, but as ur subject line says...
    may be the code give below will help you to change button colors in a loop..
              for(int i = 0; i < button.length; i++){
                   int color1 = (int)(250*Math.random());
                   int color2 = (int)(250*Math.random());
                   int color3 = (int)(250*Math.random());
                   Color c = new Color(color1,color2,color3);
                   button[i] = new JButton("button name");
                   button.addActionListener(this);
                   //to check the r, g, b combination.
                   //System.out.println(c);
                   button[i].setBackground(c);
                   button[i].setForeground(Color.white);
    //adding into the panel
                   panel.add(button[i]);
    hope this would help you.

  • How to localize button labels of a genuine NI VI?

    Some days ago I asked how to manage the translation of button labels of the
    genuine "file dialog VI" from NI (i.e. German label "Wahlen"-> English label
    "Select", German label "Abbruch"->English label "Cancel" etc.) for the
    finished application (I need to have a german and an English version).
    Someone suggested to select English from the Windows country selection and
    someone else suggested to use the string export/import function.
    However, nothing succeeded so far.
    I even bought WIN 2000 in English, since I thought LV perhaps refers to some
    standard/library Windows labelling names during compilation.
    Regarding the string export/import function: This should work if one is able
    to get into the VI, but with the genuine "
    file dialog VI" from NI I cannot
    enter the VI.
    Do I really have to program my own VI for such a simple localizing thing?
    So far, heavily disappointed....
    Thanks
    Klaus

    Klaus,
    Sorry to hear about your problems. Have you tried contacting NI about this? They are usually very good about supporting issues such as this.
    I am going to try a few things for you to see if I can help. If I don't post a followup, assume I had no luck. If you go to ni.com/ask you can start a formal support question. The NI tech support guys will help you fairly quickly (usually within a day or less!)
    Good luck.

  • Changing button label;JSP; input type="submit" name="jboEvent" value="Search"

    Hello everybody,
    I try to develop a multilanguage application in which the button labels will change accordingly with the browser's regional settings.
    The line in the generated DataQueryComponent.jsp file is the following:
    <input type="submit" name="jboEvent" value="Search">
    If I want to change the value like value="Rechercher" the application will not execute the query.
    In fact the section
    <jbo:ViewCriteriaIterate datasource="dsQuery" >
    </jbo:ViewCriteriaIterate>
    is not executed.
    I tried to generate the button with:
    <input type="submit" name="jboEvent" value="Rechercher" onClick="this.value='Search'"> ,
    but for a long query the name Search will remain as button label on the screen.
    Any new solutions, please?
    Thanks in advance.

    Visit that Jakarta web site. There is an i18n tag library that you will find useful.
    http://jakarta.apache.org/taglibs/doc/i18n-doc/intro.html

  • How to change account login in Adobe Content Viewer on Win8 Tablet?

    LS,
    Can you please tell me how I can change the account in Adobe Content Viewer.
    At the right upper corner it states :  Account: [email protected]  but I cannot find how I can signout and login with another mail address.
    We use another account to preview test presentations,
    I hope anyone can help  ;-)
    Kind regards,
    Erwin Boon

    Hi Christophe,
    I feel so .....   That I could not find that myself 
    Indeed , If I swipe from the right the Adobe content Viewer Settings tab appears and I can log out easily.
    Thanks for your help on this.
    You made my day  .
    Kind regards,
    Erwin Boon
    Christophe_Jossic wrote:
    on a Windows 8 tablet the menus are hidden in what is known as the Charms bar .. I believe if you swipe left from the right edge of the screen, it should appear

  • How to change the label of a total column in pivot view

    Hi
    Is there a way to change the label of the column created by analytics when calculated row based totals? Currently, it is same as the measure label to be summed.
    Thanks

    Hi
    Thanks for your help, actually that option works for the total displayed as the latest row, I mean the label for the total row. However, for the total column, the name stays as the same as the measure label.
    Can you further help me on the issue?
    Thanks

  • How to Change the label names in crmd_order

    HI Experts
    in CRMD_order transaction i want to change the lable names to the following Standard labels is it possible?..
    the standard label names are
    Standard Label name proposed label name
    Sold to Party = XXXXXXXX
    Requester = YYYYYYY
    Change Manager = AAAAAA
    Change Advisory Board= BBBBBBB
    I have found one link in sdn,To change the label Names But I am not able to find data element name.
    Kindly provide me  your valuable guidance on the above issue.
    Thanks in advance
    Thanks & Regards
    Anand

    Hi,
    it looks like you want to change the names of the partner functions.
    You can do this in the customizing, for example using SPROScenario Specific SettingsService Desk-Service Desk--Partner Determination Procedure (This one works for both ChaRM & Service Desk).
    The standard procedure in your case would be SDCR0001.
    The recommended way is to define your own Z partner functions and assign them to your own Z Partner Determination Procedure, which you have to replace in the configuration of your transaction type.
    Regards,
    Christoph

  • How to change field labels in CRM without changing original data structure

    Hello, I wish I could change the label of the input-type fields that are visibile in the CRM Account search page.
    The only way I have found so far is: go to the structure CRMT_BSP_SEAREQ_ACCOUNT
    and change the short description of the component.
    This is, anyway, very invasive, as I have to modify a SAP structure and I am asked an activation key.
    I have gone through the PCUI but cannot find a way to change the labels, anybody has a hint?
    At least, I would like to give the labels the same length so that the page is better organized, now all columns have different widths...

    Sorry, I had not seen this previous answer
    https://forums.sdn.sap.com/click.jspa?searchID=9822963&messageID=4781696
    Very nice!!!

Maybe you are looking for

  • Error when creating a view in r/3

    Guys, This is the first time creating a view in my R/3 sandbox, when I try to save it for the first time, It is asking for the development class, as it is just sand box, I typed "$TMP" and trying to save it as a local object. But it give me an error

  • WS2012 R2 Recovery from Windows Backup Not Working

    Hi, I tried to perform a bare metal recovery of a Windows Server 2012 R2 operating system backup but I can't get it to recover or access earlier restore points.  Any help would be appreciated!  I want to avoid reinstalling the OS *again*. I have a ha

  • Disposition in URM!!

    Hi All, I want to get the disposition date of records as well as non-records in URM10g. 1) Can I use a SQL query to fetch the database tables and columns to calculate the disposition date.. 2) Is there any specific content server service available in

  • Mute notifications while watching video (YouTube, Netflix, etc)

    Hi! i just bought the Apple Composite AV Cable and it works great. one thing I do find annoying is while watching Netflix or YouTube, either reminders from my calendar or push notifications show up and pause the video until I go to my iPad and dismis

  • How to reduce resoluion of bitmapped image

    Hello friends                      i am taking the bitmapped of a canvas a having height 390 and width 234.using that code                     var snapshot:ImageSnapshot = ImageSnapshot.captureImage(cnvParent);                      var bdata:String =