Linked Questions

Popular Questions

I am searching if there is some way that one call of method applies to all nodes in a scene or stage. Like in below given code, I have to call autosize() and some other styling methods for every single node which will increase the length and readability of my code. I shall be very thankful if anyone knows some way.

Thank you.

public class FXA1 extends Application implements EventHandler<ActionEvent>
{

    Button b1, b2, bs12, bs13, b21, b22, bs21, bs23, b31, b32, bs31, bs32;
    Label lb1, lb2, lb21, lb22, lb23, lb24, lb31, lb32;
    TextField tf1, tf2, tf21, tf22, tf23, tf31, tf32;

    BackgroundImage backImage;

    Alert alertM;

@Override 
public void start(Stage stg) throws Exception  
{
    stg.setTitle("JavaFX Assignment");
    stg.setResizable(false);
    stg.getIcons().add(new Image(this.getClass().getResource("AC_BackImage.png").toString()));

    b1 = new Button("Reset");
    b2 = new Button("Save Record");
    lb1 = new Label("Name:");
    lb2 = new Label("Roll Number:");
    tf1 = new TextField(null);
    tf2 = new TextField(null);
    bs12 = new Button("Update Record - Panel");
    bs13 = new Button("Delete Record - Panel");

            b1.autosize();
            b2.autosize();
            lb1.autosize();
            lb2.autosize();
            tf1.autosize();
            tf2.autosize();


    b1.setOnAction(this);
    b2.setOnAction(this);

Related Questions