Search Results

Search found 347 results on 14 pages for 'javafx'.

Page 6/14 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • MonologFX: FLOSS JavaFX Dialogs for the Taking

    - by HecklerMark
    Some time back, I was searching for basic dialog functionality within JavaFX and came up empty. After finding a decent open-source offering on GitHub that almost fit the bill, I began using it...and immediately began thinking of ways to "do it differently."  :-)  Having a weekend to kill, I ended up creating DialogFX and releasing it on GitHub (hecklerm/DialogFX) for anyone who might find it useful. Shortly thereafter, it was incorporated into JFXtras (jfxtras.org) as well. Today I'm sharing a different, more flexible and capable JavaFX dialog called MonologFX that I've been developing and refining over the past few months. The summary of its progression thus far is pretty well captured in the README.md file I posted with the project on GitHub: After creating the DialogFX library for JavaFX, I received several suggestions and requests for additional or different functionality, some of which ran counter to the interfaces and/or intent of the DialogFX "way of doing things". Great ideas, but not completely compatible with the existing functionality. Wanting to incorporate these capabilities, I started over...incorporating some parts of DialogFX into the new MonologFX, as I called it, but taking it in a different direction when it seemed sensible to do so. In the meantime, the OpenJFX team has released dialog code that will be refined and eventually incorporated into JavaFX and OpenJFX. Rather than just scrap the MonologFX code or hoard it, I'm releasing it here on GitHub with the hope that someone may find it useful, interesting, or entertaining. You may never need it, but regardless, MonologFX is there for the taking. Things of Note So, what are some features of MonologFX? Four kinds of dialog boxes: ACCEPT (check mark icon), ERROR (red 'x'), INFO (blue "i"), and QUESTION (blue question mark) Button alignment configurable by developer: LEFT, RIGHT, or CENTER Skins/stylesheets support Shortcut key/mnemonics support (Alt-<key>) Ability to designate default (RETURN-key) and cancel (ESCAPE-key) buttons Built-in button types and labels for OK, CANCEL, ABORT, RETRY, IGNORE, YES, and NO Custom button types: CUSTOM1, CUSTOM2, CUSTOM3 Internationalization (i18n) built in. Currently, files are provided for English/US and Spanish/Spain locales; please share others and I'll add them! Icon support for your buttons, with or without text labels Fully Free/Libre Open Source Software (FLOSS), with latest source code & .jar always available at GitHub Quick Usage Overview Having an intense distaste for rough edges and gears flying when things break (!), I've tried to provide defaults for everything and "fail-safes" to avoid messy outcomes if some property isn't specified, etc. This also feeds the goal of making MonologFX as easy to use as possible, while retaining the library's full flexibility. Or at least that's the plan.  :-) You can hand-assemble your buttons and dialogs, but I've also included Builder classes to help move that along as well. Here are a couple examples:         MonologFXButton mlb = MonologFXButtonBuilder.create()                .defaultButton(true)                .icon(new ImageView(new Image(getClass().getResourceAsStream("dialog_apply.png"))))                .type(MonologFXButton.Type.OK)                .build();         MonologFXButton mlb2 = MonologFXButtonBuilder.create()                .cancelButton(true)                .icon(new ImageView(new Image(getClass().getResourceAsStream("dialog_cancel.png"))))                .type(MonologFXButton.Type.CANCEL)                .build();         MonologFX mono = MonologFXBuilder.create()                .modal(true)                .message("Welcome to MonologFX! Please feel free to try it out and share your thoughts.")                .titleText("Important Announcement")                .button(mlb)                .button(mlb2)                .buttonAlignment(MonologFX.ButtonAlignment.CENTER)                .build();         MonologFXButton.Type retval = mono.showDialog();         MonologFXButton mlb = MonologFXButtonBuilder.create()                .defaultButton(true)                .icon(new ImageView(new Image(getClass().getResourceAsStream("dialog_apply.png"))))                .type(MonologFXButton.Type.YES)                .build();         MonologFXButton mlb2 = MonologFXButtonBuilder.create()                .cancelButton(true)                .icon(new ImageView(new Image(getClass().getResourceAsStream("dialog_cancel.png"))))                .type(MonologFXButton.Type.NO)                .build();         MonologFX mono = MonologFXBuilder.create()                .modal(true)                .type(MonologFX.Type.QUESTION)                .message("Welcome to MonologFX! Does this look like it might be useful?")                .titleText("Important Announcement")                .button(mlb)                .button(mlb2)                .buttonAlignment(MonologFX.ButtonAlignment.RIGHT)                .build(); Extra Credit Thanks to everyone who offered ideas for improvement and/or extension to the functionality contained within DialogFX. The JFXtras team welcomed it into the fold, and while I doubt there will be a need to include MonologFX in JFXtras, team members Gerrit Grunwald & Jose Peredas Llamas volunteered templates and i18n expertise to make MonologFX what it is. Thanks for the push, guys! Where to Get (Git!) It If you'd like to check it out, point your browser to the MonologFX repository on GitHub. Full source code is there, along with the current .jar file. Please give it a try and share your thoughts! I'd love to hear from you. All the best,Mark

    Read the article

  • Connecting SceneBuilder edited FXML to Java code

    - by daniel
    Recently I had to answer several questions regarding how to connect an UI built with the JavaFX SceneBuilder 1.0 Developer Preview to Java Code. So I figured out that a short overview might be helpful. But first, let me state the obvious. What is FXML? To make it short, FXML is an XML based declaration format for JavaFX. JavaFX provides an FXML loader which will parse FXML files and from that construct a graph of Java object. It may sound complex when stated like that but it is actually quite simple. Here is an example of FXML file, which instantiate a StackPane and puts a Button inside it: -- <?xml version="1.0" encoding="UTF-8"?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.paint.*?> <StackPane prefHeight="150.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml"> <children> <Button mnemonicParsing="false" text="Button" /> </children> </StackPane> ... and here is the code I would have had to write if I had chosen to do the same thing programatically: import javafx.scene.control.*; import javafx.scene.layout.*; ... final Button button = new Button("Button"); button.setMnemonicParsing(false); final StackPane stackPane = new StackPane(); stackPane.setPrefWidth(200.0); stackPane.setPrefHeight(150.0); stacPane.getChildren().add(button); As you can see - FXML is rather simple to understand - as it is quite close to the JavaFX API. So OK FXML is simple, but why would I use it?Well, there are several answers to that - but my own favorite is: because you can make it with SceneBuilder. What is SceneBuilder? In short SceneBuilder is a layout tool that will let you graphically build JavaFX user interfaces by dragging and dropping JavaFX components from a library, and save it as an FXML file. SceneBuilder can also be used to load and modify JavaFX scenegraphs declared in FXML. Here is how I made the small FXML file above: Start the JavaFX SceneBuilder 1.0 Developer Preview In the Library on the left hand side, click on 'StackPane' and drag it on the content view (the white rectangle) In the Library, select a Button and drag it onto the StackPane on the content view. In the Hierarchy Panel on the left hand side - select the StackPane component, then invoke 'Edit > Trim To Selected' from the menubar That's it - you can now save, and you will obtain the small FXML file shown above. Of course this is only a trivial sample, made for the sake of the example - and SceneBuilder will let you create much more complex UIs. So, I have now an FXML file. But what do I do with it? How do I include it in my program? How do I write my main class? Loading an FXML file with JavaFX Well, that's the easy part - because the piece of code you need to write never changes. You can download and look at the SceneBuilder samples if you need to get convinced, but here is the short version: Create a Java class (let's call it 'Main.java') which extends javafx.application.Application In the same directory copy/save the FXML file you just created using SceneBuilder. Let's name it "simple.fxml" Now here is the Java code for the Main class, which simply loads the FXML file and puts it as root in a stage's scene. /* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. */ package simple; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class Main extends Application { /** * @param args the command line arguments */ public static void main(String[] args) { Application.launch(Main.class, (java.lang.String[])null); } @Override public void start(Stage primaryStage) { try { StackPane page = (StackPane) FXMLLoader.load(Main.class.getResource("simple.fxml")); Scene scene = new Scene(page); primaryStage.setScene(scene); primaryStage.setTitle("FXML is Simple"); primaryStage.show(); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } } Great! Now I only have to use my favorite IDE to compile the class and run it. But... wait... what does it do? Well nothing. It just displays a button in the middle of a window. There's no logic attached to it. So how do we do that? How can I connect this button to my application logic? Here is how: Connection to code First let's define our application logic. Since this post is only intended to give a very brief overview - let's keep things simple. Let's say that the only thing I want to do is print a message on System.out when the user clicks on my button. To do that, I'll need to register an action handler with my button. And to do that, I'll need to somehow get a handle on my button. I'll need some kind of controller logic that will get my button and add my action handler to it. So how do I get a handle to my button and pass it to my controller? Once again - this is easy: I just need to write a controller class for my FXML. With each FXML file, it is possible to associate a controller class defined for that FXML. That controller class will make the link between the UI (the objects defined in the FXML) and the application logic. To each object defined in FXML we can associate an fx:id. The value of the id must be unique within the scope of the FXML, and is the name of an instance variable inside the controller class, in which the object will be injected. Since I want to have access to my button, I will need to add an fx:id to my button in FXML, and declare an @FXML variable in my controller class with the same name. In other words - I will need to add fx:id="myButton" to my button in FXML: -- <Button fx:id="myButton" mnemonicParsing="false" text="Button" /> and declare @FXML private Button myButton in my controller class @FXML private Button myButton; // value will be injected by the FXMLLoader Let's see how to do this. Add an fx:id to the Button object Load "simple.fxml" in SceneBuilder - if not already done In the hierarchy panel (bottom left), or directly on the content view, select the Button object. Open the Properties sections of the inspector (right panel) for the button object At the top of the section, you will see a text field labelled fx:id. Enter myButton in that field and validate. Associate a controller class with the FXML file Still in SceneBuilder, select the top root object (in our case, that's the StackPane), and open the Code section of the inspector (right hand side) At the top of the section you should see a text field labelled Controller Class. In the field, type simple.SimpleController. This is the name of the class we're going to create manually. If you save at this point, the FXML will look like this: -- <?xml version="1.0" encoding="UTF-8"?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.paint.*?> <StackPane prefHeight="150.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml" fx:controller="simple.SimpleController"> <children> <Button fx:id="myButton" mnemonicParsing="false" text="Button" /> </children> </StackPane> As you can see, the name of the controller class has been added to the root object: fx:controller="simple.SimpleController" Coding the controller class In your favorite IDE, create an empty SimpleController.java class. Now what does a controller class looks like? What should we put inside? Well - SceneBuilder will help you there: it will show you an example of controller skeleton tailored for your FXML. In the menu bar, invoke View > Show Sample Controller Skeleton. A popup appears, displaying a suggestion for the controller skeleton: copy the code displayed there, and paste it into your SimpleController.java: /** * Sample Skeleton for "simple.fxml" Controller Class * Use copy/paste to copy paste this code into your favorite IDE **/ package simple; import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Button; public class SimpleController implements Initializable { @FXML // fx:id="myButton" private Button myButton; // Value injected by FXMLLoader @Override // This method is called by the FXMLLoader when initialization is complete public void initialize(URL fxmlFileLocation, ResourceBundle resources) { assert myButton != null : "fx:id=\"myButton\" was not injected: check your FXML file 'simple.fxml'."; // initialize your logic here: all @FXML variables will have been injected } } Note that the code displayed by SceneBuilder is there only for educational purpose: SceneBuilder does not create and does not modify Java files. This is simply a hint of what you can use, given the fx:id present in your FXML file. You are free to copy all or part of the displayed code and paste it into your own Java class. Now at this point, there only remains to add our logic to the controller class. Quite easy: in the initialize method, I will register an action handler with my button: () { @Override public void handle(ActionEvent event) { System.out.println("That was easy, wasn't it?"); } }); ... -- ... // initialize your logic here: all @FXML variables will have been injected myButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("That was easy, wasn't it?"); } }); ... That's it - if you now compile everything in your IDE, and run your application, clicking on the button should print a message on the console! Summary What happens is that in Main.java, the FXMLLoader will load simple.fxml from the jar/classpath, as specified by 'FXMLLoader.load(Main.class.getResource("simple.fxml"))'. When loading simple.fxml, the loader will find the name of the controller class, as specified by 'fx:controller="simple.SimpleController"' in the FXML. Upon finding the name of the controller class, the loader will create an instance of that class, in which it will try to inject all the objects that have an fx:id in the FXML. Thus, after having created '<Button fx:id="myButton" ... />', the FXMLLoader will inject the button instance into the '@FXML private Button myButton;' instance variable found on the controller instance. This is because The instance variable has an @FXML annotation, The name of the variable exactly matches the value of the fx:id Finally, when the whole FXML has been loaded, the FXMLLoader will call the controller's initialize method, and our code that registers an action handler with the button will be executed. For a complete example, take a look at the HelloWorld SceneBuilder sample. Also make sure to follow the SceneBuilder Get Started guide, which will guide you through a much more complete example. Of course, there are more elegant ways to set up an Event Handler using FXML and SceneBuilder. There are also many different ways to work with the FXMLLoader. But since it's starting to be very late here, I think it will have to wait for another post. I hope you have enjoyed the tour! --daniel

    Read the article

  • What is the best strategy for populating a TableView from a service?

    - by alrutherford
    I have an application which has a potentially long running background process. I want this process to populate a TableView as results objects are generated. The results objects are added to an observableList and have properties which are bound to the columns in the usual fashion for JavaFX. As an example of this consider the following sample code Main Application import java.util.LinkedList; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class DataViewTest extends Application { private TableView<ServiceResult> dataTable = new TableView<ServiceResult>(); private ObservableList<ServiceResult> observableList; private ResultService resultService; public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { observableList = FXCollections.observableArrayList(new LinkedList<ServiceResult>()); resultService = new ResultService(observableList); Button refreshBtn = new Button("Update"); refreshBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { observableList.clear(); resultService.reset(); resultService.start(); } }); TableColumn<ServiceResult, String> nameCol = new TableColumn<ServiceResult, String>("Value"); nameCol.setCellValueFactory(new PropertyValueFactory<ServiceResult, String>("value")); nameCol.setPrefWidth(200); dataTable.getColumns().setAll(nameCol); // productTable.getItems().addAll(products); dataTable.setItems(observableList); Scene scene = new Scene(new Group()); stage.setTitle("Table View Sample"); stage.setWidth(300); stage.setHeight(500); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(refreshBtn, dataTable); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); } } Service public class ResultService extends Service<Void> { public static final int ITEM_COUNT = 100; private ObservableList<ServiceResult> observableList; /** * Construct service. * */ public ResultService(ObservableList<ServiceResult> observableList) { this.observableList = observableList; } @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { process(); return null; } }; } public void process() { for (int i = 0; i < ITEM_COUNT; i++) { observableList.add(new ServiceResult(i)); } } } Data public class ServiceResult { private IntegerProperty valueProperty; /** * Construct property object. * */ public ServiceResult(int value) { valueProperty = new SimpleIntegerProperty(); setValue(value); } public int getValue() { return valueProperty.get(); } public void setValue(int value) { this.valueProperty.set(value); } public IntegerProperty valueProperty() { return valueProperty; } } Both the service and the TableView share a reference to the observable list? Is this good practise in JavaFx and if not what is the correct strategy? If you hit the the 'Update' button the list will not always refresh to the ITEM_COUNT length. I believe this is because the observableList.clear() is interfering with the update which is running in the background thread. Can anyone shed some light on this?

    Read the article

  • Chapter 3: JavaFX Primer3

    JavaFX Script blends declarative programming concepts with object orientation. This provides a highly productive, yet flexible and robust, foundation for applications. However, with this flexibility comes responsibility from the developer.

    Read the article

  • Eclipse and JavaFX? is it just me?

    - by jeff porter
    I'm looking at learning JavaFX. I've tried setting Eclipse to develop a small app and I've downloaded the Eclipse plugin. Eclipse JavaFX plugin BUT... it just seems, well, flakey. So I have 3 questions... 1: Is there a better plugin? 2: Or is there some great set of tutorials out there that I'm missing? 3: finally, is it meant to be easy to call Java code from FX? I'm stuggling, it there a good example somewhere? On questions 1 & 2, Eclipse underlines code in red that just shouln't be. For example.. see this image... Why does it underline bit of imports in red? I know this is little of an open ended question. So I guess my main question is this... Is my experiance of JavaFX and Eclipse the best I can hope for? Or am I missing something ? (and I'm not looking for a Yes/No response) :-) Just looking for a discussion on how best to learn/develop JavaFx.

    Read the article

  • Is JavaFx suitable for creating online multiplayer board/card games?

    - by Piniu
    In JavaFx i can easy create animations, moving pieces etc., but as far as i see there is better to write program logic and communication in java. Worst i see at the moment is calling javafx part as a result of data incoming from server. Is there any convenient way to do it or its better to change to other technology (flex, qt?) assuming it is not important if program will run in browser or outside as a standalone application? I just started to learn javafx but can drop it and move to other technology and consider c++ + wxWidgets or Qt which im more comforatable with.

    Read the article

  • Java Spotlight Episode 87: Nandini Ramani on Java FX and Embedded Java

    - by Roger Brinkley
    Interview with Nandini Ramani on JavaFX and Embedded Java. Joining us this week on the Java All Star Developer Panel is Arun Gupta, Java EE Guy. Right-click or Control-click to download this MP3 file. You can also subscribe to the Java Spotlight Podcast Feed to get the latest podcast automatically. If you use iTunes you can open iTunes and subscribe with this link:  Java Spotlight Podcast in iTunes. Show Notes News JFXtras Project: There’s an app for that! JavaOne 2012 content catalog is online Native packaging for JavaFX in 2.2 EL 3.0 Public Review (JSR 341) el-spec.java.net Events June 18-20, QCon, New York City June 19, CJUG, Chicago June 20, 1871, Chicago June 26-28, Jazoon, Zurich, Switzerland Jun 27, Houston JUG July 5, Java Forum, Stuttgart, Germany Jul 13-14, IndicThreads, Delhi July 30-August 1, JVM Language Summit, Santa Clara Feature InterviewNandini Ramani is Vice President of Development at Oracle in the Fusion Middleware Group. She is responsible for the Java Client Platform and has a long history of creating innovation and futures at Sun Microsystems.Nandini launched the JavaFX Platform and tools and had been actively involved in JavaFX since its inception in May 2007. Prior to joining the client group, Nandini was in the Software CTO Office driving the emerging technologies group for incubation projects. She has a background in both hardware and software, having worked in hardware architecture and simulation team in the Accelerated Graphics group and the graphics and media team in the JavaME group. She was involved in the development of XML standards, as Co-Chair of the W3C Scalable Vector Graphics working group and as a member of the W3C Compound Document Formats working group. She was also a member of several graphics and UI related expert groups in the JCP. Mail Bag What’s Cool "OpenJDK is now the heart of a vital piece of technology that runs large parts of our entire civilization.” Java Magazine PetStore using Java EE 6 - Antonio Goncalves

    Read the article

  • Do you start migrating your Swing project to JavaFX

    - by Yan Cheng CHEOK
    I have a 4 years old project which is written in Swing + SwingX. Currently, it is still alive and still kicking. However, as more GUI related feature requests coming in (For instance, a sortable tree table), I start to feel the difficulty in fulling the requests. This is true especially there isn't active development going around SwingX project. Also, I hardly can find any good, yet being actively maintained/ developed/ evolving GUI Java framework. I was wondering, any of Swing developers feel the same thing? Have you start to migrate your Swing project to a much more active developed GUI framework like JavaFX?

    Read the article

  • Ubuntu 12.04 version of Netbeans doesn't have the JavaFX plugin

    - by aliasbody
    I just want to know why does Netbeans 7.0.1 from the official Ubuntu 12.04 doesn't have all the plugins (in especial the JavaFX plugin) on it while the official Netbeans from the website (even the version with the less plugin), has it by default ? And how can we change that ? Because I love Ubuntu (even if it is extremly slow on my Asus 1215N (it is the only OS that is slow on it, but that's not very important), but I am trying to use it only with the software provided by the Original repositories without having to download manually or even use any PPA. Thanks in Advance

    Read the article

  • OpenJDK In The News: Oracle Outlines Roadmap for Java SE and JavaFX at JavaOne 2012

    - by $utils.escapeXML($entry.author)
    The OpenJDK Community continues to host the development of the reference implementation of Java SE 8. Weekly developer preview builds of JDK 8 continue to be available from jdk8.java.net.OpenJDK continues to thrive with contributions from Oracle, as well as other companies, researchers and individuals.The OpenJDK Web Site Terms of Use was recently updated to allow work on Java Specification Requests (JSRs) for Java SE to take place in the OpenJDK Community, alongside their corresponding reference implementations, so that specification leads can satisfy the new transparency requirements of the Java Community Process (JCP 2.8).“The recent decision by the Java SE 8 Expert Group to defer modularity to Java SE 9 will allow us to focus on the highly-anticipated Project Lambda, the Nashorn JavaScript engine, the new Date/Time API, and Type Annotations, along with numerous other performance, simplification, and usability enhancements,” said Georges Saab, vice president, Software Development, Java Platform Group at Oracle. “We are continuing to increase our communication and transparency by developing the reference implementation and the Oracle-led JSRs in the OpenJDK community.”Quotes taken from the 14th press release from Oracle mentioning OpenJDK, titled "Oracle Outlines Roadmap for Java SE and JavaFX at JavaOne 2012".

    Read the article

  • JavaFX in a JSF 2.0 Custom Tag?

    - by Geertjan
    I followed these instructions and now have a simple JSF 2.0 tag handler: The reason I created this is because I'm curious about whether it would be possible to change the tag created above: <my:hello name="Jack" /> ...to something like this: <my:chart type="pie" xAxis="${some-expression}" yAxis="${some-expression}" width="300" height="500" /> Has anyone tried this? That could be a way to incorporate a JavaFX chart into a Java EE application. That's different to how Adam Bien is doing it in LightFish, but might be a simpler and more reusable way of doing the same thing.

    Read the article

  • Oracle introduit la création des packages natifs dans JavaFX 2.2, permettant d'exécuter une application sans dépendances externes

    Oracle introduit la création des packages natifs dans JavaFX 2.2 permettant d'exécuter une application sans dépendances externes Oracle a annoncé que JavaFX 2.2, sa solution pour la création d'applications internet riches (RIA), pourra être empaquetée en natif pour diverses plateformes. Cette nouvelle possibilité permettra aux développeurs de créer des applications qui pourront être installées et exécutées sans nécessiter de dépendances externes comme JRE ou encore le SDK FX. Le système "native package" pour les applications JavaFX fonctionne en créant un wrapper de votre application JavaFX, comprenant le code de l'application et les ressources, le runtime Java e...

    Read the article

  • DialogFX: A New Approach to JavaFX Dialogs

    - by HecklerMark
    How would you like a quick and easy drop-in dialog box capability for JavaFX? That's what I was thinking when a weekend presented itself. And never being one to waste a good weekend...  :-) After doing some "roll-your-own" basic dialog building for a JavaFX app, I recently stumbled across Anton Smirnov's work on GitHub. It was a good start, but it wasn't exactly what I was after, and ideas just kept popping up of things I'd do differently. I wanted something a bit more streamlined, a bit easier to just "drop in and use". And so DialogFX was born. DialogFX wasn't intended to be overly fancy, overly clever - just useful and robust. Here were my goals: Easy to use. A dialog "system" should be so simple to use a new developer can drop it in quickly with nearly no learning curve. A seasoned developer shouldn't even have to think, just tap in a few lines and go. Why should dialogs slow "actual development"?  :-) Defaults. If you don't specify something (dialog type, buttons, etc.), a good dialog system should still work. It may not be pretty, but it shouldn't throw gears. Sharable. It's all open source. Even the icons are in the commons, so they can be reused at will. Let's take a look at some screen captures and the code used to produce them.   DialogFX INFO dialog Screen captures Windows Mac  Sample code         DialogFX dialog = new DialogFX();        dialog.setTitleText("Info Dialog Box Example");        dialog.setMessage("This is an example of an INFO dialog box, created using DialogFX.");        dialog.showDialog(); DialogFX ERROR dialog Screen captures Windows Mac  Sample code         DialogFX dialog = new DialogFX(Type.ERROR);        dialog.setTitleText("Error Dialog Box Example");        dialog.setMessage("This is an example of an ERROR dialog box, created using DialogFX.");        dialog.showDialog(); DialogFX ACCEPT dialog Screen captures Windows Mac  Sample code         DialogFX dialog = new DialogFX(Type.ACCEPT);        dialog.setTitleText("Accept Dialog Box Example");        dialog.setMessage("This is an example of an ACCEPT dialog box, created using DialogFX.");        dialog.showDialog(); DialogFX Question dialog (Yes/No) Screen captures Windows Mac  Sample code         DialogFX dialog = new DialogFX(Type.QUESTION);        dialog.setTitleText("Question Dialog Box Example");        dialog.setMessage("This is an example of an QUESTION dialog box, created using DialogFX. Would you like to continue?");        dialog.showDialog(); DialogFX Question dialog (custom buttons) Screen captures Windows Mac  Sample code         List<String> buttonLabels = new ArrayList<>(2);        buttonLabels.add("Affirmative");        buttonLabels.add("Negative");         DialogFX dialog = new DialogFX(Type.QUESTION);        dialog.setTitleText("Question Dialog Box Example");        dialog.setMessage("This is an example of an QUESTION dialog box, created using DialogFX. This also demonstrates the automatic wrapping of text in DialogFX. Would you like to continue?");        dialog.addButtons(buttonLabels, 0, 1);        dialog.showDialog(); A couple of things to note You may have noticed in that last example the addButtons(buttonLabels, 0, 1) call. You can pass custom button labels in and designate the index of the default button (responding to the ENTER key) and the cancel button (for ESCAPE). Optional parameters, of course, but nice when you may want them. Also, the showDialog() method actually returns the index of the button pressed. Rather than create EventHandlers in the dialog that really have little to do with the dialog itself, you can respond to the user's choice within the calling object. Or not. Again, it's your choice.  :-) And finally, I've Javadoc'ed the code in the main places. Hopefully, this will make it easy to get up and running quickly and with a minimum of fuss. How Do I Get (Git?) It? To try out DialogFX, just point your browser here to the DialogFX GitHub repository and download away! Please take a look, try it out, and let me know what you think. All feedback welcome! All the best, Mark 

    Read the article

  • Speaking tomorrow @ JAX, Mainz, Germany

    - by terrencebarr
    Just a quick note: I’ll be speaking at the JAX conference in Mainz, Germany, tomorrow: “JavaFX 2: Java, RIA, Web, and more”, April 17, 18:00 The talk will be giving an overview of JavaFX 2.0, top features, demos, tools, and the roadmap of what’s in store for the technology in 2012 and beyond. Also, be sure to check out the other Oracle sessions: “Java everywhere – The Vision becomes true, again”, Dennis Leung, April 17, 9:00 “Die Oracle-Java-Plattformstrategie zeigt klare Konturen”, Wolfgang Weigend, April 18, 17:30 “Lambdas in Java 8: their Design and Implementation”, Maurizio Cimadamore, April 18, 17:30 “OpenJDK Build Workshop”, Frederik Öhrström, April 18, 20:45 “The Future of Java on Multi-Core, Lambdas, Spliterators and Methods“, Frederik Öhrström, April 19, 10:15 For a complete list of all sessions, see here. Cheers, – Terrence Filed under: Mobile & Embedded Tagged: JavaFX, JAX

    Read the article

  • NetBeans 7.1 RC1 now available - JavaFX 2, Enhanced Java Editor, Improved JavaEE, WebLogic 12 support

    - by arungupta
    NetBeans 7.1 RC1 is now available! What's new in NetBeans 7.1 ? Support for JavaFX 2 Full compile/debug/profile development cycle Many editor enhancements Deployment tools  Customized UI controls using CSS3 Enhanced Java editor Upgrade projects completely to JDK 7 Import statement organizer Rectangular block selection Getters/Setters included in refactoring Java EE  50+ CDI improvements RichFaces4 and ICEFaces2 component libraries EJB Timer creation wizard Code completion for table, column, and PU names CSS3, GUI Builder, Git, Maven3, and several other features listed at New and Noteworthy Download and give us your feedback using NetBeans Community Acceptance Testing by Dec 7th. Check out the latest tutorials. To me the best part was creating a Java EE 6 application, deploying on GlassFish, and then re-deploying the same application by changing the target to Oracle WebLogic Server 12c (internal build). And now see the same application deployed to both the servers: Don't miss the Oracle WebLogic Server 12c Launch Event on Dec 1. You can provide additional feedback about NetBeans on mailing lists and forums, file reports, and contact us via Twitter. The final release of NetBeans IDE 7.1 is planned for December.

    Read the article

  • How to get the FPS from a JavaFX scene?

    - by valmar
    I am currently writing a small graphical performance test benchmark for JavaFX. Thus, I need to get the current FPS at which the JavaFX scene is being refreshed. So far, I haven't found a solution how to accomplish this. Does anyone know if there is some kind of event that I could use in order to get the FPS?

    Read the article

  • Can you bundle a JavaFX jar as an OS X application?

    - by Ianprime0509
    I'm looking for a way to bundle JavaFX applications similarly to the way I can bundle Java applications using Jar Bundler? I really would like to have a custom icon for my program(and the ability to pin it to the Dock). Is there a way to do this now, or do I have to wait for JavaFX to mature in the Java market?

    Read the article

  • Is possible to make sexy GUI with javaFX & swing ?

    - by phmr
    I would like to do a "sexy" / user-friendly / appealing GUI in java. Swing is a limited in terms of "skin" customisation. I'm thinking about JavaFX but I don't it yet, what can I achieve with this technology ? how hard is it ? do you have examples of real-life examples of Swing/JavaFX integration ? I would like to do something in this spirit of this, which is built on the .NET framework: original link: http://www.patrickpayet.com/net/?p=329

    Read the article

  • How to display different value with ComboBoxTableCell?

    - by Philippe Jean
    I try to use ComboxBoxTableCell without success. The content of the cell display the right value for the attribute of an object. But when the combobox is displayed, all items are displayed with the toString object method and not the attribute. I tryed to override updateItem of ComboBoxTableCell or to provide a StringConverter but nothing works. Do you have some ideas to custom comboxbox list display in a table cell ? I put a short example below to see quickly the problem. Execute the app and click in the cell, you will see the combobox with toString value of the object. package javafx2; import javafx.application.Application; import javafx.beans.property.adapter.JavaBeanObjectPropertyBuilder; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Scene; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn.CellDataFeatures; import javafx.scene.control.TableView; import javafx.scene.control.cell.ComboBoxTableCell; import javafx.stage.Stage; import javafx.util.Callback; import javafx.util.StringConverter; public class ComboBoxTableCellTest extends Application { public class Product { private String name; public Product(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } } public class Command { private Integer quantite; private Product product; public Command(Product product, Integer quantite) { this.product = product; this.quantite = quantite; } public Integer getQuantite() { return quantite; } public void setQuantite(Integer quantite) { this.quantite = quantite; } public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; } } public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { Product p1 = new Product("Product 1"); Product p2 = new Product("Product 2"); final ObservableList<Product> products = FXCollections.observableArrayList(p1, p2); ObservableList<Command> commands = FXCollections.observableArrayList(new Command(p1, 20)); TableView<Command> tv = new TableView<Command>(); tv.setItems(commands); TableColumn<Command, Product> tc = new TableColumn<Command, Product>("Product"); tc.setMinWidth(140); tc.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Command,Product>, ObservableValue<Product>>() { @Override public ObservableValue<Product> call(CellDataFeatures<Command, Product> cdf) { try { JavaBeanObjectPropertyBuilder<Product> jbdpb = JavaBeanObjectPropertyBuilder.create(); jbdpb.bean(cdf.getValue()); jbdpb.name("product"); return (ObservableValue) jbdpb.build(); } catch (NoSuchMethodException e) { System.err.println(e.getMessage()); } return null; } }); final StringConverter<Product> converter = new StringConverter<ComboBoxTableCellTest.Product>() { @Override public String toString(Product p) { return p.getName(); } @Override public Product fromString(String s) { // TODO Auto-generated method stub return null; } }; tc.setCellFactory(new Callback<TableColumn<Command,Product>, TableCell<Command,Product>>() { @Override public TableCell<Command, Product> call(TableColumn<Command, Product> tc) { return new ComboBoxTableCell<Command, Product>(converter, products) { @Override public void updateItem(Product product, boolean empty) { super.updateItem(product, empty); if (product != null) { setText(product.getName()); } } }; } }); tv.getColumns().add(tc); tv.setEditable(true); Scene scene = new Scene(tv, 140, 200); stage.setScene(scene); stage.show(); } }

    Read the article

  • JavaFX, Google Maps, and NetBeans Platform

    - by Geertjan
    Thanks to a great new article by Rob Terpilowski, and other work and research he describes in that article, it's now trivial to introduce a map component to a NetBeans Platform application. Making use of the GMapsFX library, as described in Rob's article, which provides a JavaFX API for Google Maps, you can very quickly knock this application together. Click to enlarge the image. Here's all the code (from Rob's article): @TopComponent.Description( preferredID = "MapTopComponent", persistenceType = TopComponent.PERSISTENCE_ALWAYS ) @TopComponent.Registration(mode = "editor", openAtStartup = true) @ActionID(category = "Window", id = "org.map.MapTopComponent") @ActionReference(path = "Menu/Window" /*, position = 333 */) @TopComponent.OpenActionRegistration( displayName = "#CTL_MapWindowAction", preferredID = "MapTopComponent" ) @NbBundle.Messages({ "CTL_MapWindowAction=Map", "CTL_MapTopComponent=Map Window", "HINT_MapTopComponent=This is a Map window" }) public class MapWindow extends TopComponent implements MapComponentInitializedListener { protected GoogleMapView mapComponent; protected GoogleMap map; private static final double latitude = 52.3667; private static final double longitude = 4.9000; public MapWindow() { setName(Bundle.CTL_MapTopComponent()); setToolTipText(Bundle.HINT_MapTopComponent()); setLayout(new BorderLayout()); JFXPanel panel = new JFXPanel(); Platform.setImplicitExit(false); Platform.runLater(() -> { mapComponent = new GoogleMapView(); mapComponent.addMapInializedListener(this); BorderPane root = new BorderPane(mapComponent); Scene scene = new Scene(root); panel.setScene(scene); }); add(panel, BorderLayout.CENTER); } @Override public void mapInitialized() { //Once the map has been loaded by the Webview, initialize the map details. LatLong center = new LatLong(latitude, longitude); MapOptions options = new MapOptions(); options.center(center) .mapMarker(true) .zoom(9) .overviewMapControl(false) .panControl(false) .rotateControl(false) .scaleControl(false) .streetViewControl(false) .zoomControl(false) .mapType(MapTypeIdEnum.ROADMAP); map = mapComponent.createMap(options); //Add a couple of markers to the map. MarkerOptions markerOptions = new MarkerOptions(); LatLong markerLatLong = new LatLong(latitude, longitude); markerOptions.position(markerLatLong) .title("My new Marker") .animation(Animation.DROP) .visible(true); Marker myMarker = new Marker(markerOptions); MarkerOptions markerOptions2 = new MarkerOptions(); LatLong markerLatLong2 = new LatLong(latitude, longitude); markerOptions2.position(markerLatLong2) .title("My new Marker") .visible(true); Marker myMarker2 = new Marker(markerOptions2); map.addMarker(myMarker); map.addMarker(myMarker2); //Add an info window to the Map. InfoWindowOptions infoOptions = new InfoWindowOptions(); infoOptions.content("<h2>Center of the Universe</h2>") .position(center); InfoWindow window = new InfoWindow(infoOptions); window.open(map, myMarker); } } Awesome work Rob, will be useful for many developers out there.

    Read the article

  • Java Fx Data bind not working with File Read

    - by rjha94
    Hi I am using a very simple JavaFx client to upload files. I read the file in chunks of 1 MB (using Byte Buffer) and upload using multi part POST to a PHP script. I want to update the progress bar of my client to show progress after each chunk is uploaded. The calculations for upload progress look correct but the progress bar is not updated. I am using bind keyword. I am no JavaFx expert and I am hoping some one can point out my mistake. I am writing this client to fix the issues posted here (http://stackoverflow.com/questions/2447837/upload-1gb-files-using-chunking-in-php) /* * Main.fx * * Created on Mar 16, 2010, 1:58:32 PM */ package webgloo; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.geometry.VPos; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.LayoutInfo; import javafx.scene.text.Font; import javafx.scene.control.ProgressBar; import java.io.FileInputStream; /** * @author rajeev jha */ var totalBytes:Float = 1; var bytesWritten:Float = 0; var progressUpload:Float; var uploadURI = "http://www.test1.com/test/receiver.php"; var postMax = 1024000 ; function uploadFile(inputFile: java.io.File) { totalBytes = inputFile.length(); bytesWritten = 1; println("To-Upload - {totalBytes}"); var is = new FileInputStream(inputFile); var fc = is.getChannel(); //1 MB byte buffer var chunkCount = 0; var bb = java.nio.ByteBuffer.allocate(postMax); while(fc.read(bb) >= 0){ println("loop:start"); bb.flip(); var limit = bb.limit(); var bytes = GigaFileUploader.getBufferBytes(bb.array(), limit); var content = GigaFileUploader.createPostContent(inputFile.getName(), bytes); GigaFileUploader.upload(uploadURI, content); bytesWritten = bytesWritten + limit ; progressUpload = 1.0 * bytesWritten / totalBytes ; println("Progress is - {progressUpload}"); chunkCount++; bb.clear(); println("loop:end"); } } var label = Label { font: Font { size: 12 } text: bind "Uploaded - {bytesWritten * 100 / (totalBytes)}%" layoutInfo: LayoutInfo { vpos: VPos.CENTER maxWidth: 120 minWidth: 120 width: 120 height: 30 } } def jFileChooser = new javax.swing.JFileChooser(); jFileChooser.setApproveButtonText("Upload"); var button = Button { text: "Upload" layoutInfo: LayoutInfo { width: 100 height: 30 } action: function () { var outputFile = jFileChooser.showOpenDialog(null); if (outputFile == javax.swing.JFileChooser.APPROVE_OPTION) { uploadFile(jFileChooser.getSelectedFile()); } } } var hBox = HBox { spacing: 10 content: [label, button] } var progressBar = ProgressBar { progress: bind progressUpload layoutInfo: LayoutInfo { width: 240 height: 30 } } var vBox = VBox { spacing: 10 content: [hBox, progressBar] layoutX: 10 layoutY: 10 } Stage { title: "Upload File" width: 270 height: 120 scene: Scene { content: [vBox] } resizable: false }

    Read the article

  • Notes - Part I - Say Hello from Java

    - by Silviu Turuga
    Sometimes we need to take small notes to remember things, one way to do this is to use stick notes and have them all around our desktop. But what happening if you have a lot of notes and a small office? You'll need a piece of software that will sort things for you and also it will provide you a quick way to retrieve the notes when need. Did I mention that this will keep your desktop clean and also will reduce paper waste? During the next days we'll gonna create an application that will let you manage your notes, put them in different categories etc. I'll show you step by step what do you need to do and finally you'll have the application run on multiple systems, such as Mac, Windows, Linux, etc. The only pre-requisition for this lesson is to have JDK 7 with JavaFX installed and an IDE, preferably NetBeans. I'll call this application Notes…. Part I - Say Hello from Java  From NetBeans go to Files->New Project Chose JavaFX->JavaFX FXML Application Project Name: Notes FXML name: NotesUI Check Create Application Class and name it Main After this the project is created and you'll see the following structure As a best practice I advice you to have your code in your own package instead of the default one. right click on Source Packages and chose New->Java Package name it something like this: com.turuga.notes and click Next after the package is created, select all the 3 files from step #3 and drag them over the new package chose Refactor, as this will make sure all the references are correctly moved inside the new package now you should have the following structure if you'll try to run the project you'll get an error: Unable to find class: Main right click on project name Notes and click properties go to Run and you'll see Application Class set to Main, but because we have defined our own packages, this location has been change, so click on Browse and the correct one appear: com.turuga.notes.Main last modification before running the project is to right click on NotesUI.fxml and chose Edit (if you'll double click it will open in JavaFX Scene Builder) look around line 9 and change fx:controller="NotesUIController" to fx:controller="com.turuga.notes.NotesUIController" now you are ready to run it and you should see the following On the next lesson we'll continue to play with NetBeans and start working on the interface of our project

    Read the article

  • JavaFX Threading issue - GUI freezing while method call ran.

    - by David Meadows
    Hi everyone, I hoped someone might be able to help as I'm a little stumped. I have a javafx class which runs a user interface, which includes a button to read some text out loud. When you press it, it invokes a Java object which uses the FreeTTS java speech synth to read out loud a String, which all works fine. The problem is, when the speech is being read out, the program stops completely until its completed. I'm not an expert on threaded applications, but I understand that usually if I extend the Thread class, and provided my implementation of the speech synth code inside an overridden run method, when I call start on the class it "should" create a new Thread, and run this code there, allowing the main thread which has the JavaFX GUI on to continue as normal. Any idea why this isn't the case? Thanks a lot in advance!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >