Category Archives: Project

The projects category is for descriptions about current projects.

Why would you want Java FX?

Why would you want Java FX?

Introduction

The reasons why you should switch to JavaFX are many. Here are just a few:

  • The GUI has a much more fresh and modern look compared to Swing or AWT. (To me it looks more to MacOS Aqua).
  • Lightweight and hardware accelerated.
  • Easier and faster to develop thanks to Oracle Theme Builder.
  • CSS Support (Desktop and Web).
  • Ready to use GUI Widgets (like the calendar).
  • Accurate and fast positioning of Desktop (and web) widgets.
  • 3D support.
  • Supports a native XML format named FXML. It’s somewhat similar to HTML, Which makes it easy for we developers to work with.

References

 

JavaFX, the new platform for creating and delivering desktop applications

Introduction

JavaFX is a software platform for creating and delivering desktop applications, as well as rich Internet applications (RIAs) that can run across a wide variety of devices. JavaFX is intended to replace Swing as the standard GUI library for Java SE, but both will be included for the foreseeable future. JavaFX has support for desktop computers and web browsers on Microsoft Windows, Linux, and macOS.

JavaFX
JavaFX

Similar to Eclipse SWT, It’s written for the Desktop and replaces Swing and AWT. Next to the Desktop, JavaFX can also be used to be used with Webbrows.

The code below shows how a Window named ‘HelloWorld’ with a button ‘HelloWorld’ named  is created. When the button is clicked, the console prints Hello World.

package javafxtuts;
 
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class JavaFxTuts extends Application {
    public JavaFxTuts()
    {
        //Optional constructor
    }
    @Override
    public void init()
    {
         //By default this does nothing, but it
         //can carry out code to set up your
         //app.
         //It runs once before the start
         //method and after the constructor.
    }
    
    @Override
    public void start(Stage primaryStage) {
        // Create the Java button
        final Button button = new Button();
        // Setting text to button
        button.setText("Hello World");
        // Registering a handler for button
        button.setOnAction((ActionEvent event) -> {
            // Printing Hello World! to the
            // console
            System.out.println("Hello World!");
        });
        // Please note that this Synax is a
        // Lambda Expression 
        // Initializing the StackPane class
        final StackPane root = new StackPane();
        // Adding all the nodes to the StackPane
        root.getChildren().add(button);
        // Creating a scene object
        final Scene scene = new Scene(root, 300,
         250);
        // Adding the title to the window
        // (primaryStage)
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        // Show the window(primaryStage)
        primaryStage.show();
    }
    @Override
    public void stop()
    {
        //By default this does nothing
        //It runs if the user clicks the 
        //go-away button
        //closing the window or if 
        //Platform.exit() is called.
        //Use Platform.exit() instead of
        //System.exit(0).
        //This is where you should offer to save
        //any unsavedstuff that the user 
        //may have generated.
    }
 
    /**
     * Main function that opens the "Hello
     * World!" window
     * Note that Main starts the execution of the
     * Application, just as in any regular 
     * Java Application.
     * @param args the command line arguments
     */
        public static void main(final String[] 
        arguments) {
    // The actual start takes place with the
    //  launch(arguments);
    //  launch(arguments); Command:
        launch(arguments);
    }
}
References and Tutorials

There exist many on the web:

Technical Writing

I have some Technical writing skills. You can check it out by reading the articles on this site plus the comments from readers. Furthermore I’m experienced in the following niches:

  • Technical Documentation.
  • User Documentation. (Help Files in ,chm, HTML , XML, ePub, Wiki, markdown, postscript and PDF).
  • UML and Design Patterns.
  • Visio, AutoCAD and OmniGraffle technical drawings.
How I can help.
  • Writing your project documentation, Technical Design, Proposals and Solutions Ducuments (High Level and Detailed).
  • Writing Technical Designs and Developer Documents.
  • Setting up, hosting and publishing DocuWiki or MoinMoin Wiki in a VPN. Free for you and your employees to use.
Pricing

I will make a free proposal with fixed price in advance.

The Eclipse Rich Client Platform (RCP)

Introduction

