+ 7

How can I make a GUI Programme in Java?

GUI programming?

31st Aug 2018, 12:14 PM
Supun Dissanayake
Supun Dissanayake - avatar
12 Answers
+ 1
There are 3 packages you can use. awt, swing, javafx. javafx is the latest. If you need to develop GUI applications, then you have to learn about one of these.
5th Sep 2018, 1:55 PM
Sachintha Sampath
Sachintha Sampath - avatar
+ 4
I mean I want to do it with java.Do you have any idea?
31st Aug 2018, 12:19 PM
Supun Dissanayake
Supun Dissanayake - avatar
+ 3
I would appreciate if someone could tell me about JavaFX.
1st Sep 2018, 2:18 PM
Supun Dissanayake
Supun Dissanayake - avatar
+ 2
If I mean java, Netbeans is one of the most used ide for java. In netbeans you can create GUIs in mode with graphical interface or with code directly
31st Aug 2018, 12:23 PM
Ramphy Aquino Nova
Ramphy Aquino Nova - avatar
+ 2
For creating a Javafx application, you should first extend your main class to Application. Then you have to override start(). In your main funtion you write: launch(args). Now look at your start function: It has got one argument, the Stage primaryStage. This is your base. Then you write there: Pane root = new Pane(); Scene scene = new Scene(pane, 1000, 500); primaryStage.show(); root.setVisible(true); If you did that, and run your code, an empty window pops up. Your first JavaFx Window! Every object on the root pane such as Buttons, TextViews or ImageViews extend from Node. Those you can put on your GUI. Example for adding a button: Button button = new Button("The text"); button.setOnAction(event -> { //do stuff } button.setLayoutX(10); //horizontal positioning button.setLayoutY(10); //vertical pos. root.getChildren().add(button);
2nd Sep 2018, 7:56 AM
Jonas Schröter
Jonas Schröter - avatar
+ 1
I advice you NetBeans
31st Aug 2018, 12:15 PM
Ramphy Aquino Nova
Ramphy Aquino Nova - avatar
+ 1
Jonas Schroyer, can you please give me a good resource to learn javafx. ?
5th Sep 2018, 1:57 PM
Sachintha Sampath
Sachintha Sampath - avatar
+ 1
Sachintha Sampath I really don't know how I learned JavaFX myself... I just followed the steps I described. To develop my GUI, I looked up single kinds of Nodes such as Listviews etc. I'd recommend to do it that way:)
5th Sep 2018, 2:02 PM
Jonas Schröter
Jonas Schröter - avatar
+ 1
Thanks..!! I will try that. But I am still learning swing and awt. Is the coding similar in they both swing and javafx. ?
5th Sep 2018, 2:23 PM
Sachintha Sampath
Sachintha Sampath - avatar
+ 1
Mmh, many Node's names are pretty self explaining, so looking them up is pretty easy. I didn't try Swing nor awt, so I can't compare them to JFX
5th Sep 2018, 2:26 PM
Jonas Schröter
Jonas Schröter - avatar
+ 1
Use NetBeans and if you know swing in Java, generate project and start. *You must know swing or other GUI programming "way"
18th Dec 2018, 6:15 PM
Baltazarus
Baltazarus - avatar
0
I would not recommend to use WindowBuilder or such stuff. I mostly use only JavaFX without previews. It's pretty easy to work with after while.
31st Aug 2018, 12:52 PM
Jonas Schröter
Jonas Schröter - avatar