At the moment, I'm making a lw interpreter for a programming language. http://www.muppetlabs.com/~breadbox/bf/ Anyways, I'm trying to implement a text area, but I want the scroll bars to be hidden. I've looked at multiple tutorials to do this, but none of them seemed to work. Here is the code for my fxml window
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<SplitPane dividerPositions="0.6231155778894473" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" orientation="VERTICAL" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="interpreter.Window">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0">
<children>
<HBox layoutX="188.0" layoutY="81.0" prefHeight="262.0" prefWidth="599.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="-1.0" AnchorPane.topAnchor="0.0">
<children>
<Pane prefHeight="200.0" prefWidth="200.0">
<children>
<Button fx:id="executor" layoutX="64.0" layoutY="64.0" mnemonicParsing="false" onAction="#onExecute" text="Execute" />
<TextField fx:id="input" layoutX="15.0" layoutY="105.0" promptText="input" />
<ComboBox fx:id="byteSize" layoutX="23.0" layoutY="153.0" prefWidth="150.0" promptText="Byte Size" />
<TextField fx:id="bytes" alignment="CENTER_RIGHT" layoutX="25.0" layoutY="205.0" prefHeight="27.0" prefWidth="91.0" promptText="Bytes" text="30000" />
<Text layoutX="39.0" layoutY="41.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Control Center" textAlignment="CENTER">
<font>
<Font size="17.0" />
</font>
</Text>
<Text layoutX="122.0" layoutY="222.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Bytes" />
<Line endX="100.0" layoutX="98.0" layoutY="261.0" startX="-100.0" />
</children>
</Pane>
<TextArea fx:id="errorLog" disable="true" editable="false" prefHeight="262.0" prefWidth="38.0" style="-fx-text-fill: #ff0000" />
//this is the one where I want the scroll bars hidden
<TextArea fx:id="code" prefHeight="262.0" prefWidth="361.0" promptText="Code" HBox.hgrow="ALWAYS" />
</children>
</HBox>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<TextArea fx:id="output" disable="true" editable="false" layoutX="76.0" layoutY="-60.0" prefHeight="166.0" prefWidth="598.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</items>
</SplitPane>
I have it specified which one I want to hide the scroll bar's of. Does anybody have any insight to this? Thanks.
This can be done by setting the horizontal+vertical scrollbar policies on the inner ScrollPane. I'm currently unsure if this can be done via FXML or Java API, however it can be achieved via CSS.
#errorLog .scroll-pane {
-fx-hbar-policy: never;
-fx-vbar-policy: never;
}
This assumes the CSS sub-structure of TextArea, but this is well-defined in the official CSS gudie for TextArea
scroll-pane — ScrollPane
content — Region
If you're not using CSS already, you'll need to define a CSS file and add it to the Scene or FXML. Information on how to do this can be found in Styling UI Controls with CSS.