In previous articles I talked about the Standard Widget Toolkit (SWT). There’s more. It’s all part of a bigger plan. The Rich Client Platform (RCP).

To understand the Rich Client we first need to know the normal client. For the RCP Developers the normal client is a Webbrowser. Although Webbrowers have evolved significantly the latest years (AJAX, JavaScript Libraries and performance), a Browser is still a Browser. We can use them to view webpages.

Although the Rich Client can do this too. It’s much more an Application which can run standalone or by using Servers. In this case, the Rich Client is hosted as a Web Application. To get an idea of what’s currently available, visit the Eclipse Rich Client Marketplace. It currently has 1654 Rich Clients and new ones are arriving daily. Most of them are developed using a variant of SWT. The Eclipse Project which is most involved with RCP is the e4 Project.

Apache Axis, real time remote SOAP API’s

Introduction

I wrote about SOA elsewhere in this site. It’s Service Oriented Architecture based on well described services which can be accessed trough the http protocol. This is essential to prevent routers which block all kinds of ports not to prevent our Service Oriented Architecture.

Apache Axis

Axis is yet another fine Apache project which enables us to make services available in a truely amazing easy way! Apache Axis is above all very easy to use since it’s built in in most IDE’s. Eclipse is one of them and creating a Service with Eclipse is really a piece of cake. It’s really as easy as right-clicking a JavaBean and selecting “Generate Web Application”. Eclipse will then take over and go ahead generating the service. Next to the Service it will also generate:

  • A WSDL file.
  • A (JSP based client) to test your service.
  • API Documentation (for the Consumers of your Service).
Creating a Client

In Eclipse this is even more easy. Right click the WSDL and select “Generate Web-Service Client. Eclipse goes to work and produces a skeleton of Java Classes and interfaces which you need to get the client working!

What type of Programs are worth generating services for?

It depends. Do you want to do SOA? Then your service should be as elementary as possible. (Atomic). A generic service could be anything, Database lookups, Conversions and more functions which can be useful for public users.

 

What are JavaBeans?

ejwagenaar.com logo

What are JavaBeans?

According to Wikipedia:

JavaBeans are classes that encapsulate many objects into a single object (the bean). They are serializable, have a zero-argument constructor, and allow access to properties using getter and setter methods. The name “Bean” was given to encompass this standard, which aims to create reusable software components for Java.

According to Evert:

A JavaBean is a normal class with a few properties:

  • Javabeans have a zero argument Constructor. They cannot be instantiated with Data. The data is always added after the instantiation.
  • JavaBeans implement the Serializable interface which make them serializable.
  • All class-members are private.
  • To access data inside the class you need to create so-called ‘Accessor methods’ these are the getters and setters. You can only change the values of the class members by calling setProperty(). The same thing is true to get read the private class-members. This is done by the getters. getProperty().
  • Accessor Methods have a naming convention as follows: Lowecas get or set, followed by the property name (capitalized) so if the bean has a property called id, it’s accessor-methods become getId() and setId().
  • JavaBeans can be serialized.
  • Javabeans know things about theirselves. This is called Introspection.
So what are they used for?

JavaBeans are typically used as data-carriers, for example a JavaBean can be used to represent a Database Table Row, which makes sense in a DAO (Data Access  Object). This is indeed one of the most common applications of JavaBeans.

Utilities
Example of Introspection.

As I already mentioned, JavaBeans can look inside themselves, for example to get the class name:

// Get the fully-qualified name of a class
Class cls = java.lang.String.class;
String name = cls.getName();        // java.lang.String

// Get the fully-qualified name of a inner class
cls = java.util.Map.Entry.class;
name = cls.getName();               // java.util.Map$Entry

// Get the unqualified name of a class
cls = java.util.Map.Entry.class;
name = cls.getName();
if (name.lastIndexOf('.') > 0) {
    name = name.substring(name.lastIndexOf('.')+1);  // Map$Entry
}
// The $ can be converted to a .
name = name.replace('$', '.');      // Map.Entry


// Get the name of a primitive type
name = int.class.getName();         // int

