How to get the default border for TextField?

In my textfields entry UI, I have them red border if the user enters invalid data. However, I need to reset the border to how it was.

field.setStyle("-fx-border-color: gray;");

It does not have the default border on windows XP (JavaFX2.2.21)

The default border is rounded and lightgray.

I also tried without success

field.setStyle ("border - fx - color: null;" "");

- and/or border - color: null; ») ; r color: gray; »

The style sheet by default (in Java 7), caspian.css, is not actually apply a border to the text field at all but use layered backgrounds of different radii for the border effect.

The best way to achieve the desired effect is to add and remove a style from the text box class and set the border color in an external style sheet. However, you should be aware of the https://javafx-jira.kenai.com/browse/RT-23085. One solution is to define a border radius default of zero on the text field and a different RADIUS to your "custom" css class Given that the default style sheet does not have a border that won't break anything.

Example:

import java.util.regex.Pattern;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ErrorTextFieldTest extends Application {

 @Override
  public void start(Stage primaryStage) {
  final VBox root = new VBox();
  final TextField textField = new TextField();
  root.getChildren().addAll(textField);

  final Pattern intPattern = Pattern.compile("-?[1-9]\\d*");
  final String errorCSSClass = "error" ;
  textField.textProperty().addListener(new ChangeListener() {
      @Override
      public void changed(ObservableValue observable,
          String oldValue, String newValue) {
        if (newValue.length()==0 || intPattern.matcher(newValue).matches()) {
          textField.getStyleClass().remove(errorCSSClass);
        } else if (! textField.getStyleClass().contains(errorCSSClass)) {
          textField.getStyleClass().add(errorCSSClass);
        }
        System.out.println(textField.getStyleClass());
      }
    });

  Scene scene = new Scene(root, 200, 100);
  scene.getStylesheets().add(getClass().getResource("errorTextField.css").toExternalForm());
  primaryStage.setScene(scene);
  primaryStage.show();
  }

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

errorTextField.css:

@CHARSET "US-ASCII";
.text-field.error {
 -fx-border-color: red ;
  -fx-border-width: 2px ;
}
.text-field {
 -fx-border-width: 0px ;
}

(Note: there is no space in ".text - field.error".)

Tags: Java

Similar Questions

  • How to get the default path for the data of the user to /store directory?

    I am writing an app that will create files on the device to the user.  These are not files that the user will want to transfer autour so I would store on /store instead of on the SD card.  I was wondering if there is a sort of. getUsersDirectoryPath() API which tells me that the way I should use to store these files.  That way if something changes on a later version of the operating system I don't have borken my application to hardcode it.

    any information would be appreciated,

    -Henry

    This can help you make your choice...  On OS 4.6 and higher, the user's home directory is exposed as a drive letter on the desk when the device is connected via USB.  This makes it unavailable for your application.   I use the persistent store specifically for this reason.

  • How to change the default path for documents and settings

    How to change the default path for documents and settings

    I try to change in the registry, but the profile can create but error! had no choice to change the default path % lecteur_systeme % d: /.

    Hello

    I suggest you to download TweakUI, this could help you or get you headed in the right direction
    http://Windows.Microsoft.com/en-us/Windows/downloads/Windows-XP

    Also this KB could help as well:
    http://support.Microsoft.com/kb/236621

    It will be useful.

  • Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value?

    Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value? I need the actual default value for an individual preference.
    Topic: config shows some default values, but I need the source from which everything: config returns to the default value.
    Any help in this direction is greatly appreciated.

    User Agent

    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x 64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    The preferences that are not hidden if they have by default are stored in two JavaScript text files in the Firefox program folder
    You can open them in a tab in Firefox through these links:
    resource:///defaults/pref/firefox.js
    resource:///greprefs/all.js

    (702598/forum/1/702598)

  • How to get the code produced for my Windows XP disc if I have the drive?

    Acquisition of Product Code Windows XP

    How to get the code produced for my Windows XP disc if I have the drive?  I signed the BONE when I bought it all first, but have no way of knowing if this is the way to receive a copy of the product key.

    Here are some utilities, which will display your product keys:

    Belarc Advisor: http://www.belarc.com/free_download.html
    (He did a good job of providing a wealth of information.
    However may not detect a key to office, then try one of the other two below)

    Also: http://www.nirsoft.net/utils/product_cd_key_viewer.html
    and: http://www.magicaljellybean.com/keyfinder.shtml

    Paid (free demo is available): Recover Keys: http://recover-keys.com/
    "quickly scans your system for more than 3000 + software '.
    and produces a list of software activation keys.

    13 keyfinder programs:
    http://pcsupport.about.com/od/productkeysactivation/TP/topkeyfinder.htm

    J W Stuart: http://www.pagestart.com

  • How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    You can use this class: http://goo.gl/GtMLP for information on devices

    something like this:

    String myDeviceModel = android.os.Build.MODEL;
    String myDeviceBrand = android.os.Build.BRAND;
    String myDeviceDevice = android.os.Build.DEVICE;
    
  • How to change the default setting for Australian News & Sport?

    How to change the default setting for Australian News & Sport?

    What setting, probably your browser home page, and how you do that depends on what browser you ar using.

    If using IE opens this page, then click on the "gear" icon to the rt at the top of the page, select Internet Options and look in the general tab

  • Web site created by Muse. The greats until tweek of today. Web site insists now for open index.html in the tablet. Don't know how product, nor how to change the default value for pc of office/index.html. Would advise. Bob

    Web site created by Muse. The greats until tweek of today. Web site insists now for open index.html in the tablet. Don't know how product, nor how to change the default value for pc of office/index.html. Would advise. Bob

    Hi Bob

    I think that you have found the solution but if still you are facing the question, please give me the url of the site that opens another provision in the tablet.

    Please make sure desktop redirection is checked in the site properties page layout.

    Thank you

    Sanjit

  • How to set the default printer for the user in 11i

    How to set the default printer for the user in 11i, please let me know how to set the new printer to the user, its Linux OS EBS 11i.

    Please see these documents.

    How to install the default printer for a user. [153927.1 ID]
    How to set up a default printer for a user in Oracle Applications [ID 1018856.102]
    How to set a default printer? [1237254.1 ID]
    How to configure the default printer for Applications [ID 184109.1]

    Thank you
    Hussein

  • How to get the 'default gateway' in Windows 7?

    I forgot my WiFi password and I need to change. So, how can I get the 'default gateway' address and enter the configuration of the router in Windows 7?

    I tried to connect my laptop to the modem and typed ipconfig in Command to get the "default gateway" address, but it is 0.0.0.0. If anyone can please hep me find. Thanks :)

    Hello

    You need to reset the router back to factory settings and set up your network wireless since the beginning.

    It has normally a button at the back of the router to reset.

    Instructions to set up your wireless network will be at the website of the manufacturer of the router.

    ______________________________________________________

    Microsoft prohibits any help given in these Forums for you help bypass or "crack" passwords lost or forgotten.

    Here's information from Microsoft, explaining that the policy:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-security/keeping-passwords-secure-Microsoft-policy-on/39f56ef0-5d68-41AD-9daa-6e6019c25d37

    See you soon.

  • How to get the default path of the data of a table space file

    I used below the sql statement to create a table space:

    CREATE A TABLESPACE DATAFILE AAA BBB SIZE 10 M AUTOEXTEND OFF...

    Notice, I do not give a full path instead of a file name, and then ask questions relevant to tables

    get the full path of the data file, assume that it's path below:

    d:\oracle\...\BBB

    So I don't think that there is a default path that oracle can use it to create the data file. My question

    is how to get this default path before creating a table space.

    Thank you very much.

    Hello

    I did similar simulations for you, then it could be seen easily:

    SQL > Show parameter db_create_file_dest

    VALUE OF TYPE NAME

    ------------------------------------ ----------- ------------------------------

    db_create_file_dest chain

    SQL > SELECT NAME, VALUE OF V$ PARAMETER

    2 where lower (name) = "db_create_file_dest;

    NAME

    --------------------------------------------------------------------------------

    VALUE

    --------------------------------------------------------------------------------

    db_create_file_dest

    It has the value NULL. Then where my datafile is going?

    SQL > create tablespace TEST datafile 'test01.dbf' size 10 M;

    Created tablespace.

    SQL > select file_name

    2 of dba_data_files

    3 where nom_tablespace = 'TEST ';

    FILE_NAME

    --------------------------------------------------------------------------------

    /U01/app/Oracle/product/12.1.0/Db_1/DBS/Test01.dbf

    When you check the alert logs, it will not show you the location of the data file. It will tell you what exactly you ran.

    ..

    ..

    Completed: drop tablespace test whose content and data files

    create tablespace datafile 'test01.dbf' size 10 M TEST

    Completed: create tablespace TEST datafile 'test01.dbf' size 10 M

    ..

    ..

    You can not SQL user * more? Well, I would say that, when you run the CREATE TABLESPACE command, is where you run the command:

    SQL > select file_name

    2 of dba_data_files

    3 where nom_tablespace = 'TEST ';

    FILE_NAME

    --------------------------------------------------------------------------------

    /U01/app/Oracle/product/12.1.0/Db_1/DBS/Test01.dbf


    So, you should get the location of your data file. Alternatively, you can run the query in the parameter $ v so that you know your default data file location.

    I hope this helps.

    Thank you.

    Kind regards

    Gaetan

  • Satellite L500-154 - how to get the software packaged for Win7

    How can I get the software "Bundled" for Win 7, I will install Win 7 full (no updates), in the moment is runing Vista on the laptop

    As far as I know, you can't have Win7 recovery media. Laptops ship with Vista can update only.

  • How to set the default value for the digital control on front panel?

    How to set a default value for a numeric control of LabVIEW 2009 Front Panel? I have several input values that are actually configuration settings I want to settle with the default values of zero. I want them to be the values displayed when the façade first appears until the code is executed.

    I really want to use the Minimum and Maximum limits by default for this because I still want to be able to define acceptable limits for values.

    I would not be able to specify a default value of zero for these entries?

    Enter the desired value, then "right click...... of default data of value to operations. Save the VI.

  • How to get the new update for the help and support

    OT:how to get the new update of the abd support help

    How to get help and support update

    Hello rickstemberger,

    Please click the number of the KB article for more information on how to add Windows Vista Help files.
    KB Article ID: 917607 -I can not open Help files that require the Windows Help program (WinHlp32.exe)

    Microsoft stopped including the 32-bit help files viewer in versions of Windows starting with Windows Vista and Windows Server 2008.
    However, with article 917607, you can download the appropriate version of the Windows Help program (WinHlp32.exe) and add them
    the operating system.

    Sincerely,

    Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • How to restore the default permissions (for example, the users folder) in windows 7?

    Dear windows users,

    Recently, I messed up the permissions of the files. What happened is that I took my laptop hard drive (win 7 64 bit system) in a USB external hard drive case. Then I get the USB into another windows office 7. I went through the users (perhaps of other files) folder in the hard disk of laptop on the desktop via a USB connection. It is very likely that the Office has changed the permissions of the files.
    I put the hard drive to my laptop, but some applications gives error like access denied messages.
    Is there a safe way to fix them? How to reset the default permissions?
    Thank you.
    BTW, have you worked with permissions of folders? Do you know what happens if permission to c:\users is messed up?

    When permissions in a subfolder in the users folder are confused so the user will not be able to run some programs, to create, modify or delete some files. The folder property affected, followed by assigning appropriate permissions, is usually sufficient to solve the problem.

Maybe you are looking for