The Standard Widget Toolkit (SWT) is a graphical widget toolkit for use with the Java platform. It was originally developed by Stephen Northover at IBM and is now maintained by the Eclipse Foundation in tandem with the Eclipse IDE. It is an alternative to the Abstract Window Toolkit (AWT) and Swing Java GUI toolkits provided by Oracle as part of the Java Platform.
We have created a basic sample to show how you can work with AnyChart in an SWT application.
Contents and Launching
The sample file (click to download) contains the ‘src’ folder with the source code and the ‘jar’ file. You can run the file using the java -jar <jar_file_name> command.
In Mac OS X you can launch the sample like this:
java -XstartOnFirstThread -jar anychart-java-example.jar
In Windows you can do that like this:
java -jar anychart-java-example.jar
This sample shows a basic chart with five points. It listens for the chart draw and point hover events, and logs them into the textArea on the page; anychart.min.js is loaded from AnyChart CDN.
The ‘Add Random Point’ button keeps adding random points until the total point count is 20 and after then removes one point before adding a new one.
Source code is rather simple and self-descriptive, and there are only two things you should look at:
The static String myScript variable defines what script is executed when button is clicked;
The static String createHTML() method generates HTML and puts it into the browser window.
AnyChart and Java Standard Widget Toolkit (SWT) Sample: anychart-java-swt-example.zip
AnyChart Download: https://www.anychart.com/download/
AnyChart Documentation: https://docs.anychart.com/
AnyChart API: https://api.anychart.com/
Later we will extend the sample, add more features, and show how to achieve more with AnyChart in Java environment. We also have a number of other samples coming up.
Hello, when could i see more anychart demo with swt.
Hello. Thanks for your interest in AnyChart. It is hard to say when exactly, but we will look into this and see what we can do.