/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package WindowTest;
//import java.awt.Insets;
import java.awt.Color;
import javafx.geometry.Insets;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*
* @author M
*/
public class WindowTest extends Application {
@Override
public void start(Stage primaryStage) {
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Button btn = new Button("create frame");
HBox hbBtn = new HBox(10);
hbBtn.getChildren().add(btn);
grid.add(hbBtn, 1, 4);
final Text actiontarget = new Text();
grid.add(actiontarget, 1, 6);
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
/*
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setSize(400, 300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
*/
JFrame frame = new JFrame("new JFrame");
// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setSize(400, 300);
JPanel panel = new JPanel();
JLabel label = new JLabel("a label");
panel.add(label);
JTextField tfName = new JTextField("some text", 15);
tfName.setForeground(Color.RED);
tfName.setBackground(Color.YELLOW);
panel.add(tfName);
JButton buttonOK = new JButton("aha");
panel.add(buttonOK);
frame.add(panel);
frame.setVisible(true);
}
});
Scene scene = new Scene(grid, 300, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}