Created
May 14, 2020 10:19
-
-
Save gochev/450fb9a08b03b43d45573ab74dbd78b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Label; | |
import javafx.scene.control.Button; | |
import javafx.scene.layout.HBox; | |
import javafx.geometry.Insets; | |
import javafx.stage.Stage; | |
import javafx.scene.SceneAntialiasing; | |
import javax.swing.*; | |
import java.awt.*; | |
public class HelloFX extends Application { | |
@Override | |
public void start(Stage stage) { | |
String javaVersion = System.getProperty("java.version"); | |
String javafxVersion = System.getProperty("javafx.version"); | |
Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."); | |
Button button = new Button("Click Me"); | |
HBox hbox = new HBox(); | |
hbox.setPadding(new Insets(15, 12, 15, 12)); | |
hbox.setSpacing(10); | |
hbox.getChildren().addAll(l, button); | |
Scene scene = new Scene(hbox, 640, 480); | |
stage.setScene(scene); | |
stage.show(); | |
} | |
private static void createAndShowSwingGUI() { | |
JFrame frame = new JFrame("HelloWorldSwing"); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
JPanel panel = new JPanel(new FlowLayout()); | |
JLabel label = new JLabel("Hello Swing"); | |
panel.add(label); | |
panel.add(new JButton("Click Me")); | |
frame.getContentPane().add(panel); | |
frame.setSize(640,480); | |
frame.setVisible(true); | |
} | |
public static void main(String[] args) { | |
// System.setProperty("prism.lcdtext", "false"); | |
// System.setProperty("prism.text", "t2k"); | |
javax.swing.SwingUtilities.invokeLater(new Runnable() { | |
public void run() { | |
createAndShowSwingGUI(); | |
} | |
}); | |
launch(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment