39
Programming in Java Assignment By Krzysztof Dziurawiec HNC Student Krzysztof Dziurawiec Programing in Java HNC 2015 Page 1

Programming in Java

Embed Size (px)

Citation preview

Page 1: Programming in Java

Programming in Java

Assignment

By

Krzysztof Dziurawiec

HNC Student

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 1

Page 2: Programming in Java

Content:

1. Project proposal………………………………………………………………………………………………………..32. Project plan………………………………………………………………………………………………………………33. Project design:………………………………………………………………………………………………………….4

a. Record structure designb. User interface components designc. Data flow diagramd. Entity relationship diagrame. Class diagram

4. Produced interface and application code………………………………………………………………….95. System testing………………………………………………………………………………………………………..18

a. Test schedule and resultsb. Report on test scheduled for Image Viewer application

6. System evaluation…………………………………………………………………………………………………..227. User Guide……………………………………………………………………………………………………………..238. Power Point presentation……………………………………………………………………………………….32

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 2

Page 3: Programming in Java

Project Proposal

Proposed project is a development of software which would store in file(s) images with their associated text and be able to retrieve that information from file(s) which, would be than displayed in picture viewer. The software should have GUI windows user interface. User should be able to navigate between stored pictures and be able to add description to them. As an addition should be included dropdown box with picture list selection for quick access.

For development of proposed software I will use Java programming language which support object orientated techniques needed for this project. I would include following components: Swing components to create GUI environment, Layout Managers which allow displaying all components in correct manner, FileWriter Class which provide file writing function and FileReader Class which provide file reading functions.

As assistance with development of proposed project, error handling and testing I will use Eclipse integrated development environment (IDE) software for Java.

Project Plan

Task Name Task Description Start Date Finish DateStart of project Start of project 08/06/15 08/06/15Project proposal Producing project proposal 08/06/15 08/06/15Project plan Producing project plan 09/06/15 09/06/15Designing stage Designing record structure, user

interface components for maintaining, retrieving and displaying selected information

10/06/15 11/06/15

Implementing design produce

Creating working software by using Java components

12/06/15 23/06/15

Testing stage Testing all function of the software and fixing errors

24/06/15 24/06/15

Evaluation and Hand over

Producing evaluation of created software and recommendation list of future improvements

25/06/15 26/06/15

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 3

Page 4: Programming in Java

Project Design

Record structure design

The record structure of proposed project will be held in JAVA folder. Inside this folder would be three folders: Images, Text, JavaRun.

Images folder would store all images which would be retrieved into the image viewer as an image files.

Text folder would store all description associated with corresponding picture as a text files.

JavaRun folder would store all java files which are needed to run software.

File DescriptionImages Folder holding images files

image01 Application create class for this file and displays itimage02 Application create class for this file and displays itimage03 Application create class for this file and displays itimage04 Application create class for this file and displays itimage05 Application create class for this file and displays itimage06 Application create class for this file and displays itimage07 Application create class for this file and displays itimage08 Application create class for this file and displays itimage09 Application create class for this file and displays itImage10 Application create class for this file and displays it

Text Folder holding text files with images descriptionstext01 File hold text description of associated imagetext02 File hold text description of associated imagetext03 File hold text description of associated image

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 4

Page 5: Programming in Java

text04 File hold text description of associated imagetext05 File hold text description of associated imagetext06 File hold text description of associated imagetext07 File hold text description of associated imagetext08 File hold text description of associated imagetext09 File hold text description of associated imagetext10 File hold text description of associated image

run.exe File opening applicationabout.txt Text file holding help and support informationreadme.txt Text file holding how to install and run program

information

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 5

Page 6: Programming in Java

User interface components design

JFrame window in size 700 by 680 Menu bar set at the top of JFrame window include menu options. “File” menu

consist “Open in Paint” option, “Save” option and “Close” option. “Tools” menu include: “Font Colour” option which allows changing font colour in text area, “Look and Feel” submenu consisting two options for look of the application: “Nimbus” set as default and “Metal” as an optional. “Help” menu includes “About” option which consist text regarding use of application and Support details.

