Java Code Examples for javafx.scene.control.TextArea#setPrefColumnCount()

The following examples show how to use javafx.scene.control.TextArea#setPrefColumnCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TomlEntryEditor.java    From Lipi with MIT License 6 votes vote down vote up
private void initValueTextControl(String value) {

        if (value.length() > 30) {
            TextArea valueTextArea = new TextArea(value);
            valueTextArea.setPrefColumnCount(16);

            int cols = value.length() / 30;
            valueTextArea.setPrefRowCount(cols);
//            valueTextArea.prefHeight(20);
            valueTextArea.setWrapText(true);
            valueTextControl = valueTextArea;
        } else {
            TextField valueTextField = new TextField(value);
            valueTextField.setPrefColumnCount(18);
            valueTextControl = valueTextField;

        }

    }
 
Example 2
Source File: FileNamesComponent.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public FileNamesComponent(List<ExtensionFilter> filters) {

    this.filters = ImmutableList.copyOf(filters);

    // setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));

    txtFilename = new TextArea();
    txtFilename.setPrefColumnCount(40);
    txtFilename.setPrefRowCount(6);
    txtFilename.setFont(smallFont);

    Button btnFileBrowser = new Button("...");
    btnFileBrowser.setOnAction(e -> {
      // Create chooser.
      FileChooser fileChooser = new FileChooser();
      fileChooser.setTitle("Select files");

      fileChooser.getExtensionFilters().addAll(this.filters);

      String currentPaths[] = txtFilename.getText().split("\n");
      if (currentPaths.length > 0) {
        File currentFile = new File(currentPaths[0].trim());
        File currentDir = currentFile.getParentFile();
        if (currentDir != null && currentDir.exists())
          fileChooser.setInitialDirectory(currentDir);
      }

      // Open chooser.
      List<File> selectedFiles = fileChooser.showOpenMultipleDialog(null);
      if (selectedFiles == null)
        return;
      setValue(selectedFiles.toArray(new File[0]));
    });
    getChildren().addAll(txtFilename, btnFileBrowser);

  }
 
Example 3
Source File: UiHexViewDialog.java    From EWItool with GNU General Public License v3.0 5 votes vote down vote up
UiHexViewDialog( byte[] patchBlob ) {
  
  // setId( "hex-view-dialog" );
  
  setTitle( "EWItool - Patch in Hex" );
  initStyle(StageStyle.UTILITY);
  getDialogPane().getButtonTypes().add( ButtonType.OK );
  TextArea hexArea = new TextArea( EWI4000sPatch.toHex( patchBlob, true ) );
  hexArea.setPrefColumnCount( 62 );
  hexArea.setWrapText( true );
  getDialogPane().setContent( hexArea );
}
 
Example 4
Source File: PropertySheet.java    From JetUML with GNU General Public License v3.0 4 votes vote down vote up
private Control createExtendedStringEditor(Property pProperty)
{
	final int rows = 5;
	final int columns = 30;
	final TextArea textArea = new TextArea();
	textArea.setPrefRowCount(rows);
	textArea.setPrefColumnCount(columns);

	textArea.addEventFilter(KeyEvent.KEY_PRESSED, pKeyEvent ->
	{
		final String aFocusEventText = "TAB_TO_FOCUS_EVENT";
		
		if (!KeyCode.TAB.equals(pKeyEvent.getCode()))
        {
            return;
        }
        if (pKeyEvent.isAltDown() || pKeyEvent.isMetaDown() || pKeyEvent.isShiftDown() || !(pKeyEvent.getSource() instanceof TextArea))
        {
            return;
        }
        final TextArea textAreaSource = (TextArea) pKeyEvent.getSource();
        if (pKeyEvent.isControlDown())
        {
            if (!aFocusEventText.equalsIgnoreCase(pKeyEvent.getText()))
            {
            	pKeyEvent.consume();
                textAreaSource.replaceSelection("\t");
            }
        }
        else
        {
        	pKeyEvent.consume();
            final KeyEvent tabControlEvent = new KeyEvent(pKeyEvent.getSource(), pKeyEvent.getTarget(), pKeyEvent.getEventType(), 
            		pKeyEvent.getCharacter(), aFocusEventText, pKeyEvent.getCode(), pKeyEvent.isShiftDown(), true, pKeyEvent.isAltDown(),
            		pKeyEvent.isMetaDown());
            textAreaSource.fireEvent(tabControlEvent);
        }
    });

	textArea.setText((String) pProperty.get());
	textArea.textProperty().addListener((pObservable, pOldValue, pNewValue) -> 
	{
	   pProperty.set(textArea.getText());
	   aListener.propertyChanged();
	});
	
	return new ScrollPane(textArea);
}