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

Make Field Instance Variable Protected In SimpleControl #3

Closed
wemgl opened this issue Sep 18, 2017 · 0 comments
Closed

Make Field Instance Variable Protected In SimpleControl #3

wemgl opened this issue Sep 18, 2017 · 0 comments
Assignees

Comments

@wemgl
Copy link

wemgl commented Sep 18, 2017

I'm attempting to create a new SimpleControl subclass called SimpleHtmlEditorControl for my project and I cannot access the private field instance variable in SimpleControl in my subclass because it is private. This is the code that I wrote:

public class SimpleHtmlEditorControl extends SimpleControl<StringField> {

    private StackPane stackPane;

    private Label fieldLabel;
    private Label readOnlyLabel;
    private HTMLEditor htmlEditor;

    @Override
    public void initializeParts() {
        super.initializeParts();

        stackPane = new StackPane();

        fieldLabel = new Label();
        readOnlyLabel = new Label();

        htmlEditor = new HTMLEditor();
    }

    @Override
    public void layoutParts() {
        super.layoutParts();

        readOnlyLabel.getStyleClass().add("read-only-label");

        readOnlyLabel.setPrefHeight(26);

        stackPane.getChildren().addAll(htmlEditor, readOnlyLabel);

        stackPane.setAlignment(Pos.CENTER_LEFT);

        // Cannot access private instance variable 'field' here.
        int columns = 12;

        if (columns < 3) {
            add(fieldLabel, 0, 0, columns, 1);
            add(stackPane, 0, 1, columns, 1);
        } else {
            add(fieldLabel, 0, 0, 2, 1);
            add(stackPane, 2, 0, columns - 2, 1);
        }
    }

    @Override
    public void setupBindings() {
        super.setupBindings();
    }

    @Override
    public void setupValueChangedListeners() {
        super.setupValueChangedListeners();
    }
}

If I hardcode the column count, as you can see below my inline code comment above, the HTMLEditor is displayed fine. Otherwise, if I try to to call getSpan() on the field to get the field's actual column span I get a compile time error. Can you please make that field protected so subclasses can use it?

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