Sunday, October 11, 2015

Playing with Hazelcast on Payara

I have been reading a bit about Hazelcast, came up to chapter 5 in http://hazelcast.org/mastering-hazelcast/, but as I am a bit impatient and wanted to try out some stuff before reading the whole book and thinking about possibilities to use Hazelcast in my current work, this Weekend I set up to solve the following:

  • Use Hazelcast IMap in a Java EE container
  • Use MapLoader to load into a IMap with JPA
  • As far as possible, use CDI
Payara comes with a Hazelcast, but solving this tasks may not be so straightforward, and I will try to explain why.

As usual I use a simple blog Post RESTful service as an example.



Using Hazlecast in Payara

Even if Payara comes with an embedded Hazelcast, I will not use it by letting Payara start it, and the reason is what I found when playing around with EntryListener. I will however use the Hazelcast that is provided, but will not activate it as written here: https://github.com/payara/Payara/wiki/Hazelcast-%28Payara-4.1.153%29 but more with ideas as written here: http://blog.modernjava.info/2014/10/using-hazelcast-as-jcache-provider-with.html.

To start with, this is what we will need in the pom.xml,

I am using Hazelcast 3.5 since that is the one that comes with Payara 4.153.

To fire up Hazelcast we will use an annotation and a provider so we can use CDI where we want to use stuff from Hazelcast.




The reason for doing like this is that I noticed by playing around with EntryListener that by letting Payara firing up Hazelcast I cannot really add listeners, since Hazelcast then know nothing about my classes (resulting in ClassNotFoundException), so to resolve this we need to provide the class loader from our web-application to Hazelcast. To do this we need to start it "manually" and provide the class loader so Hazelcast knows about them. You can also see we configure Hazelcast with a MapLoader, more on that later.

REST-resource

I will not share the full code since you can find it on Bitbucket. In PostResource we use CDI to get hold of the Hazelcast, it will initialise on first use, so if no pre-warming occurs (like using a startup bean) it will take 5-10 seconds.


And use it

For the creation of a Post we can use a trick to load it in the map by trying to get it after the save. That is we don't put it in the map directly and use a MapStore to save it (we don't know the id until after the persist). But since this is about using MapLoader, we will use that and not put it (as indicated in the comments)

MapLoader using JPA

Actually, I am not using it directly from the MapLoader, but injecting a @Statless bean from it, that does the actual JPA stuff.
As the MapLoader lives in Hazelcast and is created by it, we cannot use @Inject or even make it a managed bean (well we can, but it will not help since it is not using the jave ee container to handle it). But since CDI 1.1 we can inject using the CDI-class.

This is how the map loader I create looks like:

Notice the code to inject the PostRepository (which is the bean using JPA with an EntityManager). This will work since Hazelcast is loaded from the container with our classes.

Some notes

I have implemented loadAllKeys() and loadAll(...), this is probably fine since I do not have so many posts, but for a huge database and if you do not want them all in memory, you may leave them empty and return null for keys or you will end up waiting for a while. I played with a criteria search on the map


and found out that by doing that, Hazelcast will try to load all keys from the database before it searcher memory.
However, this is done only once, if you add items to the database, it will not get loaded if you do not do anything to tell the map, as you have seen in the "@POST" or put it there yourself, subsequent searches on the map will not try to load items not there from the first loadAll.

Payara does not really matter in the context, other than having a Hazelcast and being a Java EE container. But I also use it since it have a default datasource for Derby, so I kind of used that to avoid setting up a database, and load a few posts to get started.If you use another container, you may have to change the hazelnuts dependency to be "compile" instead of "provided" if that container donate have it. You may also need to set up a datasource.


