Chat with us, powered by LiveChat

AnyChart and Java Standard Widget Toolkit (SWT)

September 15th, 2015 by Timothy Loginov

Overview

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

Description

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.

Summary

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/
AnyChart Overview: AnyChart Web Charts JavaScript Framework

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.

If you created anything with AnyChart in Java applications and are ready to share – please drop us a line in comments, on Facebook, Twitter, or via email (support@anychart.com).


Comments (3)

*

屁瑞瑞    31st Jan 18 8:24 am

Hello, when could i see more anychart demo with swt.

  1. Reply
  2. Link
AnyChart Team    2nd Feb 18 5:40 pm

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.

  1. Reply
  2. Link