JavaFX 2.X disable Button.

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 6202 Views - Last Post: 17 February 2013 - 11:28 AM Rate Topic: -----

#1 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

JavaFX 2.X disable Button.

Posted 14 February 2013 - 11:14 AM

I am looking all over the internet and i cannot find how to disable the button in JavaFX. Maybe there is a special Property that i should be searching for and not a method? Not sure. In Swing it was intuitive to do, unlinke FX.
Any help welcomed.
Is This A Good Question/Topic? 1
  • +

Replies To: JavaFX 2.X disable Button.

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX 2.X disable Button.

Posted 14 February 2013 - 11:24 AM

It has a .setDisabled() method thats inherited from Node

http://docs.oracle.c...sabled(boolean)
Was This Post Helpful? 2
  • +
  • -

#3 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 848
  • View blog
  • Posts: 2,585
  • Joined: 29-July 11

Re: JavaFX 2.X disable Button.

Posted 14 February 2013 - 11:44 AM

Oh, boy. JavaFX may be starting to make its way here... Good catch, Ryano. It's amazing how similar to Swing JavaFX is.
Was This Post Helpful? 0
  • +
  • -

#4 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX 2.X disable Button.

Posted 14 February 2013 - 11:51 AM

So similar, but so much better :P
Was This Post Helpful? 0
  • +
  • -

#5 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

Re: JavaFX 2.X disable Button.

Posted 14 February 2013 - 12:07 PM

Thanks. I was browsing thorugh API. Must have missed it.
Was This Post Helpful? 0
  • +
  • -

#6 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 848
  • View blog
  • Posts: 2,585
  • Joined: 29-July 11

Re: JavaFX 2.X disable Button.

Posted 14 February 2013 - 05:08 PM

View Postdarek9576, on 14 February 2013 - 07:07 PM, said:

Thanks. I was browsing thorugh API. Must have missed it.


Have you played around with fxml yet? It's so nice. :)
Was This Post Helpful? 1
  • +
  • -

#7 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

Re: JavaFX 2.X disable Button.

Posted 14 February 2013 - 06:08 PM

Because i was always building the GUIs with Swing, i kind of feel more comfortable with Java-like FX. Why would you say fxml is nicer than normal Java when it comes to JavaFX? Only difference i am aware of is the MVC but i am using MVC in my GUI anyway.
Was This Post Helpful? 0
  • +
  • -

#8 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 04:32 AM

It's one of those once you try it you'll like it kind of things. For example comparing some Java generation code to it's FXML counterpart, I for one much prefer the latter. It's so much cleaner, easier to read, and easier to add to in my opinion.

BorderPane border = new BorderPane();
Label toppanetext = new Label("Page Title");
border.setTop(toppanetext);
Label centerpanetext = new Label ("Some data here");
border.setCenter(centerpanetext);


<BorderPane>
    <top>
        <Label text="Page Title"/>
    </top>
    <center>
        <Label text="Some data here"/>
    </center>
</BorderPane>



For me it's like the switch from WinForms to WPF in the .Net world. At first I thought 'whats going on with this new xml based gui layouts. I much prefer my old drag n drop, change attributes workflow'. But then I gave it a try, and well it's pretty darn good to say the least, and extremely powerful way of designing gui's.

From the docs. The fact that it's not compiled is a big one for me. You can make small changes to the markup and have it immediately reflect in your designer. With Swing you either have to run it to see whats happening or use the designer which has to compile it anyways.

Quote

Benefits of FXML
Because the scene graph is more transparent in FXML, it is easy for a development team to create and maintain a testable user interface.

FXML is not a compiled language; you do not need to recompile the code to see the changes.

The content of an FXML file can be localized as the file is read. For example, if an FXML file is loaded using the en_US locale, then it produces the string "First Name" for a label based on the following resource string:
<Label text="%firstName"/>

If the locale is changed to fr_FR and the FXML file is reloaded, then the label shows "Prénom."
The same is not true for Java code, because you must manually update the content of every element of your user interface by obtaining a reference to it and calling the appropriate setter (such as setText()).

You can use FXML with any Java Virtual Machine (JVM) language, such as Java, Scala, or Clojure.
FXML is not limited to the view portion of the MVC interface. You can construct services or tasks or domain objects, and you can use Javascript or other scripting languages in FXML. For an example of using Javascript, see Use a Scripting Language to Handle Events in the FXML tutorial of the Getting Started guide.

Was This Post Helpful? 1
  • +
  • -

#9 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 04:41 AM

So when you are writing GUI using fxml, do you hand code it or do you use SceneBuilder?
Was This Post Helpful? 0
  • +
  • -

#10 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 04:46 AM

So far I've just written it by hand, although I haven't yet done a huge amount of JavaFX development past the odd small app.
Was This Post Helpful? 1
  • +
  • -

#11 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 04:48 AM

The scene builder is nowhere near as good as hand coding it, but it also depends on what layout manager you use, I prefer to use MiGLayout, so I can more easily manually tweak it to exactly how I want by hand without as much fuss as using scenebuilder or anything.
Was This Post Helpful? 1
  • +
  • -

#12 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 04:51 AM

Thanks for sharing. Never used MiGLayout but heard a lot of good things about it.
Was This Post Helpful? 0
  • +
  • -

#13 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 05:04 AM

Another reason to use FXML is because using styling programmatically is actually a bit more annoying then just adding the css reference in FXML.
Was This Post Helpful? 1
  • +
  • -

#14 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 848
  • View blog
  • Posts: 2,585
  • Joined: 29-July 11

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 05:29 AM

I don't use scene builder either. FXML is easy. It's not retardedly complicated like Swing.
Was This Post Helpful? 0
  • +
  • -

#15 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: JavaFX 2.X disable Button.

Posted 15 February 2013 - 06:31 AM

View Postfarrell2k, on 15 February 2013 - 05:29 AM, said:

I don't use scene builder either. FXML is easy. It's not retardedly complicated like Swing.


Here Here!

One day I hope swing will be completely a thing of the past, FX2 is more responsive in every way and more powerful to add.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2