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 in Tab #186

Closed
kanashius opened this issue Oct 1, 2015 · 11 comments
Closed

CodeArea in Tab #186

kanashius opened this issue Oct 1, 2015 · 11 comments

Comments

@kanashius
Copy link

When I put CodeAreas in a Tab, the first Tab is shown correctly, the other Tabs with other CodeAreas show just the scrollbar, not the content. I think its the Problem, that they are marked at invisible and need to be set to visible (FIX: override setVisible, so that the content is visible, too)
Code:

//To set it visible
mainPane.getSelectionModel().selectedItemProperty().addListener(
                new ChangeListener<Tab>() {
                    @Override
                    public void changed(ObservableValue<? extends Tab> ov, Tab t, Tab t1) {
                        System.out.println("changed");
                        if(t!=null)
                            t.getContent().setVisible(false);
                        t1.getContent().setVisible(true);
                    }
                }
        );
//TABCLASS
public class SyntaxEditorTab extends Tab{
    private SyntaxEditor editor;
    private File file;
    public SyntaxEditorTab(Settings mainSettings){
        editor = new SyntaxEditor(mainSettings);
        this.setContent(editor);
    }
    public SyntaxEditorTab(Settings mainSettings,File tmp){
        editor = new SyntaxEditor(mainSettings);
        file=tmp;
        editor.setFile(tmp);
        this.setText(tmp.getName());
        this.setContent(editor);
    }
    public void setFile(File x){
        this.file=x;
        editor.setFile(x);
    }
    public SyntaxEditor getEditor(){
        return editor;
    }
}
//SyntaxEditorTab extends CodeArea
@TomasMikula
Copy link
Member

From your description, it seems more like a problem with TabPane than with RichTextFX to me. Do you think otherwise?

@kanashius
Copy link
Author

The Problem is, that TabPane set its content invisible, if the Tab is not shown.
If the Tab changes, only the Scrollbars are set to visible (not recursive to the StyledTextArea, I think.)
Maybe, it can be set visible, manually?
(I looked up the source and think, you use List to display the text. I think, they are not set to visible, if CodeArea is set visible).
I think its just bad-made by the Tab^^

@kanashius
Copy link
Author

I don´t know why, but I worked a littlebit and now its displayed... or not... Its just displayed sometimes, and sometimes not. I have no idea why, I will look for a reason...
I´m loading files, when doubleclicked at a TreeView. The same File is Displayed sometimes, and Sometimes not...

@kanashius
Copy link
Author

Now I found the difference. The CodeArea is displayed in Tabs, when it have no scrollbars. If there are any scrollbars and its not opened in the first tab, the content is not visible. So I don´t think, its a problem of Tabs. But I don´t know.

@TomasMikula
Copy link
Member

Can you create a minimal self-contained test case that I can use to reproduce the problem?

@kanashius
Copy link
Author

I uploaded it at my Webside (.zip is not allowed here).
I hope it helps :)
http://kanashius.de/Downloads/codeAreaExample.zip

@TomasMikula
Copy link
Member

Thanks, but unfortunately I was not able to reproduce the problem. I simplified the example to a single java file. Could you please try to run this and report back whether you observe the same problem?

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;

import org.fxmisc.richtext.CodeArea;

public class RichTextFXInTabPane extends Application {

    // generate some text
    private static final String TEXT1, TEXT2;
    static {
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        for(int i = 0; i < 100; ++i) {
            for(int j = 100; j > i; --j) {
                sb1.append(i);
                sb2.append(100-i);
            }
            sb1.append("\n");
            sb2.append("\n");
        }
        TEXT1 = sb1.toString();
        TEXT2 = sb2.toString();
    }

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

    @Override
    public void start(Stage primaryStage) throws Exception{
        TabPane pane = new TabPane(
                new Tab("tab1", new CodeArea(TEXT1)),
                new Tab("tab2", new CodeArea(TEXT2)));
        primaryStage.setScene(new Scene(pane, 800, 600));
        primaryStage.show();
    }
}

@kanashius
Copy link
Author

Needed to rewrite TabPane pane = new TabPane(
new Tab("tab1", new CodeArea(TEXT1)),
new Tab("tab2", new CodeArea(TEXT2)));
, tab konstruktor error, could not create Tab with sting and codearea.
I made a Screenshot:
codeareaexample

@TomasMikula
Copy link
Member

new Tab(String, Node) constructor is only available sine 8u40, which is also the minimum recommended version for RichTextFX. There were some text rendering issues prior to 8u40 anyway, so I strongly suggest to upgrade.

@kanashius
Copy link
Author

Ok, didn´t saw that. I will update... thought I had the newest Version...

@TomasMikula
Copy link
Member

Closing this as it doesn't seem to be an issue in JDK 8u40 and later.

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