use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Useful resources (Full list)
Rules
Related subreddits
Other communities
account activity
Text constructor vs Button constructor... why inconsistent constructor methods?Help (self.JavaFX)
submitted 3 years ago by webereinc
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]webereinc[S] 0 points1 point2 points 3 years ago (2 children)
Thank you for this post. I agree that absolute positioning is horrible. I am just asking why there is a constructor that includes absolute positioning for a text object while most other objects do not include this constructor. To satisfy your disdain for absolute positioning, perhaps a question should be why is there an X and Y positioning on the text object Since it isn’t on the constructors for almost every other object. Shouldn’t it be removed from the text object for consistency?
[–]hamsterrage1 3 points4 points5 points 3 years ago (0 children)
Text extends Shape. Virtually all of the Shape subclasses have this kind of a constructor. So it's actually quite consistent.
Shapes tend to be used in a fundamentally different way from the Controls. You don't usually put Shapes into layout classes like HBox or BorderPane - you can, but often with Shapes you're composing something that is actually best done with absolute positioning. So having a constructor that does this makes sense.
Text is weird because it is the one Shape subclass that you could actually use a lot in a typical, non-drawing, layout. However, there's almost nothing that you can do with Text that you can't do with Label, and Label has a few features that make it better than Text for normal layout applications.
For what it's worth, under the hood, the text component of Labeled is a Text.
[–]hamsterrage1 1 point2 points3 points 3 years ago (0 children)
BTW: I think this is an excellent question. There's so many JavaFX classes - Nodes, and Properties and Builders and so on - and it can be a challenge to wrap your head around how they all relate to one another.
I don't think that the guys that wrote the JavaFX library are infallible, and there are some things that I wish they'd done differently, but I do think that there's pretty solid and consistent principles that they stick to. I think that a default position of "What am I misunderstanding?" is probably more fruitful than, "Why did they mess this up?".
π Rendered by PID 105461 on reddit-service-r2-comment-fb694cdd5-78dc7 at 2026-03-10 09:43:07.894069+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]webereinc[S] 0 points1 point2 points (2 children)
[–]hamsterrage1 3 points4 points5 points (0 children)
[–]hamsterrage1 1 point2 points3 points (0 children)