This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Posts tagged: Swing

Full-Screen Mode for JVx applications

If you have a JVx application and want to use it without the frame border, it's not supported out-of-the-box. Sometimes it's very useful to have a full-screen application or to grab a screenshot without frame.

We now support this feature for Swing based applications but not in the official UI API. Here's a code snippet:

//F12 for toggling mode
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher()
{
      @Override
      public boolean dispatchKeyEvent(KeyEvent e)
      {
          if (e.getKeyCode() == KeyEvent.VK_F12)
          {
              if (ObjectCache.get("FULLSCREEN") == null)
              {
                  ObjectCache.put("FULLSCREEN", Boolean.TRUE, 500);
                 
                  SwingApplication app = (SwingApplication)getLauncher();
                  app.setFullScreen(!app.isFullScreen());
                 
                  return true;
              }
             
              return false;
          }
         
          return false;
      }
});

The trick with FULLSCREEN is necessary because the event fires sometimes more than once.

Simply press F12 key to toggle between Fullscreen/Frame mode.

eTV in Action

Some days ago, I wrote about our eTV project. The blog post had some pictures but no more details. I want to tell you some details about this project because it's simply awesome.

The project was a research project of our framework team and was started just for fun. The use-case was simple: Our room had 4 walls and 3 were full with pictures and world maps. Only one wall was empty. Why not using a flat TV for showing different content like livestreams, comic strips, images.

The idea was great and some days later, the last wall was full. A nice 43" flat TV was mounted.

We thought that a RaspberryPi could bring the content to the TV because it's a small device and fits behind the TV. Java works without problems on the Pi and JVx as well.

After all hardware pieces were ready, it was time to think about the software because a sort of control center was needed to implement some features. The plan was to write a simple server which has a set of commands like: open website, show image, play livestream, execute command, upload file, download file.

The server was implemented as simple socket server, with JVx. It executes pre-configured commands and has some important control features: take screenshot, next - previous window, get window list, close window. The server has no GUI and is more or less a window/process manager.

The server has no GUI, but we need a GUI to control the server. We wrote a simple JVx application as remote control. The remote control application was deployed on a Jetty application server (on the RasPi, with vaadin UI) and as mobile JavaFX application. Jetty runs fine on the RasPi and our vaadin UI as well.

The TV with RaspberryPi, streaming a Video from YouTube:

eTV YouTube Stream

eTV YouTube Stream

After we were ready with the server, we tried to create a simple JVx demo application to demonstrate JVx on embedded devices. It was funny to use eTV for live streams or to show images, but what about real-world use-cases?

The idea was about a JavaFX application, running on the RasPi. The application could be a monitoring app for a warehouse with a nice looking frontend and a backoffice view for administration. It's usual to have a nice looking frontend and a not so nice looking backoffice part.

We've implemented an application for a big assembly hall. The application is a styled JVx application but still 100% JVx. We've used VisionX to create the UI:

VisionX design mode

VisionX design mode

TV mode

TV mode

The application in VisionX is not 100% the same as on the TV because of the screen resolution, but it's the same source code and VisionX works with this application. The application on the TV hides the application frame and only shows the screen content, but this is a supported feature.

The UI technology is not JavaFX! We tried to use JavaFX but it wasn't possible because the RasPi had performance problems with the amount of nodes. It wasn't possible to reduce the amount of used nodes with standard JavaFX controls. Overclocking the Pi didn't solve the problem.

We simply switched to Swing and didn't have any performance problems. So, the UI technology is good old Swing. It works great in combination with the RasPi and we think the result is also nice!

The application is a monitoring application for different events, like performance, effort, pressure, temperature, aerodynamics, alerts. We did connect a temp sensor and two buzzers to get a better real-world experience and because it was easy to support with a RasPi. Initial setup:

Initial setup

Initial setup

The backoffice/backend was deployed as web application (Jetty on RaspberryPi, JVx vaadin UI) because it should be possible to use it on tablets or smartphones without native apps:

Backend view

Backend view

The same UI on mobile phones:

Mobile view

Mobile view

Mobile view (no menu)

Mobile view (no menu)

The application is a 100% JVx application with Swing UI and vaadin UI. Everything runs directly on the RaspberryPi.

We've used the whole eTV system as showcase application at DOAG conference in November:

eTV @ DOAG 2015

eTV @ DOAG 2015

