why does the ui crash
This commit is contained in:
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/GraphicsUtils.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/GraphicsUtils.java
Normal file → Executable file
52
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/HelloMinecraftLookAndFeel.java
Normal file → Executable file
52
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/HelloMinecraftLookAndFeel.java
Normal file → Executable file
@@ -1,23 +1,32 @@
|
||||
/*
|
||||
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.lookandfeel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
import sun.swing.DefaultLookup;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -25,12 +34,45 @@ import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||
*/
|
||||
public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
|
||||
|
||||
public static final Map<String, String> DEFAULT_SETTINGS = Theme.BLUE.settings;
|
||||
|
||||
/**
|
||||
* Creates a new instance of NimbusLookAndFeel
|
||||
* @throws java.text.ParseException error parsing the xml, it must not happen.
|
||||
*
|
||||
* @throws java.text.ParseException error parsing the xml, it must not
|
||||
* happen.
|
||||
*/
|
||||
public HelloMinecraftLookAndFeel() throws ParseException {
|
||||
load(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml"), HelloMinecraftLookAndFeel.class);
|
||||
this(DEFAULT_SETTINGS);
|
||||
}
|
||||
|
||||
public HelloMinecraftLookAndFeel(Map<String, String> settings) throws ParseException {
|
||||
try {
|
||||
String s = NetUtils.getStreamContent(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml"));
|
||||
for (String ss : settings.keySet())
|
||||
s = s.replace("${" + ss + "}", settings.get(ss));
|
||||
load(new ByteArrayInputStream(s.getBytes()), HelloMinecraftLookAndFeel.class);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
throw new ParseException("FUCKING BUG", 0);
|
||||
}
|
||||
}
|
||||
|
||||
UIDefaults uiDefaults;
|
||||
|
||||
@Override
|
||||
public UIDefaults getDefaults() {
|
||||
if (uiDefaults != null)
|
||||
return uiDefaults;
|
||||
uiDefaults = super.getDefaults();
|
||||
//ui.put("Table.selectionForeground", new ColorUIResource(Color.red));
|
||||
//ui.put("Table.focusCellForeground", new ColorUIResource(Color.red));
|
||||
//ui.put("TabbedPane.isTabRollover", false);
|
||||
//ui.put("ComboBox.selectionBackground", new ColorUIResource(Color.red));
|
||||
//ui.put("List.background", new ColorUIResource(Color.red));
|
||||
//uiDefaults.put("TabbedPane.selectedLabelShift", 0);
|
||||
uiDefaults.put("Table.selectionBackground", Color.red);
|
||||
return uiDefaults;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher.
|
||||
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.lookandfeel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public enum Theme {
|
||||
BLUE(C.i18n("color.blue"), new HashMap<String, String>() {
|
||||
{
|
||||
put("Customized.TabbedPaneTab.selected_foreground", "#106CA3");
|
||||
put("Customized.ComboBox.selected_background", "#A0D8F0");
|
||||
put("Customized.MainFrame.background", "#106CA3");
|
||||
put("Customized.MainFrame.selected_background", "#0C5E91");
|
||||
}
|
||||
}),
|
||||
GREEN(C.i18n("color.green"), new HashMap<String, String>() {
|
||||
{
|
||||
put("Customized.TabbedPaneTab.selected_foreground", "#1ABC9C");
|
||||
put("Customized.ComboBox.selected_background", "#1ABC9C");
|
||||
put("Customized.MainFrame.background", "#1ABC9C");
|
||||
put("Customized.MainFrame.selected_background", "#16A085");
|
||||
}
|
||||
}),
|
||||
PURPLE(C.i18n("color.purple"), new HashMap<String, String>() {
|
||||
{
|
||||
put("Customized.TabbedPaneTab.selected_foreground", "#9B59B6");
|
||||
put("Customized.ComboBox.selected_background", "#9B59B6");
|
||||
put("Customized.MainFrame.background", "#9B59B6");
|
||||
put("Customized.MainFrame.selected_background", "#8E44AD");
|
||||
}
|
||||
}),
|
||||
DARKER_BLUE(C.i18n("color.dark_blue"), new HashMap<String, String>() {
|
||||
{
|
||||
put("Customized.TabbedPaneTab.selected_foreground", "#34495E");
|
||||
put("Customized.ComboBox.selected_background", "#34495E");
|
||||
put("Customized.MainFrame.background", "#34495E");
|
||||
put("Customized.MainFrame.selected_background", "#2C3E50");
|
||||
}
|
||||
}),
|
||||
ORANGE(C.i18n("color.orange"), new HashMap<String, String>() {
|
||||
{
|
||||
put("Customized.TabbedPaneTab.selected_foreground", "#E67E22");
|
||||
put("Customized.ComboBox.selected_background", "#F39C12");
|
||||
put("Customized.MainFrame.background", "#E67E22");
|
||||
put("Customized.MainFrame.selected_background", "#D35400");
|
||||
}
|
||||
}),
|
||||
RED(C.i18n("color.red"), new HashMap<String, String>() {
|
||||
{
|
||||
put("Customized.TabbedPaneTab.selected_foreground", "#E74C3C");
|
||||
put("Customized.ComboBox.selected_background", "#E74C3C");
|
||||
put("Customized.MainFrame.background", "#E74C3C");
|
||||
put("Customized.MainFrame.selected_background", "#C0392B");
|
||||
}
|
||||
});
|
||||
|
||||
public final String localizedName;
|
||||
public final Map<String, String> settings;
|
||||
|
||||
private Theme(String localizedName, Map<String, String> settings) {
|
||||
this.localizedName = localizedName;
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/components/ConstomButton.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/components/ConstomButton.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/components/IConstomable.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/components/IConstomable.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/painters/ButtonPainter.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/painters/ButtonPainter.java
Normal file → Executable file
42
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/painters/ProgressPainter.java
Normal file → Executable file
42
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/painters/ProgressPainter.java
Normal file → Executable file
@@ -37,23 +37,13 @@ import java.awt.LinearGradientPaint;
|
||||
*/
|
||||
public class ProgressPainter extends SynthPainter {
|
||||
|
||||
private static final float[] NORMAL_BG_PTS = new float[]{0, 1};
|
||||
private static final Color[] NORMAL_BG = new Color[]{
|
||||
private static final float[] NORMAL_BG_PTS = new float[] {0, 1};
|
||||
private static final Color[] NORMAL_BG = new Color[] {
|
||||
GraphicsUtils.getWebColor("c6c6c6"),
|
||||
GraphicsUtils.getWebColor("c6c6c6")
|
||||
};
|
||||
private static final float[] NORMAL_FG_PTS = new float[]{0, 1};
|
||||
private static final Color[] NORMAL_FG = new Color[]{
|
||||
GraphicsUtils.getWebColor("c6c6c6"),
|
||||
GraphicsUtils.getWebColor("c6c6c6")
|
||||
};
|
||||
private static final float[] BAR_BG_PTS = new float[]{0, 1};
|
||||
private static final Color[] BAR_BG = new Color[]{
|
||||
GraphicsUtils.getWebColor("41B1E1"),
|
||||
GraphicsUtils.getWebColor("41B1E1")
|
||||
};
|
||||
private static final float[] BAR_FG_PTS = new float[]{0, 1};
|
||||
private static final Color[] BAR_FG = new Color[]{
|
||||
private static final float[] BAR_FG_PTS = new float[] {0, 1};
|
||||
private static final Color[] BAR_FG = new Color[] {
|
||||
GraphicsUtils.getWebColor("41B1E1"),
|
||||
GraphicsUtils.getWebColor("41B1E1")
|
||||
};
|
||||
@@ -61,39 +51,31 @@ public class ProgressPainter extends SynthPainter {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void paintProgressBarBackground(SynthContext context, Graphics g, int x, int y, int w, int h,
|
||||
int orientation) {
|
||||
int orientation) {
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.setPaint(new LinearGradientPaint(x, y + 3, x, y + h - 4, NORMAL_BG_PTS, NORMAL_BG));
|
||||
if (x + 2 < w - 5 && y + 2 < h - 5) {
|
||||
g2.setPaint(new LinearGradientPaint(x, y + 2, x, y + h - 4, NORMAL_BG_PTS, NORMAL_BG));
|
||||
if (x + 2 < w - 5 && y + 2 < h - 5)
|
||||
g2.fillRect(x + 2, y + 2, w - 5, h - 5);
|
||||
}
|
||||
g2.setPaint(new LinearGradientPaint(x, y + 2, x, y + h - 5, NORMAL_FG_PTS, NORMAL_FG));
|
||||
if (x + 2 < w - 5 && y + 2 < h - 5) {
|
||||
g2.drawRect(x + 2, y + 2, w - 5, h - 5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void paintProgressBarForeground(SynthContext context, Graphics g, int x, int y, int w, int h,
|
||||
int orientation) {
|
||||
int orientation) {
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.setPaint(new LinearGradientPaint(x, y + 3, x, y + h - 4, BAR_BG_PTS, BAR_BG));
|
||||
if (x + 2 < w - 5 && y + 2 < h - 5) {
|
||||
g2.fillRect(x + 2, y + 2, w - 5, h - 5);
|
||||
}
|
||||
g2.setPaint(new LinearGradientPaint(x, y + 2, x, y + h - 2, BAR_FG_PTS, BAR_FG));
|
||||
if (x + 2 < w - 5 && y + 2 < h - 5) {
|
||||
if (x + 2 < w - 5 && y + 2 < h - 5)
|
||||
g2.drawRect(x + 2, y + 2, w - 5, h - 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void paintProgressBarBorder(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) {
|
||||
}
|
||||
}
|
||||
|
||||
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/painters/TextFieldPainter.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/painters/TextFieldPainter.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ComboBoxUI.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ComboBoxUI.java
Normal file → Executable file
7
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ListCellRender.java
Normal file → Executable file
7
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ListCellRender.java
Normal file → Executable file
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.lookandfeel.ui;
|
||||
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
@@ -33,8 +33,9 @@ import java.awt.Component;
|
||||
*/
|
||||
public class ListCellRender extends DefaultListCellRenderer {
|
||||
|
||||
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
setOpaque(true);
|
||||
setBackground(Color.magenta);
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ScrollBarUI.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ScrollBarUI.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ScrollButton.java
Normal file → Executable file
0
MetroLookAndFeel/src/main/java/org/jackhuang/hellominecraft/lookandfeel/ui/ScrollButton.java
Normal file → Executable file
Reference in New Issue
Block a user