class is not public in my package and cannot be accessed from outside package


I am using the following ControlFX project. Hence, created a class in my package and pasted the code from there.

Since I am not Inside the package org.controlsfx.dialog , I have to do the following:

import org.controlsfx.dialog.LightweightDialog;

And I am getting the following error as shown in the image below: image

When I went inside the package org.controlsfx.dialog and opened, LightweightDialog.class,

I wasn't able to make the class public.

How should I overcome this situation? Please advise.

5/1/2014 11:51:33 PM

If the class is not public, it is not part of the public API, so it's not intended (or really possible) for you to use.

To use a lightweight dialog in ControlsFX, you can either use the Dialogs class API and call the lightweight() method as part of the creation of your dialog, or you can call one of the Dialog constructors which takes a flag for the lightweight property.

Here's a complete example using the Dialogs fluent API:

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import org.controlsfx.dialog.Dialogs;

public class Main extends Application {
    public void start(Stage primaryStage) {
        try {
            BorderPane root = new BorderPane();
            Scene scene = new Scene(root,600,400);

            TabPane tabPane = new TabPane();
            Tab tab1 = new Tab("Tab 1");
            BorderPane tab1Root = new BorderPane();
            Button showDialogButton = new Button("Enter message...");
            VBox messages = new VBox(3);
            HBox buttons = new HBox(5);
            buttons.setPadding(new Insets(5));

            ScrollPane messageScroller = new ScrollPane();


            Tab tab2 = new Tab("Tab 2");
            tab2.setContent(new TextField("This is tab 2"));

            tabPane.getTabs().addAll(tab1, tab2);

            showDialogButton.setOnAction(event -> {
                String response = Dialogs.create()
                        .masthead("Enter a new message")
                        .message("Enter your new message:")
                if (response != null) {
                    messages.getChildren().add(new Label(response));


        } catch(Exception e) {

    public static void main(String[] args) {

Using the Dialog constructor you'd do something like this, though it's a lot more work:

// params are owner, title, lightweight:
Dialog dialog = new Dialog(someNode, "Dialog", true);
// lots of code here to configure dialog...
Action response =;

The real beauty of ControlsFX is the very comprehensive documentation. Just check the Javadocs for Dialogs and for Dialog.

5/2/2014 1:50:49 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow