Skip to content

Commit

Permalink
set an application icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslanys committed Oct 28, 2017
1 parent 18a4145 commit fc12839
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

## [Новое]
### Добавлено
- Установочные пакеты приложения для Windows, Unix, MacOS со встроенной JRE.
- Установочные пакеты приложения для Windows, Unix, MacOS со встроенной JRE.
- Установлена иконка (#14).

### Исправлено
- Установлены минимальные размеры окон.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/ruslanys/vkmusic/ui/view/LoginFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import me.ruslanys.vkmusic.util.DesktopUtils;
import org.springframework.stereotype.Component;

import javax.swing.*;
Expand All @@ -29,6 +30,7 @@ public class LoginFrame extends LoadingFrame implements ChangeListener<Worker.St
protected void initWindow() {
setTitle("Авторизация");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setIconImage(DesktopUtils.getIcon());

setSize(1000, 660);
setMinimumSize(new Dimension(640, 480));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/ruslanys/vkmusic/ui/view/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Setter;
import me.ruslanys.vkmusic.entity.domain.event.LogoutEvent;
import me.ruslanys.vkmusic.ui.model.AudioTableModel;
import me.ruslanys.vkmusic.util.DesktopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -57,6 +58,7 @@ public MainFrame(@NonNull ApplicationEventPublisher publisher,
protected void initWindow() {
setTitle("VKMusic");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setIconImage(DesktopUtils.getIcon());

setSize(new Dimension(640, 480));
setMinimumSize(new Dimension(640, 240));
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/me/ruslanys/vkmusic/util/DesktopUtils.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
package me.ruslanys.vkmusic.util;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import me.ruslanys.vkmusic.Application;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URL;

/**
* @author Ruslan Molchanov ([email protected])
*/
@Slf4j
public class DesktopUtils {

private static final Image ICON;
private static final Desktop DESKTOP = Desktop.getDesktop();

static {
Image image;
try {
URL resource = Application.class.getClassLoader().getResource("images/icon.png");
image = ImageIO.read(resource);
} catch (IOException e) {
log.error("Can not load an application icon", e);
image = null;
}
ICON = image;
}

private DesktopUtils() {
throw new UnsupportedOperationException();
}
Expand All @@ -27,4 +45,8 @@ public static void browse(URL url) {
browse(url.toURI());
}

public static Image getIcon() {
return ICON;
}

}
Binary file modified src/main/resources/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc12839

Please sign in to comment.