// Get the name of an array
name = boolean[].class.getName();   // [Z
name = byte[].class.getName();      // [B
name = char[].class.getName();      // [C
name = short[].class.getName();     // [S
name = int[].class.getName();       // [I
name = long[].class.getName();      // [J
name = float[].class.getName();     // [F
name = double[].class.getName();    // [D
name = String[].class.getName();    // [Ljava.lang.String;
name = int[][].class.getName();     // [[I

// Get the name of void
cls = Void.TYPE;
name = cls.getName();               // void

A more complex example of Introspection can be found here.

The java.net.URL

ejwagenaar.com logo

 

Introduction

Above everything the Java Programming language was designed to

be a Networking Language by Sun Microsystems early nineties Sun’s slogan was “The Network is the Computer”.

Actually John Gage wasn’t completely right. Although it has become true for some systems   Computers are still the Computer, weather they are smartphones, smart watches, PC’s, Macs, iPads, Android tablets or Virtual Machines are still the real computers. Although they have become more and more connected and serve the API’s which  are accessed trough the networks.

Public API’s are becoming more and more available and are used as services which indeed make the Network. The coming of SOA slowly is making things better.

Time to see how you can connect to a (web) service using the java.net API.

Opening and reading from a url

In java.net the Opbject which represents an url is the URL object. You can instantiate it as follows:

URL url = new URL("http://www.ejwagenaar.com");

The next step is to open a connection:

HTTPUrlConnection con = url.openConnection();

Now we are ready to read from the connection. This is similar to reading from a file:

 

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine())
          != null) 
          System.out.println(inputLine);
        in.close();
    }
}

This prints the html of my homepage to the console. If you want to write it to disk, follow the instructions on writing to a file.

As you can see, the methods for java.io are consistent everywhere, which makes the Java programming language easy to learn.

i/o streams should always be closed!!!

Conclusion

This article demonstrates how to make a http connection and read a full HTML page from an HTTP connection using only plain Java objects. In another article we will post something to the http server.

 

Windows 10 Pro Activation keys

Windows 10 Pro Activation Keys

I found these on the web when dowloading Win 10 Pro.

  • Windows 10 Pro: W269N-WFGWX-YVC9B-4J6C9-T83GX
  • Windows 10 Education: NW6C2-QMPVW-D7KKK-3GKT6-VCFB2
  • Windows 10 Enterprise: NPPR9-FWDCX-D2C8J-H872K-2YT43
Windows 10 Edition Product Key
Windows 10 Home TX9XD-98N7V-6WMQ6-BX7FG-H8Q99
Windows 10 Home Single Language 7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH
Windows 10 Home Country Specific (CN) PVMJN-6DFY6-9CCP6-7BKTT-D3WVR
Windows 10 Home N 3KHY7-WNT83-DGQKR-F7HPR-844BM
Windows 10 Professional W269N-WFGWX-YVC9B-4J6C9-T83GXVK7JG-NPHTM-C97JM-9MPGT-3V66T8N67H-M3CY9-QT7C4-2TR7M-TXYCV
Windows 10 Professional N MH37W-N47XK-V7XM9-C7227-GCQG92B87N-8KFHP-DKV6R-Y2C8J-PKCKT
Windows 10 Enterprise NPPR9-FWDCX-D2C8J-H872K-2YT43XGVPP-NMH47-7TTHJ-W3FW7-8HV2CCKFK9-QNGF2-D34FM-99QX3-8XC4K
Windows 10 Enterprise N DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4WGGHN-J84D6-QYCPR-T7PJ7-X766F
Windows 10 Enterprise S FWN7H-PF93Q-4GGP8-M8RF3-MDWWW
Windows 10 Education NW6C2-QMPVW-D7KKK-3GKT6-VCFB2YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY
Windows 10 Education N 2WH4N-8QGBV-H22JP-CT43Q-MDWWJ84NGF-MHBT6-FXBX8-QWJK7-DRR8H
Windows 10 Enterprise 2015 LTSB WNMTR-4C88C-JK8YV-HQ7T2-76DF9
Windows 10 Enterprise 2015 LTSB N 2F77B-TNFGY-69QQF-B8YKP-D69TJ
Windows 10 Core KTNPV-KTRK4-3RRR8-39X6W-W44T3
Windows 10 Core Single Language BT79Q-G7N6G-PGBYW-4YWX6-6F4BTJPYNJ-XTFCR-372YJ-YJJ4Q-G83YBJPYNH-XTFCR-372YJ-YJJ3Q-G83YBR3BYW-CBNWT-F3JTP-FM942-BTDXY (CN)
ESD ISO 6P99N-YF42M-TPGBG-9VMJP-YKHCF

