LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(30, 20, 30, 0); Button okButton=new Button(this); okButton.setText("some text"); ll.addView(okButton, layoutParams);
LinearLayout gameWidgets = new LinearLayout (this); Button endGameButton = new Button(this); TextView myText = new TextView(this); endGameButton.setText("Start Game"); myText.setText("rIZ..i"); gameWidgets.addView(myText); gameWidgets.addView(endGameButton); endGameButton.setOnClickListener(this);
Button startButton = new Button("Start"); startButton.setOnAction(event -> { MessageProducer producer = new MessageProducer(messageQueue); Thread t = new Thread(producer); primaryStage.setScene(scene); primaryStage.show();
final Group root = new Group(); Button button = new Button("Add more windows"); primaryStage.setScene(new Scene(root, 600, 500)); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { w.getContentPane().getChildren().add(new Label("Content... \nof the window#"+counter++));
final Label currentlyPlaying = new Label(); final ProgressBar progress = new ProgressBar(); private ChangeListener<Duration> progressChangeListener; final Button skip = new Button("Skip"); final Button play = new Button("Pause"); skip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { final MediaPlayer curPlayer = mediaView.getMediaPlayer(); play.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { if ("Pause".equals(play.getText())) { mediaView.getMediaPlayer().pause(); play.setText("Play"); } else { mediaView.getMediaPlayer().play(); play.setText("Pause"); Button invisiblePause = new Button("Pause"); invisiblePause.setVisible(false); play.prefHeightProperty().bind(invisiblePause.heightProperty());
public class AlertDialogTestActivity extends Activity { AlertDialog alert; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button connect = new Button(this); connect.setText("Don't push me"); AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setTitle("Profile"); alertBuilder.setView(connect); connect.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { alert.dismiss(); } }); alert = alertBuilder.create(); } }
@Override public void start(final Stage primaryStage) { Button btn = new Button(); btn.setText("Open Dialog"); btn.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { final Stage dialog = new Stage(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(primaryStage); VBox dialogVbox = new VBox(20); dialogVbox.getChildren().add(new Text("This is a Dialog")); Scene dialogScene = new Scene(dialogVbox, 300, 200); dialog.setScene(dialogScene); dialog.show(); } }); }
public class MainActivity extends Activity implements View.OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TableLayout layout = new TableLayout (this); layout.setLayoutParams( new TableLayout.LayoutParams(4,5) ); layout.setPadding(1,1,1,1); for (int f=0; f<=13; f++) { TableRow tr = new TableRow(this); for (int c=0; c<=9; c++) { Button b = new Button (this); b.setText(""+f+c); b.setTextSize(10.0f); b.setTextColor(Color.rgb( 100, 200, 200)); b.setOnClickListener(this); tr.addView(b, 30,30); } // for layout.addView(tr); } // for super.setContentView(layout); } // () public void onClick(View view) { ((Button) view).setText("*"); ((Button) view).setEnabled(false); } } // class
vb.setPadding( new Inset(10,10,10,10) ); vb.setSpacing( 10 ); Button yesButton = new Button( "Yes" ); yesButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle( ActionEvent e ) { dial.close(); Button noButton = new Button( "No" ); noButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle( ActionEvent e ) { dial.close(); vb.setPadding( new Inset(10,10,10,10) ); vb.setSpacing( 10 ); Button okButton = new Button( "OK" ); okButton.setAlignment( Pos.CENTER ); okButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle( ActionEvent e ) { dial.close();
mainLayout = new LinearLayout(this); tv = new TextView(this); but = new Button(this); but.setText("Click Me"); but.setOnClickListener(new OnClickListener() { layout.setOrientation(LinearLayout.VERTICAL); tv.setText("Hi this is a sample text for popup window"); layout.addView(tv, params); popUp.setContentView(layout); mainLayout.addView(but, params); setContentView(mainLayout);
final Label label = new Label(); final Model model = new Model(); final NumberFormat formatter = NumberFormat.getIntegerInstance(); final Button startButton = new Button("Start"); startButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { primaryStage.setScene(scene); primaryStage.show();
Button configure = new Button("Configure"); changeBackgroundOnHoverUsingBinding(configure); Button update = new Button("Update"); changeBackgroundOnHoverUsingEvents(update); layout.setStyle("-fx-padding: 10;"); layout.getChildren().addAll(configure, update); stage.setScene(new Scene(layout)); stage.show();
private final Button runButton = new Button("Run"); private final Label label = new Label(); ); runButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) {
public class MyActivity extends Activity { protected void onCreate(Bundle icicle) { super.onCreate(icicle); final Button button = new Button(this); button.setText("Press me!"); setContentView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click } }); } }