diff --git a/src/main/java/se/lantz/gui/GameListDataRenderer.java b/src/main/java/se/lantz/gui/GameListDataRenderer.java index c5b2c7c..01b5b78 100644 --- a/src/main/java/se/lantz/gui/GameListDataRenderer.java +++ b/src/main/java/se/lantz/gui/GameListDataRenderer.java @@ -3,10 +3,13 @@ package se.lantz.gui; import java.awt.Color; import java.awt.Component; import java.awt.Font; +import java.awt.Insets; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; +import javax.swing.ImageIcon; import javax.swing.JList; +import javax.swing.SwingConstants; import se.lantz.model.data.GameListData; import se.lantz.model.data.GameView; @@ -35,6 +38,8 @@ public class GameListDataRenderer extends DefaultListCellRenderer { this.boldItalic = getFont().deriveFont(Font.BOLD + Font.ITALIC); this.bold = getFont().deriveFont(Font.BOLD); + this.setHorizontalTextPosition(SwingConstants.LEADING); + this.setHorizontalAlignment(SwingConstants.LEADING); } @Override @@ -59,6 +64,7 @@ public class GameListDataRenderer extends DefaultListCellRenderer private void handleGameListData(Object value, boolean isSelected) { + this.setIcon(null); GameListData listData = (GameListData) value; if (listData.isFavorite()) { @@ -68,6 +74,7 @@ public class GameListDataRenderer extends DefaultListCellRenderer { case 1: this.setForeground(isSelected ? fav1ColorSelected : fav1Color); + this.setIcon(new ImageIcon(this.getClass().getResource("/se/lantz/16x16SaveIcon-1.png"))); break; case 2: this.setForeground(isSelected ? fav2ColorSelected : fav2Color); @@ -105,6 +112,7 @@ public class GameListDataRenderer extends DefaultListCellRenderer break; } } + } private void handleGameListView(Object value, boolean isSelected, int index) @@ -170,4 +178,18 @@ public class GameListDataRenderer extends DefaultListCellRenderer } } } + + @Override + public void setBounds(int x, int y, int width, int height) { + super.setBounds(x, y, width, height); + if (getIcon() != null) { + int padding = 1; + int textWidth = getFontMetrics(getFont()).stringWidth(getText()); + Insets insets = getInsets(); + int iconTextGap = width - textWidth - getIcon().getIconWidth() - insets.left - insets.right - padding; + setIconTextGap(iconTextGap); + } else { + setIconTextGap(0); + } + } } diff --git a/src/main/resources/se/lantz/16x16SaveIcon-1.png b/src/main/resources/se/lantz/16x16SaveIcon-1.png new file mode 100644 index 0000000..704190c Binary files /dev/null and b/src/main/resources/se/lantz/16x16SaveIcon-1.png differ diff --git a/src/main/resources/se/lantz/16x16SaveIcon-2.png b/src/main/resources/se/lantz/16x16SaveIcon-2.png new file mode 100644 index 0000000..e6572f3 Binary files /dev/null and b/src/main/resources/se/lantz/16x16SaveIcon-2.png differ diff --git a/src/main/resources/se/lantz/16x16SaveIcon-3.png b/src/main/resources/se/lantz/16x16SaveIcon-3.png new file mode 100644 index 0000000..c4cd30a Binary files /dev/null and b/src/main/resources/se/lantz/16x16SaveIcon-3.png differ diff --git a/src/main/resources/se/lantz/16x16SaveIcon-4.png b/src/main/resources/se/lantz/16x16SaveIcon-4.png new file mode 100644 index 0000000..44d42f1 Binary files /dev/null and b/src/main/resources/se/lantz/16x16SaveIcon-4.png differ diff --git a/src/main/resources/se/lantz/18x18SaveIcon-1.png b/src/main/resources/se/lantz/18x18SaveIcon-1.png new file mode 100644 index 0000000..b097e79 Binary files /dev/null and b/src/main/resources/se/lantz/18x18SaveIcon-1.png differ diff --git a/src/main/resources/se/lantz/18x18SaveIcon-2.png b/src/main/resources/se/lantz/18x18SaveIcon-2.png new file mode 100644 index 0000000..ff9ca56 Binary files /dev/null and b/src/main/resources/se/lantz/18x18SaveIcon-2.png differ diff --git a/src/main/resources/se/lantz/18x18SaveIcon-3.png b/src/main/resources/se/lantz/18x18SaveIcon-3.png new file mode 100644 index 0000000..94ff6b5 Binary files /dev/null and b/src/main/resources/se/lantz/18x18SaveIcon-3.png differ diff --git a/src/main/resources/se/lantz/18x18SaveIcon-4.png b/src/main/resources/se/lantz/18x18SaveIcon-4.png new file mode 100644 index 0000000..0b3dc80 Binary files /dev/null and b/src/main/resources/se/lantz/18x18SaveIcon-4.png differ diff --git a/src/main/resources/se/lantz/save-states-icon-20.png b/src/main/resources/se/lantz/save-states-icon-20.png new file mode 100644 index 0000000..3d2824e Binary files /dev/null and b/src/main/resources/se/lantz/save-states-icon-20.png differ diff --git a/src/main/resources/se/lantz/save-states-icon18-clean.png b/src/main/resources/se/lantz/save-states-icon18-clean.png new file mode 100644 index 0000000..3158935 Binary files /dev/null and b/src/main/resources/se/lantz/save-states-icon18-clean.png differ diff --git a/src/main/resources/se/lantz/save-states-icon18.png b/src/main/resources/se/lantz/save-states-icon18.png new file mode 100644 index 0000000..ecc31f9 Binary files /dev/null and b/src/main/resources/se/lantz/save-states-icon18.png differ