-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text box like Telegram. Is it possible? #440
Comments
Something like this might work: import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.InlineCssTextArea;
public class AreaHeight extends Application {
@Override
public void start(Stage primaryStage) {
InlineCssTextArea area = new InlineCssTextArea();
VirtualizedScrollPane<InlineCssTextArea> pane = new VirtualizedScrollPane<>(area);
area.getParagraphs().sizeProperty().values()
.map(size -> {
int linesToDisplay;
if (size > 5) {
linesToDisplay = 5;
} else if (size == 0) {
linesToDisplay = 1;
} else {
linesToDisplay = size;
}
double lineHeight = 14;
return lineHeight * linesToDisplay;
})
.subscribe(pane::setPrefHeight);
primaryStage.setScene(new Scene(pane, 500, 500));
primaryStage.show();
}
} |
@JordanMartinez Thank you!
|
@otopba Why not use a lambda instead of a |
@JordanMartinez It's not necessary. I just prefer this way =) |
@otopba Does this resolve your issue? If so, could you close it? |
@JordanMartinez Yes. Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
I can not figure out how to make so that the text field can expand and shrink to a certain size. Just as it does in the Telegram.
Thank you!
The text was updated successfully, but these errors were encountered: