Skip to content
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

CodeArea Jump to a Specific Line #208

Closed
mellwa opened this issue Nov 13, 2015 · 2 comments
Closed

CodeArea Jump to a Specific Line #208

mellwa opened this issue Nov 13, 2015 · 2 comments

Comments

@mellwa
Copy link

mellwa commented Nov 13, 2015

Hi Tomas,

Thank you for the quick reply in email. I tried moveTo(int) before but it didn't work. The file still shows the first line.
CodeArea codeArea = new CodeArea();
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
codeArea.appendText(content);
codeArea.setWrapText(true);
codeArea.moveTo(1000);

Scene scene1 = new Scene(codeArea, 800, 600);
Stage stage = new Stage();
stage.setTitle(objects[0].toString());
stage.setScene(scene1);
stage.show();

Also, the moveTo() method seems like only accept int value but codeArea.position(x, 0) gives a Position type value. Is there any other way to jump to a specific line?

@mellwa mellwa changed the title Code CodeArea Jump to a Specific Line Nov 13, 2015
@TomasMikula
Copy link
Member

You are right, it should be

codeArea.position(x, 0).toOffset()

moveTo() doesn't work on startup again because skin hasn't been initialized. Try to put it inside a Platform.runLater() and after stage.show():

stage.show();
Platform.runLater(() -> codeArea.moveTo(codeArea.position(1000, 0).toOffset()));

@mellwa
Copy link
Author

mellwa commented Nov 13, 2015

It works! Thank you, Tomas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants