• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Understanding exercise  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got an exercise and did not understand a specific line, if anyone understood, I'd be happy to get help

I did everything to the last line that I did not understand what I should actually do?
How to limit the number of characters and what to limit? The Draw?


This is my exercise, my difficulty in the highlighted line:


Create a new program that simulates a window of the Winix operating system

You must define several classes that represent controls in the window: button, text box, and text box for password generation.
All controls are based on the basic control class containing:
• Position-containing X and Y coordinates.
• Height
• Width
• Label - text value
It also contains the Draw method that simply displays the text labels on the screen ...

The Button class inherits from Control and adds a color property to it and overrides the Draw method to display the value of the label within a starlet frame. For example, a button with a Click me value will be displayed on the screen as follows:

The TextBox class inherits from Control and adds a property that determines the maximum number of characters you can type in the box.
 
Master Rancher
Posts: 3276
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How to limit the number of characters and what to limit? 


If the limit is 3 characters, do not accept any characters after the 3rd character.  If the user enters: ABCD only accept ABC
 
Marshal
Posts: 60130
188
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

From the names of the classes, I think you are writing FX code. Please have a look through the documentation for Button, and Control and TextInputControl and its two subclasses. Have you been provided with a TextBox class? There isn't a textbox class in the standard API. Is the Button class in your assignment the same class as I linked to?
What you have been given is not a question but a statement. It says that your textbox class has a property to do with length of text acceptable. That suggests to me it is an IntegerProperty, just the way the Node#scaleXProperty is a DoubleProperty.
You haven't provided us with the full details, but I would make some suggestions:-
  • 1: Run the javadoc tool on the class you have got, and open the .html files you create.
  • 2: Look for the inheritance hierarchy of your class.
  • 3: Look for properties. Or look in the code for an IntegerProperty.
  • Ther ewill be some way to set that to 3. Unfortunately I have forgotten almost everything I ever knew about FX properties.
     
    Sheriff
    Posts: 5121
    138
    Chrome Eclipse IDE Java Postgres Database VI Editor
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There is not TextBox class in JavaFX currently.  There is TextField and TextArea.  Both of these inherit from TextInputControl which inherits from Control.

    There was a TextBox in JavaFX 1, but that was when you were using a script to run JavaFX and it's gone now.  Does your exercise really say TextBox?  If so, it may be very out of date.  Can you post where you found this exercise?
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!