Prev
14. Unit testing
Next
16. Android Application

15. exercise: GUI Application

  1. Review presentation Java Graphical Frameworks

      

  2. Install WindowBuilder plugin for eclipse.
  3. Investigate jtm.activity15 package
  4. Implement class ColorSlider to make color sliders changing test area background color
  5. Export ColorSlider class as executable jar file. In Eclipse, do following:
    1. Right click on ColoSlider.java file in Package explorer, and select Export...
    2. Select Java — Runnable JAR file, and press Next,
    3. In Launch configuration select ColorSlider - Aaaa (where Aaaa is your project),
    4. In Export destination enter Aaaa/src/main/java/jtm/activity15/color-slider.jar (where Aaaa is your project)
    5. In Library handling select Package required libraries into generated JAR
    6. Press Finish,
    7. If errors/warnings are reported, press OK (you may ignore warnings, but have to fix errors).
  6. Open terminal and check, execution of jar file from command line:

    cd ~/Aaaa/src/main/java/jtm/activity15/
    java -jar color-slider.jar 
  7. Check that tests in ColorSliderTestSuite test suite are passing.

Optional task — make jar file smaller

When done as simple export, jar file contains all libraries listed as project dependencies included, which are not necessary just for Swing application. You may make jar file smaller, by icluding only required libraries.

  1. Right click on ColoSlider.java file in Package explorer, and select Export...
  2. Select Java — Runnable JAR file, and press Next,
  3. Also select Save as ANT script and set some location of it (e.g. export.xml in your project) and finish export.
  4. Open export.xml file and delete all <zipfileset ... entries EXCEPT:

    <zipfileset excludes="META-INF/*.SF" src=".../com/miglayout/miglayout/3.5.5/miglayout-3.5.5.jar"/>

    (where ... is location of your M2_REPO) and save it.

  5. Right click on export.xml and select Run as — Ant build.
  6. Check that now color-slider.jar is few hundred kilobytes in size.
You can use design of ColorSliderTest.java class as a template for GUI test for your teamwork project.

More info

Prev
14. Unit testing
Next
16. Android Application
Tags:
Created by Valdis Vītoliņš on 2017-01-03 10:07
Last modified by Valdis Vītoliņš on 2019-08-16 11:35
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License