The code can be found here: [https://bitbucket.org/pejomstd/hazelblog]


Tuesday, May 19, 2015

Payara Micro, even easier

Just saw this post. [http://java.dzone.com/articles/java-ee-embedded-and-micro]. It is not even nescessary to build a runner, using Payara Micro, it is as easy as this:


More here:http://www.payara.co.uk/introducing_payara_micro

RESTful Service on an embedded Glassfish/Payara


Last posts were about making a RESTFul service and run it on Jersey with an embedded Jetty.
This time I will set up a more Java EE like solution with the same REST Resource, but instead run it on an embedded Glassfish (actually, I will go for Payara). I will take the same model as before. Next part I will also add a JSF 2.2 client to use the RESTful service.

I will create this as a maven multi module with a parent project and two subprojects. One will be a web-project and the other will be a "runner" for the embedded Glassfish. I will not use maven to run, but will create a class that will run the embedded Glassfish with the war-file from the other project.

As it is pretty easy I use NetBeans to create maven projects for me.

The structure will be like this:

  • embgf
    • task-web
    • gf-runner
    • pack-dist

task-web

To start with, instead of having to set up a Servlet on "/api" path, we will create a configuration class that extends JAX_RSs Application.

And this will be the class for the Task service.


The service will be available at [http://localhost:2001/task-web/api/tasks] (depending what you use as port and contextRoot)
Just to have some Tasks to start with since we have a simple cache in a HashMap, we create a startup bean to create some.



gf-runner

Embedded Payara

Trying to follow [http://www.payara.co.uk/using_payara_embedded_and_payara_micro_with_mav] I ran in to some issues. The dependency on that page does not really work, it end up with the following message:


There is a bug-report on this. But to get on, I will download the jar and do a "quickie" and add it as a system dependency and get on.

The code to get up and running with the war-file from task-web on an embedded Payara is just a few lines:


pack-dist

As I am a bit lazy and want to avoid copy jars manually I created a pom-project just to copy dependencies. The needed jar file will end up in the root folders under ./dist/, I also added a bat file to start the embedded Payara with the following content:


I also tried the jersey-client from the previous post with s slight modification for the context-path and it still works. (or you can start the payara with "/" as context path)

In next part I will add a JSF client on top of this service to show some nice stuff in Java EE 7 and JSF 2.2.

[The full project can be found at: https://bitbucket.org/pejomstd/embedded-gf-payara]

Saturday, May 2, 2015

REST with Jersey and Jetty part 3

REST with Jersey and Jetty part 3

Adding JSON support.

The first two parts  in this small series of posts were about setting up the server and be able to run it with Jersey. [REST with Jersey and Jetty part 1, REST with Jersey and Jetty part 2].

This time there will be a bit more work. And I will take it step by step.

The service we will implement will handle tasks. To start with, there will only be one task list where all tasks will go.

The api will be the following.
Task class:


To start with we add support for getting the list, there will be some hardcoding until we have the working JSON support, since the first thing we want is a working Jersey with JSON support, not to complicate things further. When we have that, we can start adding functionality. But in the end, we will try to support:

  • list all
  • show a single task
  • create a task
  • update a task
  • remove a task
  • show range of tasks
  • get task count

But starting with some hardcoded stuff, to get the server running with JSON, this will be the stating point for the TaskResource


If you start the server and try to surf to this [http://localhost:2001/api/tasks] will yield the following in the log.


so we need to add some stuff to have JSON support.

Well, just a shor Googling, and it was pretty easy to add. [http://stackoverflow.com/questions/25474223/jersey-rest-messagebodywriter-not-found-for-media-type-application-jso] gives a hint. Just added moxy and it works to get JSON with the @GET.

So lets go for some real coding. We will add a simple cache, To avoid having a database for this simple example it will only contain a map with the tasks.

Lets start with some simple support of the cache:


Lets first add a method to create a task and one for getting a specific task.

To test this, we will need to also add a method to get a single task and a client to test it.

First, the client.


So far the client just adds a Task, gets the URI to the created Task and then gets it using the @GET for the methods added above.

Next step, fix the getAll().
The client cannot handle a List without wrapping it in a GenericType, but that is really all there is too it, we can still return List from the method.


The only thing we need to add now is update and delete. We will also add some code to test it in the client.

I also made some changes in the client:
Enjoy your Task microservice in REST using embedded Jetty with Jersey.

Read more about Jersey [https://jersey.java.net/documentation/latest/index.html]

Friday, May 1, 2015

REST with Jersey and Jetty part 2

REST with Jersey and Jetty part 2

Getting Jersey into play

In this part, we will introduce Jetty as serving with rest. We will att a class serving a @GET request.

We will need an extra dependency for Jersey to work, and after getting a strange error under startup I ended up changing the dependency on Jetty from the previous post [http://ironicprogrammer.blogspot.se/2015/04/rest-with-jersey-and-jetty-part-1.html]. I got the following error:


When adding the dependency for Jersey 2.17 after th Jetty dependency. Actually I got it to work by moving the Jetty dependency to after the Jersey dependency. But reading the log you can see that 2.17 if Jersey used Jetty 9.1.1 so, updating Jetty dependency to 9.1.1.v20140108, the order does not matter.
This is the dependencies for this part.



We will also create a new statup-class, It will not be much more code than the one in the previous part, but some extra stuff is needed to get Jersey into play.


The difference here is that we use a ServletHolder with some init parameters to set Jersey up. We also set the path to serve to "/api/*" instead of plain root "/".
That brings us to REST, we need something to show that it works. To do this we have a class under "rest" package called HelloResource.


So now the only thing you have to do is to start upp JerseyServer and surf into [http://localhost:2001/api/hello] and you should see the hello message. And there you have your first little Microservice ;)

In future post will explore how to use more than @GET and also how to add JSON support to this.


Thursday, April 30, 2015

REST with Jersey and Jetty part 1

REST with Jersey and Jetty part 1

Running Jersy standalone with a Servlet.

A few days ago I started to look into how to run a REST service with an embedded container. Now a friend of Springframework will say, that is easy with Spring, but after looking at a tutorial [http://spring.io/guides/tutorials/bookmarks/] I notice a couple of things. The annotations are not the standard JSR 331/339 ones, and there is a lot of other things from spring framework coming into play. Well, sorry Spring-guys, I don’t want that. I want to go with standard JSR annotations, and no specialities from Spring.

So my ide is to use Jersey which is the reference implementation och JSR 311/339 and run it on a server that can be embedded. What I want to do is to have the following support.

  • Ability to run with an embedded server (my choise: “jetty”)
  • Ability to serve REST calls (my choise: “Jersey”)
  • Ability to communicate wiht JSON. 
After some research I noticed that it is not easy to find any good resource on how to run Jersey with an embedded server. the bes I could find was [http://jlunaquiroga.blogspot.se/2014/01/restful-web-services-with-jetty-and.html] , but I don’t like blogs saying “you only need to include the jars necessary or use maven” but leaving out the information of which the necessary jars are or the specific maven dependencies needed.. the documentation over Jersey is scarce in examples.

I will start this “journey” by building it up step by step. In this part, I will do only what is necessary to start an embedded server.

I used the above blog as a starting point. First step I will show is how to run a servlet in an embedded Jetty.

The first thing to do is to have a dependency to Netty.



The server will be started in a class with a main method, 



There will also be a simple servlet to run in it.



Next post is about how to create a REST service based on Jersey and run it in Jetty.
(Update: changed the version of Jetty dependency, since I in next post use Jersey 2.17 and there was some issues running with Jetty 9.0.2)

Sunday, December 29, 2013

Why I plan to leave RichFaces

Having recently worked with upgrading RichFaces 3.3 to 4.3.1 I have come to the conlusion.... "It basically s*cks". I will give some reasons why:

  • Huge makeover of tags
  • Removal of tags
  • Changes in attibutes
  • Too many attributes.
Maybe RF was good when it came, because there was not so much else. But the makeover from 3 to 4 made an upgrade a real pain in the a**.

Googling help for RF in most cases gives result for 3.3.x solutions. I have found it hard to find any useful information about 4 or later. This makes an upgrade hard since it is not easy to find the proper information how things are done with 4.3.x, specially how to replace stuff that is removed from 3.3.x since there is not a decent upgrade guide to be found either. Maybe I have missed some place where all this is written, but weeks of Googling without finding anything is another problem, the documentation s*cks when there is not easy to find what you need.

Makeover of Tags

Some examples: 


Removal of tags

rich:modalPanel dissapeared. Well WHY? I think a lot of people used it, now all that code have to be totally rewritten.
rich:layoutPanel was removed. Well now I have found nothing obvious to replace it so back to postitioning by div and css.


Changes in attributes

Take rich:dataTable as an example: some attributes removed, some new, and also changes from camel-case to all lower case attributes but not all. WTF? do you really want someone to use the framework after an upgrade, do not change EVERYTHING. All event-attributes was changed to lowercase ("onRowClick" to "onrowclick"), but not things like "rowClass".

rich:panel: attribute "header"changed meaning from label to space-separated list of styles (???)

Too many attributes

a4j:commandButton: 32 attributes
a4j:commandLing: 37 attributes
rich:dataTable: 34 attributes

This is just a few examples, there is a lot of headache upgrading from 3.3.x to 4.3.x, not only on the surface, if you are using classes in your backing code, be aware, the package structure is also changed, classes have dissapeared and things just stop working. Changing the tags may look hard enough, but when new ones are in place you still probably have strange bugs that need fixing since things that worked before does not work any more.

If I would choose next upgrade, I would not choose RF 5, but go for PrimeFaces instead.

Wednesday, November 13, 2013

Designing a “modular” web application

Background

I would like to separate functionality for a web application into separate jar-modules and include these in a war project.
The purpose for this is to separate development and deployment, that is, to develop functionality separately and include it in the war-packaging and it should automatically be usable with templates, menues etc.
Sorry if the code don't display so well. But putting codes with Generics is not so well handled by Bloggers editor, so until I have time to fix it you will have to live with it ;) and I will use [] instead of <>


Structure

To make it modular it is nescessary to have some common code (placed in “common-web”). The structure for this is basically:

  • common-web: will contain code common to modules and web-applications.
    • templates: for reuse in different modules, basic templates is put in a common module.
    • login: (out of scope, will not implement login in this example) for reuse of login-form etc. i.e. the same files and functionality applies to all web-applications that uses login.
    • resources: common css and images is placed to be reused.
    • menu: functionality to assemble n menu(es) from m modules so they will present in web-applications no matter in what module a page is used.
    • common code: code for hoding and generating menu(es), common utility code for JSF, ManagedBeans etc.
  • war: web-project with war-packaging that will use modules.
  • webmoduleA..X: functional parts that implement a function or group af functions that logically belong together.
    • as an example I will implement at “todo-webmodule” in a PoC to show the functionality.


Menu

Basic functionality for menu is placed in common-web.

What am I trying to solve here?

A module can have different kind of needs, to access parts of its functionality we need a menu with 1 or more items (even if a module can be without menu, for example common-web may not need one, even if it is also a kind of a module).


Requirements:
  • A menu sholud be able to present itself as a top-menu in a menubar
  • A menu should be able to present itself as a part of another menu (i.e. not on toplevel) but in another menu.
  • Should be able to order children of a node.
  • Support to up to 4 levels of menues (more level will not be displayed)


Assumptions:
  • If a menu has no children it should have an action attached (=no expression needed)
  • If a menu has children, it has no action attatched to it.(=no expression needed)
  • Only SubMenus can be placed, not single menues (MenuItem). And they can only be placed in other SubMenus.



Placement:
“/” is root, putting menues under “/” would put them in top menubar.
Take as an example; you have 3 top menus (Admin, Project, Help). These should all be placed under “/”


Further, say we want to capture this endresult for menues.
  • /
    • admin
      • add user
      • list users
    • project
      • add project
      • list projects
      • issues
        • add issue
        • list issues
    • help
      • about


/admin
/admin/add user
/admin/list users
/project
/project/add project
/project/list projects
/project/issues
/help
/help/about

We have Issues under its own grouping and this should be inserted under project. (The reason behind this is that it may be developed in another module and we want to insert it under project in this application)

Ordering

When it comes to ordering, I want to speify an order on all levels. The purpose of this is that when adding top menues dynamically I do not know which order they will appear, hence it is usefull to be able to define it on top-level.
Another purpose is, that since it is possible to insert a menu into another, this may disturb the order or we want the inserted menu group to in another position than it gets inserted to.

This solution for this is to sort all items alphabetically and then resort according to supplied ordering (which is allowed to just use the ones it wants to sort in from start)

Solution

Model



Description


I will describe the solution by taking my example project on bitbucket as an example.
The example project (on bitbucket) have the following structure:


In this example the only “working” code for a MenuGroup that I will implement is the TODO-functionality, and of course the supporting code to have it modular. As goes for the concept of menus I will add a couple of MenuGroups undermodule-web itself. (Do not be surprised if the code here differs from the one on bitbucket, because there may be improvements done in the real code.). There is also mockup code to add the menues as described above to get more than one menu.


To have a menu for “Todo”, the following code will give me that as a “MenuGroup”





To have it modular and generate modules, this is done by having the menu.xhtml and supporting classes in common-web. The most important are MenuBean (that assemble the menu for the view), MenuAssembler (that assembles a menu for MenuBean from the groups it is provided)


To get menu groups aswell as config of orderings and placement from other modules, a bit of CDI is used.




Since we do not know which MenuGroups will exist when developing common code, we inject any type in an Instance. The view will call getMenus() tha if empty will try to assemble the menu. The placement and ordering should be provided from outside aswell, not hardcoded as in this case.


The order we do this is:

  1. add MenuGroups
  2. add rules
    1. placement and/or ordering (defined in a WebMenuConfig implementation)
  3. call assemble()


The last call will assemble the menu and return a list of the top menus. These menus will after returning be rendered in the view.


The implementation of the WebMenuConfig in this case is defined like this:




This will give a menu that looks like:









Thursday, July 12, 2012

"plz give codez..."

or "How to try to get the work done by posting questions"

Hold your hat because this may have some ironic content.

Well this post is going to be mostly about discussions in groups on LinkedIn. And specifically about questions asked in the groups. It seams to be a tendency for freshers from certain countries to try to get the work done by asking help from others. Seriously, LinkedIn is a professional networks site, but that does not mean that the professionals there are suppose to do your work for you.

It is almost amazing to see that some does not have the capability to think just 2 seconds before posting a question or the capability to search either the group in hand or to use a search engine (like Google!) to try to find an answer.

Well lets narrow down to Java because that is my field at the moment. Lets be honest. Getting to know the basics for Java, it is not hard to find resources online. For crying out loud, I think Oracle's (Sun's) documentation  and tutorial online is far better then what can be found for C# (Not that I looked recently). Despite of this, groups on LinkedIn is filled with basic questions, why?

Some examples:
Give me codez (or I do not know anything, but please do the job for me):
"Hi All, I want to learn Collection framework. Will you please tell me the sources where I can get the "Easy to Understand" and "With Examples" and "Real Time Scenarios" ? Need Your Help !!! "
Well, the short answer is, "Google it!!!". To search for this will give more answers than someone is willing to spend time explaining in a group discussion. To answer this I would probably Google for the sources as I do not bookmark these kind of things. I will not give you examples. And certainly to give real time scenarios will make me write a lot, which I am not willing to do for the effort put in in asking the question.
How can we create array of vector or array of arrayList,please reply
Actually a student. But come on, aren't LinkedIn a network site for professionals. Should a question really be a question where the obvious answer is, "See the API documentation" or "We are not doing your homework here!".

Another one:
i am a java fresher...can u suggest how the interfaces given to developers to program...? if possible give some real time examples.....@thanks in advance
How should I give you an example of how this is done? Should I make a movie out of how to check in into SVN created interfaces and show how a newbie check it out and start working?

Here is a different one, but requesting the docs instead of code:
can anyone explain me ,what id maven?also provide me docs.thanks in advance
Or some links and docs:

Please send me best javafx links and pdf. Thanks in advance.
Some Basic Java and API questions:
What is the difference between String Buffer and String Builder?

Abstract classes and interfaces

What is synchronize keyword? Why we use synchronize keyword in java?

what is system , out and println in system.out.println()?and how it works?

What is the difference between HashTable and HashMap?
Ok, here it is:
Java™ Platform, Standard Edition 6 API Specification,
Trail: Learning the Java Language

Language difficulties (or do you think you are in a chat for kids?):

Proper English seam to be some kind of standard. Look at this reply in a thread about an exception in Struts-1
hello "---" wt prob in struts2 ur nw in struts2 ok no problem wt u use eclipse or net bean i hav nt much knowledge in struts1 bu i m working in struts2

plz frnds, tell me.....
Again, in a networking site for professionals, should you really write in a way that teenagers do in a chat?

About interviews:
Hello, In an interview i faced the question "What is your project architecture?"can u plz help me the correct answer
Well, maybe if you do not know what you have done the last couple of years, maybe you should not have that job. One thing that I can tell you is that I have no clue how you worked during those two years.


And people posting jobs under discussion? I do not even want to go there...

Tuesday, January 31, 2012

My experience with Binero 2.0 (so far...)

Well, for those who do not know, Binero is a Swedish Webhotel, which I use for a small site, and also administer another.

They brag about being "Best in Test" and having an awesome support all days a week through phone and email.

Well according to me, if they are best in test, how bad are the other ones? If the support are awesome, why is it impossible to reach them by phone, (if you do not want to be in a phone queue listening to some stupid 80's computer game melody forever)? And why does it take a full day to get an answer on a mail you send?

OneClick

They also lifts out their "OneClick" solution as you avoid sitting with long installations. However, it does not really work. And then you have to wait to get an answer from the support that does not really help.

In my example, I wanted to migrate my small site to 2.0 to be able to test Umbraco for the other site. Well to not think of the headache to migrate, which I will describe later, when finally migrated I tried to install it. Well did it work?

Not really. Trying to install Umbraco on the Windows platform, you have to choose domain and then application to install. Guess what! The only thing I can do, is to read the message that the chosen platform does not support this. Well, creating a subdomain for Linux instead, Umbraco is not an option anymore.

What does the support say, that I have to create the subdomain on Linux!

Ok, I did not actually write that it was Umbraco I was trying to install and since that should be on Windows. But after replying to the mail 21 hours ago, I still have not got any answer to why this does not work.

Migrating

Ok, back to the migration, which is a story it self.

I started it early myself, since this is an option. then it says, migration will start 24th at 10:49, then nothing happens, this is what I see when I log in. Then I sent a mail about this, and what I wrote and when I can not tell, because of later problems. Anyway, the support took their time to answer, like 6-8 hours. (Because calling is not an option "There is many calling right now....").

Reply was something like "We are sorry about this, but we can not give any estimations of how long it will take, but no longer then the end of next week"...

What!, can it take more than one week to move a -NET site with not that many pages? After a long time, at friday, I get a message that a technician will reply to me with a better answer. He did, monday, with the short note that it was stuck in a state that did not tell them it did not work.

Then the actual migration. For the site there was no problems actually. There was just ONE inconvenience. My mail address disappeared. I wrote the support about it (from another address), No reply at all, then I wrote after 6 hours, that this is bad, and maybe I should blog about it....Well when I got home, there was an account again. But all my old mails were missing, and still are. And Binero is all quiet, no reply at all on the task.

The ironi in this is that they are trying to take the customers from another webhotel, that had mail problems a while ago.

On top of it, in the migration an invoice that was already paid was copied as not paid to the new account.

Wednesday, October 19, 2011

Scala Stock Charts - part 6 some GUI things

I got a bit caught up in all the programming and finished up a few diagrams, then some refactoring and was able to remove a couple of hundred lines of code. The program now looks like this:


As you can see a lot have happened since the last pictures of the application. So here is some things.

Main part

The applications is build up around a main frame that contains the bar chart and some overlays. As you can see there is also some text fields and buttons. The upper part is to search stocks/indexes and also handle the overlays in the bar char. These fields and buttons are:

  • Search field to enter a search criteria to filter the instruments to search for.
  • Search button, to apply the search
  • A combo box, to show the filtered search result, and also choose the stock to view. This combo box listen to changes and updates the bar chart with the selected stock
  • Next there is a box to limit the range of the data. I have not introduced recalculation for splits and emissions so to have a possibility to handle to not show before these events, I added a box to filter away prices before this date part.
  • Next there is the intervals for the moving averages in the chart, default they are set to 5,20,50 but can be changed but have as most 3 different, but also as few as one. Default they are Simple Moving Average (SMA),
  • to change to Exponential Moving Average (EMA) there is a checkbox
  • to update changed settings for Moving averages there is a button "Update averages"
  • finally on the top there is a check box to switch on/off viewing of "Bollinger Bands"
In the bottom part there is buttons for additional chart types. these are the ones I picked as most interesting for me and they show some different aspect of the prices.
  • Stocastics (show how a stocks price is doing in relation to past movements)
  • RSI (shows how strong a stock is moving in the current direction)
  • Aroon (shows if a stock is trending or oscillating)
  • MACD (and also MACD-histogram) (a momentum oscillator)

As I mentioned the main part is a Bar chart diagram. It contains some overlays like volume, moving average and optional Bollinger bands. These help to get a basic overview of a stocks movement and trend. It is made up of a specialized panel for the bar chart to handle the drawing of the chart.

The main application implements a method named top that is used in wrapped Swing features used in Scala. I have an object representing my starting point of the application, the first lines looks like:
As you can see I provide a title and also here is the search field where to put a search string. The most important thing to note here is the inheritance of SimpleSwingApplication which makes this object a Swing application

The next part looks like this
Here you can see some on the fly declaration and reactions to events on the components.  The following code shows how to add these to the contents of other panels. you can also see the creation at the click of the button, creation of a generic diagram for "stochastics" mixed in with a DrawListener to make it drawable. Also how the series of stochastics is added to a generic diagram can be seen here.
This last part of the code adds the actual panels containing the fields, bar chart and buttons to the Swing application.

Additional panels

To add some extra check to the main part there is some diagrams that first was their own specialized panel, but after some refactoring they now all except MACD uses a generalized panel called GenericDiagram and here is a part of that code:

And here is addition of some of the buttons into menu panel (top panel) followed by some example of the bottom panel with addition of button and reactions to its event. You see here that here is where the panel frame is set up inside the reaction to show the GenericDiagram with "stochastic" data.
Not so much to mention really except that as you see I extend with a trait with basic chart properties. this is intended to have common properties for this and other diagrams. The var's is to be able to add series and date series to the diagram. So this panel is only responsible to draw the things that are sent to it.

Ability to draw

No bar chart is complete if it is not possible to draw some help lines. This is managed by adding a trait for this, that can be mixed in wherever I want it. The code for that trais is:
An example of this functionality is to draw help lines in a MACD diagram. (or any really)
This can be mixed in like in this case:
And then it is possible to draw on that panel.