我当前的按钮事件处理代码是
public void handle( ActionEvent e )
{
if ( e.getSource() == menuS )
{
Label name = new Label( "Name" );
Label address = new Label( "Address" );
Button save = new Button( "Save" );
GridPane pane = new GridPane();
ColumnConstraints col = new ColumnConstraints();
col.setPercentWidth( 50 );
pane.getColumnConstraints().addAll( col, col );
pane.add( name, 0, 1, 1, 1 );
pane.add( address, 0, 2, 1, 1 );
pane.add( save, 1, 3, 1, 1 );
pane.add( addressTxt, 1, 2, 1, 1 );
Scene scene = new Scene( pane );
Stage stage = new Stage();
stage.setTitle( "Add Student" );
stage.setScene( scene );
stage.show();
}
else if ( e.getSource() == menuF )
{
Label name = new Label( "Name" );
Label address = new Label( "Address" );
Button save = new Button( "Save" );
GridPane pane = new GridPane();
ColumnConstraints col = new ColumnConstraints();
col.setPercentWidth( 50 );
pane.getColumnConstraints().addAll( col, col );
pane.add( name, 0, 1, 1, 1 );
pane.add( address, 0, 2, 1, 1 );
pane.add( save, 1, 3, 1, 1 );
Scene scene = new Scene( pane );
Stage stage = new Stage();
stage.setTitle( "Add Faculty Member" );
stage.setScene( scene );
stage.show();
}
else if ( e.getSource() == menuEmp )
{
Label name = new Label( "Name" );
Label address = new Label( "Address" );
Button save = new Button( "Save" );
GridPane pane = new GridPane();
ColumnConstraints col = new ColumnConstraints();
col.setPercentWidth( 50 );
pane.getColumnConstraints().addAll( col, col );
pane.add( name, 0, 1, 1, 1 );
pane.add( address, 0, 2, 1, 1 );
pane.add( save, 1, 3, 1, 1 );
Scene scene = new Scene( pane );
Stage stage = new Stage();
stage.setTitle( "Add Student" );
stage.setScene( scene );
stage.show();
}
else if ( e.getSource() == menuEmp )
{
Label name = new Label( "Name" );
Label address = new Label( "Address" );
Button save = new Button( "Save" );
GridPane pane = new GridPane();
ColumnConstraints col = new ColumnConstraints();
col.setPercentWidth( 50 );
pane.getColumnConstraints().addAll( col, col );
pane.add( name, 0, 1, 1, 1 );
pane.add( address, 0, 2, 1, 1 );
pane.add( save, 1, 3, 1, 1 );
Scene scene = new Scene( pane );
Stage stage = new Stage();
stage.setTitle( "Add Student" );
stage.setScene( scene );
stage.show();
}
else
{
Platform.exit();
System.exit( 0 );
}
}
我找不到问题。第一个开放给学生,但那里的那些不起作用。有帮助吗?我似乎无法找到任何其他方法来使这个代码功能。