The results of our "research project" are awesome and eTV is a ready-to-use product. We didn't code one line of code to support different UI technologies and didn't have problems with resolutions of tablets, smartphones or the TV (#responsive).

Thanks to JVx it was super easy to create an amazing application.

Oracle Forms with JavaFx and Swing

I'm sure that some of you have already used custom swing controls in Forms applications to enrich them. But have you tried to use JavaFx together with your Forms application?

JavaFx has cool effects, animations, controls, css styling and much more.

If you enter 'oracle forms javafx' or similar, in your favourite search engine, you get no specific results. So I think it is time to integrate JavaFx to an Oracle Forms application, isnt't it?

- It is a world premiere -


First, a screenshot:

Oracle Forms and JavaFx

Oracle Forms and JavaFx

We used the source code from the official example, that integrates JavaFx in a Swing application.

The result of our integration is a screen that contains Swing and JavaFx controls. If you change a value in the table, the chart is updated immediately. It is really cool because the chart has nice transition effects.

You can combine rapid application development with modern controls and new development concepts.

Swing RETRO application - MP3Tool - update

In the Swing RETRO application article, I wrote about my personal MP3Tool. When the tool was developed, the ID3v2 Tag was not very important and the cover image was not relevant. Now, every modern mp3 file has a cover or front or band image. The problem is that the "original" MP3Tool does not support images.

Because it is important for me, to change files with covers too, I decided to implement a simple image support. And during my research I found other features that are often used: Lyrics Tag and APE Tag. I have never heard about them. So I decided to implement at least delete support, for those Tags.

After some hours, the implementation was done. I was positive surprised about the source code quality, because the code is really old. It was amazing good.

The update version is available here and the version is now 2.2.

Cover images

The tool is not a SIB Visions Tool.

Swing RETRO application

During christmas break, I checked my (very) old personal Java applications. One of the first comments was from 2001. A long time ago. I had no UI framework, no testing framework and no automatic build process. All was hand-made :) I was amazed that I could read and edit the source code without problems.

One of my biggest and first applications, that I wrote for my personal use, was "MP3Tool". It is a tool to manage (very) large MP3 inventories, it has cool automations, supports offline edit/merge via XML, supports database loading and has command line support. It has support for ID3v1 and ID3v2. I have implemented my own library to read and write ID3 TAG infos (not complete, but works still great).

The tool is a "developer" tool that is not very user-friendly, but it is 11 years old and has tons of features. It was developed from a developer for a developer :) If someone needs a Java tool for mass editing of MP3 Files - here it is. It is not Open Source because it was not relevant in 2001. It is Free for everyone and if someone needs the source code it should not be a problem to upload it somewhere. :)

The tool has a German and English language file. I don't know if the auto detection works but you can change the language file in the settings, via Toolbar. I have not tried it on MacOS, but used it very often with Linux. If you search documentation - I have never used one!

I use the tool from time to time and still love it because it just works. After 11 years, I think it is ok to share it with you.

To be sure - The tool is not a SIB Visions Tool - It is a retro style swing application developed long time ago ;-)

mp3uebersicht_eingelesen

File overview

mp3optimierung_ergebnis_mehrfach

File optimization

mp3konvertierung_konvert

TAG conversion

JVx SwingUI extensions

JVx defines a technology independent User Interface, with Interfaces. Each technology has to implement this interfaces for its components and controls, to be compatible with JVx. We have implemented all this interfaces for Swing.

In addition we have created some swing components with special features for business applications. This components are simple extensions to existing swing components and are supported from any Look and Feel. They can be used in any swing application with or without the whole JVx framework.

We will show here some of this components:

  • DesktopPane with tab or frame mode

    Switch between tab and frame view, Closable tabs (works with java 1.5 and is LaF independent), Drag and Drop Tabs, Tab navigation with keyboard, Modal frames, Background image.

    Frames

    Frame mode

    Tab mode

    Tab mode

    Desktop Background

    Desktop Background

  • ComboBoxes with user-defined popup components

    A base implementation of a ComboBox called ComboBase. With this combo you can build your own ComboBox for e.g. input first and last name in separate fields. We implemented a date chooser and a table selector (header is:

    Date Combo

    Date Combo

    Table Combo

    Table Combo

  • Table with load-on-demand model and ready-to-use cell editors/renderers

    A table which uses an IDataBook implementation as model (e.g. MemDataBook) and shows cell editors and renderers dependent of the cell data types, e.g. a table with image renderer and multiple choice editor/renderer

    Table with renderer and editor

    Table with renderer and editor

    Following editors/renderer are available: Text, Number (only numbers are allowed), Date, Multiple Choice, Image
  • Button

    A standard button and a toggle button with support for mouse-over borders.

  • Icon

    A special icon which supports image stretching and alignment.


Our implementation includes not only Swing components. It also contains some useful layouts:

  • FormLayout

    Anchor based layouting. Supports margins, stretching, gaps, ... It is designed for simple and complex forms.

  • BorderLayout

    Supports margins.

  • SequenceLayout

    Supports component stretching, component orientation, intelligent wrapping.

If you are interested in JVx, leave a comment or join our community.
You are welcome!