Image title which is stored in text file in first line. Image view is a JLabel area in size 640 by 360. Image view area is designed to display

chosen image from images folder Picture description is a editable JText Field located below image view. It consist text

related to displayed image which is stored in text file in text folder. Dropdown box allows searching for specific text and picture. Save is a JButton which allows saving changes made to the text in picture description

area. Navigation buttons under the picture description area are Jbuttons which are helping

with navigation between pictures, they function after pressing them from left are: go back to the first picture, go to previous picture, go to next picture and go back to the last picture.

Data Flow Diagram

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 6

Page 7: Programming in Java

Entity relationship diagram

Class diagram

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 7

Page 8: Programming in Java

Produced interface and application code

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 8

Page 9: Programming in Java

Picture.java

package com.chris.imageviewer;

public class Picture{

private String pictureTitle;private String pictureFilePath;private String pictureTextPath;private String picureText;private String comboDisplayName;private String pictureAbsolutePath;private String pictureTextAbsolutePath;

public String getPictureAbsolutePath(){

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 9

Page 10: Programming in Java

return pictureAbsolutePath;}

public void setPictureAbsolutePath(String pictureAbsolutePath){

this.pictureAbsolutePath = pictureAbsolutePath;}

public void setComboDisplayName(String comboDisplayName){

this.comboDisplayName = comboDisplayName;}

public String getPictureTextAbsolutePath(){

return pictureTextAbsolutePath;}

public void setPictureTextAbsolutePath(String pictureTextAbsolutePath){

this.pictureTextAbsolutePath = pictureTextAbsolutePath;}

public Picture(String pictureFilePath, String pictureTextPath){

this.pictureFilePath = pictureFilePath;this.pictureTextPath = pictureTextPath;

}

public String getPictureTitle(){

return pictureTitle;}

public void setPictureTitle(String pictureTitle){

this.pictureTitle = pictureTitle;}

public String getPictureFilePath(){

return pictureFilePath;}

public void setPictureFilePath(String pictureFilePath){

this.pictureFilePath = pictureFilePath;}

public String getPictureTextPath(){

return pictureTextPath;}

public void setPictureTextPath(String pictureTextPath){

this.pictureTextPath = pictureTextPath;}

public String getPicureText(){

return picureText;}

public void setPicureText(String picureText)

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 10

Page 11: Programming in Java

{this.picureText = picureText;

}@Overridepublic String toString(){

return comboDisplayName;}

}

ApplicationPictures.java

package com.chris.imageviewer;

import java.io.File;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.List;import java.util.Scanner;

public class ApplicationPictures{

public List<Picture>getPictures(){

List<Picture> allPictures = new ArrayList<Picture>();for (int i=0; i<10; i++){

String pictureFilePath = "images/image" +(i+1) +".jpg";String pictureTextPath = "text/text"+(i+1)+".txt";Picture picture = createPicture(pictureFilePath,

pictureTextPath);allPictures.add(picture);

}

return allPictures;

}

private Picture createPicture(String pictureFilePath, String pictureTextPath)

{Picture picture = new Picture(pictureFilePath, pictureTextPath);try{

File textFile = new File(pictureTextPath);File imageFile = new File(pictureFilePath);picture.setComboDisplayName(textFile.getName());picture.setPictureAbsolutePath(imageFile.getAbsolutePath());picture.setPictureTextAbsolutePath(textFile.getAbsolutePath());Scanner scan = new Scanner(textFile);picture.setPictureTitle(scan.nextLine());StringBuilder fileText = new StringBuilder();

while(scan.hasNextLine()) //scanner looking for end of the file mark

{ fileText.append(scan.nextLine()+"\n"); //adding

new lines with \n to mark end of the file}

picture.setPicureText(fileText.toString());scan.close();

} catch (FileNotFoundException e){

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 11

Page 12: Programming in Java

// TODO Auto-generated catch blocke.printStackTrace();

}return picture;

}}

ImageViewer.java

package com.chris.imageviewer;

