Click here to Skip to main content
15,888,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to hide or disable or remove that default windows buttons(min,max & close).
I tried several things but result zero. Is there any way to do it?

OR

There is any way to create a custom form like Windows but without those buttons.

Please HELP!!!

What I have tried:

Java
package sample3;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;


public class Sample3 extends Application {
    
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
        
        stage.initStyle(StageStyle.UNDECORATED);

       // Group root = new Group();
        Scene scene = new Scene(root, 100, 100);

        stage.setScene(scene);
        stage.show();
        
        
        stage.setScene(scene);
        stage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
        
}
Posted
Updated 23-Nov-16 6:57am

You should try some of the different styles at StageStyle (JavaFX 8)[^].
 
Share this answer
 
Comments
KD Palekar 22-Nov-16 17:19pm    
I have seen this before but I don't know how to implement it in program. Please help me out.
Richard MacCutchan 23-Nov-16 2:50am    
Help you out with what? Check the documentation and try a few of the options to see if any of them do what you want. Try and use your initiative more to learn about the framework you are using.
KD Palekar 23-Nov-16 7:37am    
I did it. Thanks Anyway.
Richard MacCutchan 23-Nov-16 8:32am    
Well how about posting a Solution with the details, to help other people who might want to know about this?
KD Palekar 23-Nov-16 8:39am    
Ya Sure. I'll make a video on it coz i didn't found a single video on it. I'll make a video. And upload on YouTube. and will provide a link here.
So here is the solution. Fisrt of all create a java class file & and name it.
Here I am giving the name formDecorator.java

Java
package customform;

import java.awt.Insets;
import javafx.scene.Node;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
 *
 * @author KD
 */
public class formDecorator extends AnchorPane
{
    private double xOffset = 0;
    private double yOffset = 0;
    private Stage primaryStage;
    
    public formDecorator(Stage stage, Node node) {
        super();
        
        primaryStage = stage;
        this.setPadding(new javafx.geometry.Insets(0, 0, 0, 0));
    
        this.getChildren().addAll(node);

        this.setOnMousePressed((MouseEvent event) -> {
            xOffset = event.getSceneX();
            yOffset = event.getSceneY();
        });
        this.setOnMouseDragged((MouseEvent event) -> {
            primaryStage.setX(event.getScreenX() - xOffset);
            primaryStage.setY(event.getScreenY() - yOffset);
        });
       
}

}




and Second File is your main class file. Mine is custorForm. There you have to write the below code -

Java
package customform;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 *
 * @author KD
 */
public class CustomForm extends Application {
    
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
        
        stage.initStyle(StageStyle.TRANSPARENT);
        Scene scene = new Scene(new formDecorator(stage,root));
        scene.setFill(null);
        
        
        stage.setScene(scene);
        stage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
}



Thats it.. Now run your program.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900