Useful Java Snippets (4)

ejwagenaar.com logo

Hello all of you Java geeks!

Welcome back to a new episode of this historical java snippet series! In this episode we will continue having fun with the java.util package.

Beyond Collections

This far we sticked with Collections and Arrays but there’s more. The Date and Calendars for example are all part of the same family, just like the Tokenizer, Event notifiers, Randomizer, Localizers and more. Enough to write about! .

Locales

Locales identify a specific language and geographic region. Locale-sensitive objects use java.util.Locale objects to customize how they present and format data to the user. Locales affect user interface language, case mapping, collation (sorting), date and time formats, and number and currency formats. It’s a good practice to use Locales in your Java Apps since they make it possible to publish your Apps for more countries and languages.

1. Listing all available locales

Locale[] locales = Locale.getAvailableLocales();

for (int i=0; i<locales.length; i++) {
// Get the 2-letter language code
String language = locales[i].getLanguage();

// Get the 2-letter country code; may be equal to ""
String country = locales[i].getCountry();

// Get localized name suitable for display to the user
String locName = locales[i].getDisplayName();
}
  1. A sample of output using a default locale of Locale.ENGLISH:
Language Code, Country Code, Localized Name
ar, AE, Arabic (Arab Emirates)
ar, BH, Arabic (Bahrain)
ar, DZ, Arabic (Algeria)
ar, EG, Arabic (Egypt)
ar, IQ, Arabic (Iraq)
ar, JO, Arabic (Jordan)
ar, KW, Arabic (Kuwait)
ar, LB, Arabic (Lebanon)

  1. Locale.FRENCH:
Language Code, Country Code, Localized Name
ar, , arabe
ar, AE, arabe (Emirats Arabes Unis)
ar, EG, arabe (Egypte)
ar, IQ, arabe (Irak)
ar, JO, arabe (Jordanie)
ar, KW, arabe (Koweit)
ar, LB, arabe (Liban)

Events

An event in Java is an object that is created when something changes within a graphical user interface. … If a user clicks on the JButton, a button click event is triggered, the event will be created, A new custom event must extends EventObject. Moreover, an event listener interface must be declared to allow objects to receive the new custom event. All listeners must extend from EventListener.
This example demonstrates all the steps necessary to create a new custom event.

  1. Declare an event:
// Declare the event. It must extend EventObject.
public class MyEvent extends EventObject {
  public MyEvent(Object source) {
  super(source);
  }
 }

// Declare the listener class. It must extend
   EventListener.
// A class must implement this interface to get
   MyEvents.
   public interface MyEventListener extends
   EventListener {
   public void myEventOccurred(MyEvent evt);
  }

  // Add the event registration and notification
     code to a class.
   public class MyClass {
   // Create the listener list
  protected javax.swing.event.EventListenerList listenerList =
new javax.swing.event.EventListenerList();

// This methods allows classes to register for MyEvents
public void addMyEventListener(MyEventListener listener) {
listenerList.add(MyEventListener.class, listener);
}

// This methods allows classes to unregister for MyEvents
public void removeMyEventListener(MyEventListener listener) {
listenerList.remove(MyEventListener.class, listener);
}

// This private class is used to fire MyEvents
    void fireMyEvent(MyEvent evt) {
     Object[] listeners =
     listenerList.getListenerList();
    // Each listener occupies two elements - the 
       first is the listener class
   // and the second is the listener instance
   for (int i=0; i<listeners.length; i+=2) {
    if (listeners[i]==MyEventListener.class) {
      ((MyEventListener)listeners[i+1])
        .myEventOccurred(evt);
    }
  }
 }
}