import java.awt.Color;import java.awt.Font;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.io.FileNotFoundException;import java.io.IOException;import java.io.PrintWriter;import java.util.List;

import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JColorChooser;import javax.swing.JComboBox;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.KeyStroke;import javax.swing.SwingUtilities;import javax.swing.UIManager;import javax.swing.UnsupportedLookAndFeelException;

public class ImageViewer extends JFrame implements ActionListener{

List<Picture> allPicturesList;JMenuBar menuBar;

//create menu barJMenu menuFile, menuTools, menuHelp, menuLookAndFeel;

//create menu optionsJMenuItem OpenPaint, menuOptionSave, menuOptionClose, menuOptionFontColor,

menuOptionNimbus, menuOptionMetal, menuAbout; //create sub menusJLabel bikePicture, bikeTitle;JTextArea bikeText;JButton nextButton, backButton, toStartButton, toEndButton, saveButton;

//create buttonsJComboBox<Picture> combo;

public ImageViewer(){

setSize(700, 680);setTitle("Image Viewer 2.0");setLocationRelativeTo(null); //setting window in center of the

screensetLayout(null);

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 12

Page 13: Programming in Java

Nimbus(); //setting look to Nimbus style declared in Nimbus class as default

menuBar = new JMenuBar(); //adding menu barsetJMenuBar(menuBar);

//------------creating menu--------------------------------------------menuFile = new JMenu("File"); //adding menu optionsmenuBar.add(menuFile);

OpenPaint = new JMenuItem("Open in Paint",'O');//'O'adding underline for quick access in menu

menuFile.add(OpenPaint);OpenPaint.addActionListener(this);

menuOptionSave = new JMenuItem("Save",'S');menuFile.add(menuOptionSave);menuOptionSave.setToolTipText("Saving edited text into

specified file");menuOptionSave.addActionListener(this);

menuFile.addSeparator(); // adding separator

menuOptionClose = new JMenuItem("Close");menuFile.add(menuOptionClose);menuOptionClose.addActionListener(this);menuOptionClose.setAccelerator(KeyStroke.getKeyStroke("ctrl

X")); //creating shortcut for menu close option

menuTools = new JMenu("Tools");menuBar.add(menuTools);

menuOptionFontColor = new JMenuItem("Font Colour");menuTools.add(menuOptionFontColor);menuOptionFontColor.addActionListener(this);

menuLookAndFeel = new JMenu("Look and Feel");menuLookAndFeel.setToolTipText("Choosing application style");menuTools.add(menuLookAndFeel);

menuOptionNimbus = new JMenuItem("Nimbus");menuLookAndFeel.add(menuOptionNimbus);menuOptionNimbus.addActionListener(this);

menuOptionMetal = new JMenuItem("Metal");menuLookAndFeel.add(menuOptionMetal);menuOptionMetal.addActionListener(this);

menuHelp = new JMenu("Help");menuBar.add(menuHelp);

menuAbout = new JMenuItem("About");menuHelp.add(menuAbout);menuAbout.addActionListener(this);

//-----------creating layout-----------------------------------------ApplicationPictures applicationPictures = new ApplicationPictures();allPicturesList = applicationPictures.getPictures();Picture firstPicture = allPicturesList.get(0);bikeTitle = new JLabel("Welcome to ImageViewer",JLabel.CENTER);bikeTitle.setBounds(25, 10, 640, 30);bikeTitle.setFont(new Font("SanSerif",Font.BOLD,20));

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 13

Page 14: Programming in Java

bikeTitle.setForeground(Color.BLUE);add(bikeTitle);

bikePicture = new JLabel(new ImageIcon(firstPicture.getPictureFilePath()));

bikePicture.setBounds(25, 40, 640, 360);bikePicture.setToolTipText("To edit picture use option: open in paint

in main menu");add(bikePicture);

bikeText = new JTextArea();//creating notepad

bikeText.setText(firstPicture.getPicureText());bikeText.setWrapStyleWord(true);bikeText.setForeground(Color.BLUE);bikeText.setToolTipText("To edit, click, add text and when you

finished press save");JScrollPane scroll = new JScrollPane(bikeText);

//adding scroll pane and assigning notepad to itscroll.setBounds(20, 420, 510, 150);add(scroll);

nextButton = new JButton("Next >");nextButton.setBounds(290, 580, 80, 30);add(nextButton);nextButton.addActionListener(this);

backButton = new JButton("< Back");backButton.setBounds(180, 580, 80, 30);add(backButton);backButton.addActionListener(this);

toStartButton = new JButton("Last>>");toStartButton.setBounds(380, 580, 80, 30);toStartButton.setToolTipText("Sets last picture in the file");add(toStartButton);toStartButton.addActionListener(this);

toEndButton = new JButton("<< First ");toEndButton.setBounds(90, 580, 80, 30);toEndButton.setToolTipText("Sets first picture in the file");add(toEndButton);toEndButton.addActionListener(this);

saveButton = new JButton("Save");saveButton.setBounds(540, 460, 80, 30);add(saveButton);saveButton.addActionListener(this);

combo = new JComboBox<Picture>();

for (Picture picture : allPicturesList){

combo.addItem(picture);}

combo.setBounds(540, 420, 120, 30);add(combo);combo.addActionListener(this);

}

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 14

Page 15: Programming in Java

@Overridepublic void actionPerformed(ActionEvent e){

Object source = e.getSource();int selectedIndex = combo.getSelectedIndex();int picturesListSize = allPicturesList.size();

if(source==menuOptionClose){

int ans = JOptionPane.showConfirmDialog(menuOptionClose, "Do you really want to quit","End program",JOptionPane.YES_NO_OPTION); //adding option message to close the program

if(ans==JOptionPane.YES_OPTION)dispose();

else if(ans==JOptionPane.NO_OPTION)JOptionPane.showMessageDialog(null, "Thanks for

staying..."); //adding extra message boxelse if(ans==JOptionPane.CLOSED_OPTION)

JOptionPane.showMessageDialog(null, "please use yes or no option next time","Warnning",JOptionPane.WARNING_MESSAGE); //adding warning message box

} else if(source==nextButton) {

if(selectedIndex==(picturesListSize-1)) {

JOptionPane.showMessageDialog(null, "You reached end of records");

} else { int j = combo.getSelectedIndex(); j++; combo.setSelectedIndex(j); }

} else if(source==backButton) {

if(selectedIndex==0) {

JOptionPane.showMessageDialog(null, "You reached beginning of records");

} else {

int i = combo.getSelectedIndex(); i--; combo.setSelectedIndex(i); }

} else if(source==toStartButton) {

combo.setSelectedIndex(picturesListSize-1); } else if (source==toEndButton) {

combo.setSelectedIndex(0); }

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 15

Page 16: Programming in Java

else if(source==OpenPaint) {

Picture selectedPicture = (Picture)combo.getSelectedItem();

try{

Runtime.getRuntime().exec(new String[] {

"C:\\WINDOWS\\system32\\mspaint.exe",

selectedPicture.getPictureAbsolutePath() });} catch (IOException e1){

e1.printStackTrace();}

}

else if((source==saveButton)||(source==menuOptionSave)) {

Picture selectedPicture = (Picture)combo.getSelectedItem();

JFileChooser fileChooser = new JFileChooser(selectedPicture.getPictureTextAbsolutePath());

if(fileChooser.showSaveDialog(null)==JFileChooser.APPROVE_OPTION)//creating save file chooser

{File file = fileChooser.getSelectedFile();

//JOptionPane.showMessageDialog(null, file);try{

PrintWriter save = new PrintWriter(file);//openingPrintWriter with catch exception to save text in file

save.println(bikeTitle.getText());save.println(bikeText.getText());

// passing info to the PrintWriter for save

save.close(); //closing PrintWriter

selectedPicture.setPicureText(bikeText.getText());} catch (FileNotFoundException e1){

e1.printStackTrace();}

} } else if(source==menuOptionFontColor) {

Color fontColor = JColorChooser.showDialog(null, "Font Color", Color.BLUE);

bikeText.setForeground(fontColor); } else if(source==menuOptionNimbus) {

Nimbus(); }

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 16

Page 17: Programming in Java

else if(source==menuOptionMetal) {

Metal(); } else if(source==combo) {

Picture picture = (Picture) combo.getSelectedItem(); bikeTitle.setText(picture.getPictureTitle()); bikePicture.setIcon(new

ImageIcon(picture.getPictureFilePath())); bikeText.setText(picture.getPicureText());

} else if(source==menuAbout) {

try{

Runtime.getRuntime().exec("notepad.exe about.txt");} catch (IOException e1){

// TODO Auto-generated catch blocke1.printStackTrace();

} }

}

public static void main(String[] args)

{ImageViewer app = new ImageViewer();app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);app.setVisible(true);try{

Thread.sleep(2000);} catch (InterruptedException e){

// TODO Auto-generated catch blocke.printStackTrace();

}app.bikeTitle.setText(app.allPicturesList.get(0).getPictureTitle());

}

private void Nimbus(){

try{

UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");} catch (ClassNotFoundException | InstantiationException

| IllegalAccessException | UnsupportedLookAndFeelException e1)

{// TODO Auto-generated catch blocke1.printStackTrace();

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 17

Page 18: Programming in Java

} SwingUtilities.updateComponentTreeUI(this);

}

private void Metal(){

try{

UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");} catch (ClassNotFoundException | InstantiationException

| IllegalAccessException | UnsupportedLookAndFeelException e1)

{// TODO Auto-generated catch blocke1.printStackTrace();

} SwingUtilities.updateComponentTreeUI(this);

}

}

System testing

a. Test schedule and results

Test action Expected result Actual result OK Action1 Opening application Application open in centre

of the screen with displayed first image, text and welcome screen

Yes

2 Display welcome title Welcome Title displayed for 3 seconds and change to bike title

Welcome Title displayed for 3 seconds and change to bike title

Yes

3 Closing application by Close menu option

Message window ask if you want to quit, after clicking yes application terminate.

Yes

4 Closing application using Ctrl x shortcut

Message window display, asking if you want to quit, after clicking yes application terminate.

Message window display, asking if you want to quit, after clicking yes application terminate.

Yes

5 Clicking Next button Next picture from the folder should be displayed with correct text and title

Yes

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 18

Page 19: Programming in Java

6 Clicking Next button when last picture in folder is displayed

Message window should announce that this is last picture in the folder

Yes

7 Clicking Back button Previous picture is displayed with correct text and title

Yes

8 Clicking Back button when first picture is displayed

Message window should announce that this is first picture in the folder

Yes

9 Clicking Last button Displays last image with text and title in the folder

Displays last image with text and title in the folder

Yes

10 Clicking First button Displays first image with text and title in the folder

Displays first image with text and title in the folder

Yes

11 Selecting test4 in combo box from the list

Display text4 with image4 and right title

Yes

12 Selecting test9 in combo box from the list

Display text9 with image4 and right title

Yes

13 Displaying selected image with right text and title

Image5 displayed with text5 and title: KTM RC8R

Image5 displayed with text5 and title: KTM RC8R

Yes

14 Displaying selected image with right text and title

Image8 displayed with text8 and title: BMW K1300R

Image8 displayed with text8 and title: BMW K1300R

Yes

15 Displaying next images in correct order after next selection

After image8 next image displayed is image9

After image8 next image displayed is image9

Yes

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 19

Page 20: Programming in Java

16 Editing text After clicking on the text field cursor starts blinking and text can be modified

Yes

17 Saving text by Save button File directory should open in current directory and after choice of file and clicking on Save button changes would be saved.

Yes

18 Saving text by Save menu option

File directory opens in current directory and after choice of file and clicking on Save button changes would be saved.

File directory opens in current directory and after choice of file and clicking on Save button changes would be saved.

Yes

19 While using Save option, opening directory in current program location

Directory should be open in text folder in current program location

Directory is set as default for different location

No Added method to getCurrentProgram FullPath to the text folder after which expected result is achieved

20 Opening picture in Paint application

After clicking on Open in paint option in menu File current image is open in Paint

Yes

21 Using Font Colour option Font colour changed to pink Yes

22 Choosing Look and Feel option Metal

Application look is changed to Metal theme

Application look is changed to Metal theme

Yes

23 Choosing Look and Feel option Nimbus

Application look is changed to Nimbus theme

Application look is changed to Nimbus theme

Yes

24 Opening About option in Help menu

Notepad opens with about.txt file

Notepad opens with about.txt file Yes

25 Showing help clues while hovering over objects

Showing help message tooltip over text area

Yes

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 20

Page 21: Programming in Java

26 Adding more images with related text to the folder

Displaying new pictures after clicking next button

Added images are not showing becouse the loop for list is limited to 10 images

No For loop need to be changed to new number of images every time, as future improvement recommend to adjust the loop structure so any number of elements can be displayed

b. Report on test scheduled for Image Viewer application

After completed test schedule that covers all of the program functionality I found following:

Regarding to tests 1-4, application is opening after double clicking on run.jar file. Application opens in the middle of the screen with all GUI elements displayed in designed places. First image in the folder is displayed correctly with related text. Welcome title is displayed for three seconds after which is changed automatically to current image title.

Closing application is working properly by using Close option or keyboard shortcut. Warning message is displayed and user is asked for close choice confirmation.

Test 5 - 10 and test 15: shows navigation buttons functionality and that application is reading correct files from correct folders in right sequence.

Next button is working correctly and clicking it, change image to the next image in the right order. Back button is working correctly and change current image to previous in the right order. As an exception handling method, message boxes are displayed when user reached last or first image.

First and Last buttons are working correctly by going accordingly to the first image in the folder and last image in the folder.

Tests 11 – 12 are showing correct display of combo box selected choices.

Tests 13 – 14 are proving that to every image selected correct text and title is displayed.

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 21

Page 22: Programming in Java

In tests 16 to 19 editing and saving option are tested. Selected text can be edited and saved into specified file in directory. Directory was not displaying current program path, so I modified code to open directory in the current program location which solved the issue. Even moving program to new location will still open correct path to the folder holding text files.

Test 20 shows that Open in Paint option is working correctly and selected image is open in Paint application.

Tests 21 – 23 are showing that additional features to change font colour or application theme are working correctly.

Test 24 shows that about.txt which holds help and support information is opening in notepad.

Test 25 is showing that tooltip help information are displayed correctly while hovering over objects with mouse.

Test 26 checks if program is scalable. Currently program displays 10 images, more images can be added for displaying but currently adjustment needs to be made in the List of images loop but this is not user friendly solution.

System evaluation

In conclusion, all tested features included in Image Viewer application are working correctly. Data is stored accurately in designed files: text(x).txt and images(x).jpg. Program is reading data from the file accurately and displays it in structured GUI environment. All elements are displayed in right place and correct order.

All menu options are working properly and correct functions are open after clicking selected option. All buttons are working properly and assigned functionality is working correctly. External program Paint and Notepad are opening as an option from main program.

Having options to change application look theme and font colour it provide option to personalize application accordingly to the user taste and make it more personal. Unfortunately the settings selected by user are lost after application is closed, so I would suggest as an future improvement to save changed settings by overriding current default settings which allows to reopen application with user preferred theme.

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 22

Page 23: Programming in Java

Handling exceptions are working accurate, by informing user about reaching beginning or end of the folder. “Try catch” exceptions implemented in the code are working correctly while opening text files or image files.

Current version of application is very rigid, it is possible to scale program by adding new images and texts but currently it is not user friendly. As an improvement, I would suggest creating a separate option for adding new images and text to the current Array List which would be more user friendly then current option which need adjusting the For loop counter “i” to the new number of files.

User Guide

For

Image Viewer

By

Krzysztof Dziurawiec

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 23

Page 24: Programming in Java

Contents:

1. Overview2. Version3. Installing application4. Opening application5. Main functions:

5.1. Navigation buttons5.2. Using combo box5.3. Editing text5.4. How to save edited text5.5. How to open image in Paint5.6. Changing font colour5.7. Look and Feel option5.8. Help menu

6. Closing application7. FAQ8. Technical support

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 24

Page 25: Programming in Java

1. Overview

Image Viewer is a java application which displays images and related text. Images and text files are stored in Images and Text folders. User can select required image by clicking on navigation buttons below text field or select directly from combo box.

Additionally application has option to edit and save text from text area; open image in Paint for editing purpose.

2. Version

Image Viewer version 2.0 java application created in June 2015 by Krzysztof Dziurawiec HNC student at Newbury College.

3. Installing application

To sucesfullyinstallImage Viewer please copy Image Viewer Folder into chosen directory. Image Viewer Folder should contain: images Folder, text Folder, run.exe file, readme.txt file, about.txt file and Documantation folder.

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 25

Page 26: Programming in Java

4. Opening application

To open Image Viewer application please goes to Image Viewer Folder. Inside the folder find file: run.jar and double click on it after which application will launch.

To open Image Viewer in command prompt go to Image Viewer location by using command cd (full path) and enter "java -jar run.jar" which opens application

To run Image Viewer on your system, you need to have installed Java Run Environment version 8.

5. Main Functions

5.1. Navigation buttons

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 26

Page 27: Programming in Java

Next button – after clicking this button next image with related text will be displayed Back button – after clicking this button previous image with related text will be

displayed First button – clicking this button will display the first in the folder image with related

text. Last button - clicking this button will display the last in the folder image with related

text.5.2. Using combo box

By clicking on one of the title inside the combo box, user is selecting image and text for display.

5.3. Editing text

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 27

Page 28: Programming in Java

To edit text please click inside text area. After clicking, cursor should appear and you can make changes to the text.

5.4. How to save edited text

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 28

Page 29: Programming in Java

To save edited text please click on Save button next to text area or select Save option from File menu in Menu bar. After clicking, program default directory will open. Please choose which file you making changes to and click save. Please note that title in combo box displays the name of the file which you are currently editing, so if you want save changes to the same file, please choose text file with the same name as shown in combo box.

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 29

Page 30: Programming in Java

5.5. How to open image in Paint

To open selected image in Paint, please go to Menu bar, File menu and choose Open in Paint option. Current image will open in Paint application ready to edit.

5.6. Changing font colour

To change font colour of text, go to Menu bar, Tools menu and choose Font Colour option. New window will open in which you can set new colour and click Apply button to implement changes.

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 30

Page 31: Programming in Java

5.7. Look and Feel option

You can change the look of application. There are two available themes: Nimbus and Metal. To change current theme, please go to Menu bar, Tools menu, Look and Feel sub menu and click on theme of your choice.

5.8. Help menu

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 31

Page 32: Programming in Java

For help related to application interface or functionality go to Menu bar, Help menu and choose About option, which will open about.txt file.

6. Closing application

To close, please select in Menu bar, File menu and click on Close option or alternatively press Ctrl + x shortcut combination. In next window you will be asked if you really want to quit, pressing Yes would close application.

7. FAQ How to go back to first picture?

Pressing First button will display the first in the folder image with related text. How to go to last picture?

Pressing Last button will display the last in the folder image with related text. How to edit text?

To edit text please click inside text area. After clicking, cursor should appear and you can make changes to the text.

How to open application?To open Image Viewer application please goes to Image Viewer Folder. Inside the folder find file: run.jar and double click on it after which application will launch.

How to add new images?To add new images with text, you can add images to the images folder with file name: image(x).jpg where (x) is the id number of images. To add text you should save text file into text Folder with name: text(x).txt where (x) should have the same number as image(x).jpg.

8. Technical support contact details:

Krzysztof Dziurawiec

HNC Technical Support

Newbury College

Newbury

Email: [email protected]

Krzysztof Dziurawiec Programing in Java HNC 2015 Page 32