used findbugs
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
@@ -89,14 +90,16 @@ public final class Launcher {
|
||||
});
|
||||
try {
|
||||
File logFile = new File("hmclmc.log");
|
||||
if (!logFile.exists())
|
||||
logFile.createNewFile();
|
||||
FileOutputStream tc = new FileOutputStream(logFile);
|
||||
DoubleOutputStream out = new DoubleOutputStream(tc, System.out);
|
||||
System.setOut(new LauncherPrintStream(out));
|
||||
DoubleOutputStream err = new DoubleOutputStream(tc, System.err);
|
||||
System.setErr(new LauncherPrintStream(err));
|
||||
} catch (Exception e) {
|
||||
if (!logFile.exists() && !logFile.createNewFile())
|
||||
println("Failed to create log file");
|
||||
else {
|
||||
FileOutputStream tc = new FileOutputStream(logFile);
|
||||
DoubleOutputStream out = new DoubleOutputStream(tc, System.out);
|
||||
System.setOut(new LauncherPrintStream(out));
|
||||
DoubleOutputStream err = new DoubleOutputStream(tc, System.err);
|
||||
System.setErr(new LauncherPrintStream(err));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
println("Failed to add log file appender.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
@@ -56,7 +57,7 @@ public class ModInfo implements Comparable<ModInfo> {
|
||||
|
||||
@Override
|
||||
public int compareTo(ModInfo o) {
|
||||
return getFileName().toLowerCase().compareTo(o.getFileName().toLowerCase());
|
||||
return getFileName().compareToIgnoreCase(o.getFileName());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -102,12 +103,13 @@ public class ModInfo implements Comparable<ModInfo> {
|
||||
return name.endsWith(".zip") || name.endsWith(".jar") || name.endsWith("litemod");
|
||||
}
|
||||
|
||||
private static final Type TYPE = new TypeToken<List<ModInfo>>() {
|
||||
}.getType();
|
||||
|
||||
private static ModInfo getForgeModInfo(File f, ZipFile jar, ZipEntry entry) throws IOException {
|
||||
ModInfo i = new ModInfo();
|
||||
i.location = f;
|
||||
List<ModInfo> m = C.GSON.fromJson(new InputStreamReader(jar.getInputStream(entry)),
|
||||
new TypeToken<List<ModInfo>>() {
|
||||
}.getType());
|
||||
List<ModInfo> m = C.GSON.fromJson(new InputStreamReader(jar.getInputStream(entry)), TYPE);
|
||||
if (m != null && m.size() > 0) {
|
||||
i = m.get(0);
|
||||
i.location = f;
|
||||
@@ -116,8 +118,7 @@ public class ModInfo implements Comparable<ModInfo> {
|
||||
}
|
||||
|
||||
private static ModInfo getLiteLoaderModInfo(File f, ZipFile jar, ZipEntry entry) throws IOException {
|
||||
ModInfo m = C.GSON.fromJson(new InputStreamReader(jar.getInputStream(entry)),
|
||||
ModInfo.class);
|
||||
ModInfo m = C.GSON.fromJson(new InputStreamReader(jar.getInputStream(entry)), ModInfo.class);
|
||||
if (m == null)
|
||||
m = new ModInfo();
|
||||
m.location = f;
|
||||
|
||||
@@ -29,8 +29,8 @@ import java.util.Set;
|
||||
public class AssetsIndex {
|
||||
|
||||
public static final String DEFAULT_ASSET_NAME = "legacy";
|
||||
private Map<String, AssetsObject> objects;
|
||||
private boolean virtual;
|
||||
public Map<String, AssetsObject> objects;
|
||||
public boolean virtual;
|
||||
|
||||
public AssetsIndex() {
|
||||
this.objects = new LinkedHashMap();
|
||||
|
||||
@@ -97,7 +97,7 @@ public abstract class IAssetsHandler {
|
||||
|
||||
@Override
|
||||
public void executeTask() {
|
||||
if (assetsDownloadURLs == null)
|
||||
if (assetsDownloadURLs == null || assetsLocalNames == null)
|
||||
throw new IllegalStateException(C.i18n("assets.not_refreshed"));
|
||||
int max = assetsDownloadURLs.size();
|
||||
al = new ArrayList<>();
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
|
||||
@@ -46,9 +47,16 @@ public class GameProfile {
|
||||
return id != null && StrUtils.isNotBlank(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 29 * hash + Objects.hashCode(this.id);
|
||||
hash = 29 * hash + Objects.hashCode(this.name);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
System.out.println("hello?");
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
|
||||
@@ -51,6 +51,7 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
for (Map<String, String> propertyMap : list) {
|
||||
String name = propertyMap.get("name");
|
||||
String value = propertyMap.get("value");
|
||||
put(name, new Property(name, value));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
HMCLog.warn("Failed to deserialize properties", t);
|
||||
@@ -76,6 +77,7 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
JsonObject object = (JsonObject) element;
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
String value = object.getAsJsonPrimitive("value").getAsString();
|
||||
result.put(name, new Property(name, value));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -101,10 +103,10 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
@Override
|
||||
public JsonElement serialize(PropertyMap src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject result = new JsonObject();
|
||||
for (String key : src.keySet()) {
|
||||
for (PropertyMap.Entry<String, Property> entry : src.entrySet()) {
|
||||
JsonArray values = new JsonArray();
|
||||
values.add(new JsonPrimitive(src.get(key).value));
|
||||
result.add(key, values);
|
||||
values.add(new JsonPrimitive(entry.getValue().value));
|
||||
result.add(entry.getKey(), values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
*/
|
||||
public class LiteLoaderVersionList extends InstallerVersionList {
|
||||
|
||||
private static LiteLoaderVersionList instance;
|
||||
private static volatile LiteLoaderVersionList instance = null;
|
||||
|
||||
public static LiteLoaderVersionList getInstance() {
|
||||
if (instance == null)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.jackhuang.hellominecraft.launcher.core.install.optifine.bmcl;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -50,6 +51,9 @@ public class OptiFineBMCLVersionList extends InstallerVersionList {
|
||||
public Map<String, List<InstallerVersion>> versionMap;
|
||||
public List<InstallerVersion> versions;
|
||||
|
||||
private static final Type TYPE = new TypeToken<ArrayList<OptiFineVersion>>() {
|
||||
}.getType();
|
||||
|
||||
@Override
|
||||
public void refreshList(String[] needed) throws Exception {
|
||||
String s = NetUtils.get("http://bmclapi.bangbang93.com/optifine/versionlist");
|
||||
@@ -59,8 +63,7 @@ public class OptiFineBMCLVersionList extends InstallerVersionList {
|
||||
|
||||
if (s == null)
|
||||
return;
|
||||
root = C.GSON.fromJson(s, new TypeToken<ArrayList<OptiFineVersion>>() {
|
||||
}.getType());
|
||||
root = C.GSON.fromJson(s, TYPE);
|
||||
for (OptiFineVersion v : root) {
|
||||
v.mirror = v.mirror.replace("http://optifine.net/http://optifine.net/", "http://optifine.net/");
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public class GameLauncher {
|
||||
if (StrUtils.isNotBlank(options.getPrecalledCommand())) {
|
||||
Process p = Runtime.getRuntime().exec(options.getPrecalledCommand());
|
||||
try {
|
||||
if (p != null && p.isAlive())
|
||||
if (p.isAlive())
|
||||
p.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
HMCLog.warn("Failed to invoke precalled command", ex);
|
||||
|
||||
@@ -144,32 +144,26 @@ public final class ModpackManager {
|
||||
* < String, Boolean, Boolean >: Folder/File name, Is Directory,
|
||||
* Return 0: non blocked, 1: non shown, 2: suggested, checked.
|
||||
*/
|
||||
public static final BiFunction<String, Boolean, Integer> MODPACK_PREDICATE = new BiFunction<String, Boolean, Integer>() {
|
||||
@Override
|
||||
public Integer apply(String x, Boolean y) {
|
||||
if (ModpackManager.MODPACK_BLACK_LIST_PREDICATE.apply(x, y))
|
||||
return 1;
|
||||
if (ModpackManager.MODPACK_SUGGESTED_BLACK_LIST_PREDICATE.apply(x, y))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
public static final BiFunction<String, Boolean, Integer> MODPACK_PREDICATE = (String x, Boolean y) -> {
|
||||
if (ModpackManager.MODPACK_BLACK_LIST_PREDICATE.apply(x, y))
|
||||
return 1;
|
||||
if (ModpackManager.MODPACK_SUGGESTED_BLACK_LIST_PREDICATE.apply(x, y))
|
||||
return 2;
|
||||
return 0;
|
||||
};
|
||||
|
||||
public static final BiFunction<String, Boolean, Boolean> MODPACK_BLACK_LIST_PREDICATE = modpackPredicateMaker(MODPACK_BLACK_LIST);
|
||||
public static final BiFunction<String, Boolean, Boolean> MODPACK_SUGGESTED_BLACK_LIST_PREDICATE = modpackPredicateMaker(MODPACK_SUGGESTED_BLACK_LIST);
|
||||
|
||||
private static BiFunction<String, Boolean, Boolean> modpackPredicateMaker(final List<String> l) {
|
||||
return new BiFunction<String, Boolean, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(String x, Boolean y) {
|
||||
for (String s : l)
|
||||
if (y) {
|
||||
if (x.startsWith(s + "/"))
|
||||
return true;
|
||||
} else if (x.equals(s))
|
||||
return (String x, Boolean y) -> {
|
||||
for (String s : l)
|
||||
if (y) {
|
||||
if (x.startsWith(s + "/"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
} else if (x.equals(s))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -193,17 +187,14 @@ public final class ModpackManager {
|
||||
ZipEngine zip = null;
|
||||
try {
|
||||
zip = new ZipEngine(output);
|
||||
zip.putDirectory(provider.getRunDirectory(version), new BiFunction<String, Boolean, String>() {
|
||||
@Override
|
||||
public String apply(String x, Boolean y) {
|
||||
for (String s : b)
|
||||
if (y) {
|
||||
if (x.startsWith(s + "/"))
|
||||
return null;
|
||||
} else if (x.equals(s))
|
||||
zip.putDirectory(provider.getRunDirectory(version), (String x, Boolean y) -> {
|
||||
for (String s : b)
|
||||
if (y) {
|
||||
if (x.startsWith(s + "/"))
|
||||
return null;
|
||||
return "minecraft/" + x;
|
||||
}
|
||||
} else if (x.equals(s))
|
||||
return null;
|
||||
return "minecraft/" + x;
|
||||
});
|
||||
|
||||
MinecraftVersion mv = provider.getVersionById(version).resolve(provider);
|
||||
|
||||
@@ -59,5 +59,7 @@ public abstract class IMinecraftLibrary implements Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Object clone();
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,12 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new MinecraftLibrary(rules, url, checksums, natives, name, extract);
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
MinecraftLibrary ml = (MinecraftLibrary) super.clone();
|
||||
ml.extract = (Extract) ml.extract.clone();
|
||||
ml.natives = (Natives) ml.natives.clone();
|
||||
ml.rules = (ArrayList<Rules>) ml.rules.clone();
|
||||
return ml;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,11 +73,11 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
else
|
||||
for (Rules r : rules)
|
||||
if (r.action.equals("disallow")) {
|
||||
if (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString()))) {
|
||||
if (r.os != null && (StrUtils.isBlank(r.os.getName()) || r.os.getName().equalsIgnoreCase(OS.os().toString()))) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
} else if (r.os == null || (r.os != null && (StrUtils.isBlank(r.os.name) || r.os.name.equalsIgnoreCase(OS.os().toString()))))
|
||||
} else if (r.os == null || (r.os != null && (StrUtils.isBlank(r.os.getName()) || r.os.getName().equalsIgnoreCase(OS.os().toString()))))
|
||||
flag = true;
|
||||
return flag;
|
||||
}
|
||||
@@ -83,13 +87,14 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
}
|
||||
|
||||
private String getNative() {
|
||||
OS os = OS.os();
|
||||
if (os == OS.WINDOWS)
|
||||
switch (OS.os()) {
|
||||
case WINDOWS:
|
||||
return formatArch(natives.windows);
|
||||
else if (os == OS.OSX)
|
||||
case OSX:
|
||||
return formatArch(natives.osx);
|
||||
else
|
||||
default:
|
||||
return formatArch(natives.linux);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,11 +26,7 @@ public class Natives implements Cloneable {
|
||||
public String windows, osx, linux;
|
||||
|
||||
@Override
|
||||
protected Object clone() {
|
||||
Natives n = new Natives();
|
||||
n.windows = windows;
|
||||
n.osx = osx;
|
||||
n.linux = linux;
|
||||
return n;
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,21 @@ package org.jackhuang.hellominecraft.launcher.core.version;
|
||||
*/
|
||||
public class OS {
|
||||
|
||||
public String version, name;
|
||||
private String version, name;
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jackhuang.hellominecraft.launcher.ui;
|
||||
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.swing.JFileChooser;
|
||||
@@ -45,7 +44,6 @@ import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.util.Event;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.JavaProcessMonitor;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.util.ui.LogWindow;
|
||||
@@ -86,9 +84,9 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
pnlMore.setBackground(GraphicsUtils.getWebColorWithAlpha("FFFFFF7F"));
|
||||
pnlMore.setOpaque(true);
|
||||
|
||||
prepareAuths();
|
||||
|
||||
Settings.getInstance().authChangedEvent.register(onAuthChanged);
|
||||
|
||||
prepareAuths();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +462,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
void runGame() {
|
||||
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
|
||||
getProfile().launcher().genLaunchCode(value -> {
|
||||
value.successEvent.register(new LaunchFinisher());
|
||||
value.successEvent.register(launchFinisher);
|
||||
value.successEvent.register(this::prepareAuths);
|
||||
}, this::failed, txtPassword.getText());
|
||||
}
|
||||
@@ -472,7 +470,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
void makeLaunchScript() {
|
||||
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
|
||||
getProfile().launcher().genLaunchCode(value -> {
|
||||
value.successEvent.register(new LaunchScriptFinisher());
|
||||
value.successEvent.register(launchScriptFinisher);
|
||||
value.successEvent.register(this::prepareAuths);
|
||||
}, this::failed, txtPassword.getText());
|
||||
}
|
||||
@@ -483,68 +481,59 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
}
|
||||
|
||||
public class LaunchFinisher implements Event<List<String>> {
|
||||
|
||||
@Override
|
||||
public boolean call(Object sender, List<String> str) {
|
||||
final GameLauncher obj = (GameLauncher) sender;
|
||||
obj.launchEvent.register(p -> {
|
||||
if ((LauncherVisibility) obj.getTag() == LauncherVisibility.CLOSE && !LogWindow.INSTANCE.isVisible()) {
|
||||
final Event<List<String>> launchFinisher = (sender, str) -> {
|
||||
final GameLauncher obj = (GameLauncher) sender;
|
||||
obj.launchEvent.register(p -> {
|
||||
if ((LauncherVisibility) obj.getTag() == LauncherVisibility.CLOSE && !LogWindow.INSTANCE.isVisible()) {
|
||||
HMCLog.log("Without the option of keeping the launcher visible, this application will exit and will NOT catch game logs, but you can turn on \"Debug Mode\".");
|
||||
System.exit(0);
|
||||
} else if ((LauncherVisibility) obj.getTag() == LauncherVisibility.KEEP)
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
else {
|
||||
if (LogWindow.INSTANCE.isVisible())
|
||||
LogWindow.INSTANCE.setExit(() -> true);
|
||||
MainFrame.INSTANCE.dispose();
|
||||
}
|
||||
JavaProcessMonitor jpm = new JavaProcessMonitor(p);
|
||||
jpm.applicationExitedAbnormallyEvent.register(t -> {
|
||||
HMCLog.err("The game exited abnormally, exit code: " + t);
|
||||
MessageBox.Show(C.i18n("launch.exited_abnormally") + ", exit code: " + t);
|
||||
});
|
||||
jpm.jvmLaunchFailedEvent.register(t -> {
|
||||
HMCLog.err("Cannot create jvm, exit code: " + t);
|
||||
MessageBox.Show(C.i18n("launch.cannot_create_jvm") + ", exit code: " + t);
|
||||
});
|
||||
jpm.stoppedEvent.register(() -> {
|
||||
if ((LauncherVisibility) obj.getTag() != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible()) {
|
||||
HMCLog.log("Without the option of keeping the launcher visible, this application will exit and will NOT catch game logs, but you can turn on \"Debug Mode\".");
|
||||
System.exit(0);
|
||||
} else if ((LauncherVisibility) obj.getTag() == LauncherVisibility.KEEP)
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
else {
|
||||
if (LogWindow.INSTANCE.isVisible())
|
||||
LogWindow.INSTANCE.setExit(() -> true);
|
||||
MainFrame.INSTANCE.dispose();
|
||||
}
|
||||
JavaProcessMonitor jpm = new JavaProcessMonitor(p);
|
||||
jpm.applicationExitedAbnormallyEvent.register(t -> {
|
||||
HMCLog.err("The game exited abnormally, exit code: " + t);
|
||||
MessageBox.Show(C.i18n("launch.exited_abnormally") + ", exit code: " + t);
|
||||
});
|
||||
jpm.jvmLaunchFailedEvent.register(t -> {
|
||||
HMCLog.err("Cannot create jvm, exit code: " + t);
|
||||
MessageBox.Show(C.i18n("launch.cannot_create_jvm") + ", exit code: " + t);
|
||||
});
|
||||
jpm.stoppedEvent.register(() -> {
|
||||
if ((LauncherVisibility) obj.getTag() != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible()) {
|
||||
HMCLog.log("Without the option of keeping the launcher visible, this application will exit and will NOT catch game logs, but you can turn on \"Debug Mode\".");
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
jpm.start();
|
||||
});
|
||||
try {
|
||||
obj.launch(str);
|
||||
} catch (IOException e) {
|
||||
failed(C.i18n("launch.failed_creating_process") + "\n" + e.getMessage());
|
||||
HMCLog.err("Failed to launch when creating a new process.", e);
|
||||
}
|
||||
return true;
|
||||
jpm.start();
|
||||
});
|
||||
try {
|
||||
obj.launch(str);
|
||||
} catch (IOException e) {
|
||||
failed(C.i18n("launch.failed_creating_process") + "\n" + e.getMessage());
|
||||
HMCLog.err("Failed to launch when creating a new process.", e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
public class LaunchScriptFinisher implements Event<List<String>> {
|
||||
|
||||
@Override
|
||||
public boolean call(Object sender, List str) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
String s = JOptionPane.showInputDialog(C.i18n("mainwindow.enter_script_name"));
|
||||
if (s != null)
|
||||
MessageBox.Show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher) sender).makeLauncher(s, str).getAbsolutePath());
|
||||
flag = true;
|
||||
} catch (IOException ex) {
|
||||
MessageBox.Show(C.i18n("mainwindow.make_launch_script_failed"));
|
||||
HMCLog.err("Failed to create script file.", ex);
|
||||
}
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
return flag;
|
||||
final Event<List<String>> launchScriptFinisher = (sender, str) -> {
|
||||
boolean flag = false;
|
||||
try {
|
||||
String s = JOptionPane.showInputDialog(C.i18n("mainwindow.enter_script_name"));
|
||||
if (s != null)
|
||||
MessageBox.Show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher) sender).makeLauncher(s, str).getAbsolutePath());
|
||||
flag = true;
|
||||
} catch (IOException ex) {
|
||||
MessageBox.Show(C.i18n("mainwindow.make_launch_script_failed"));
|
||||
HMCLog.err("Failed to create script file.", ex);
|
||||
}
|
||||
|
||||
}
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
return flag;
|
||||
};
|
||||
|
||||
public Profile getProfile() {
|
||||
return Settings.getProfile((String) cboProfiles.getSelectedItem());
|
||||
|
||||
@@ -130,8 +130,12 @@ public final class NewProfileWindow extends javax.swing.JDialog {
|
||||
Profile newProfile = new Profile(Settings.getProfile(cboProfiles.getSelectedItem().toString()));
|
||||
newProfile.setName(txtNewProfileName.getText());
|
||||
Settings.trySetProfile(newProfile);
|
||||
break;
|
||||
case 27:
|
||||
this.dispose();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}//GEN-LAST:event_txtNewProfileNameKeyTyped
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
HMCLog.err("Failed to execute newer version application", t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
package org.jackhuang.hellominecraft.launcher.util.upgrade;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.Event;
|
||||
import org.jackhuang.hellominecraft.util.Event;
|
||||
import org.jackhuang.hellominecraft.util.VersionNumber;
|
||||
import org.jackhuang.hellominecraft.util.VersionNumber;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,6 @@ package org.jackhuang.hellominecraft.launcher.util.upgrade;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
package org.jackhuang.hellominecraft.util;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.lang.SupportedLocales;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -72,9 +72,7 @@ public class Pair<K, V> implements Map.Entry<K, V> {
|
||||
final Pair<?, ?> other = (Pair<?, ?>) obj;
|
||||
if (!Objects.equals(this.key, other.key))
|
||||
return false;
|
||||
if (!Objects.equals(this.value, other.value))
|
||||
return false;
|
||||
return true;
|
||||
return Objects.equals(this.value, other.value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ public class Base64 {
|
||||
val |= (0xFF & (int) data[i + 2]);
|
||||
quad = true;
|
||||
}
|
||||
out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)];
|
||||
out[index + 3] = ALPHABET[(quad ? (val & 0x3F) : 64)];
|
||||
val >>= 6;
|
||||
out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
|
||||
out[index + 2] = ALPHABET[(trip ? (val & 0x3F) : 64)];
|
||||
val >>= 6;
|
||||
out[index + 1] = alphabet[val & 0x3F];
|
||||
out[index + 1] = ALPHABET[val & 0x3F];
|
||||
val >>= 6;
|
||||
out[index + 0] = alphabet[val & 0x3F];
|
||||
out[index + 0] = ALPHABET[val & 0x3F];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class Base64 {
|
||||
int accum = 0;
|
||||
int index = 0;
|
||||
for (int ix = 0; ix < data.length; ix++) {
|
||||
int value = codes[data[ix] & 0xFF];
|
||||
int value = CODES[data[ix] & 0xFF];
|
||||
if (value >= 0) {
|
||||
accum <<= 6;
|
||||
shift += 6;
|
||||
@@ -86,20 +86,20 @@ public class Base64 {
|
||||
throw new Error("miscalculated data length!");
|
||||
return out;
|
||||
}
|
||||
private static final char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
private static final char[] ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
.toCharArray();
|
||||
private static final byte[] codes = new byte[256];
|
||||
private static final byte[] CODES = new byte[256];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 256; i++)
|
||||
codes[i] = -1;
|
||||
CODES[i] = -1;
|
||||
for (int i = 'A'; i <= 'Z'; i++)
|
||||
codes[i] = (byte) (i - 'A');
|
||||
CODES[i] = (byte) (i - 'A');
|
||||
for (int i = 'a'; i <= 'z'; i++)
|
||||
codes[i] = (byte) (26 + i - 'a');
|
||||
CODES[i] = (byte) (26 + i - 'a');
|
||||
for (int i = '0'; i <= '9'; i++)
|
||||
codes[i] = (byte) (52 + i - '0');
|
||||
codes['+'] = 62;
|
||||
codes['/'] = 63;
|
||||
CODES[i] = (byte) (52 + i - '0');
|
||||
CODES['+'] = 62;
|
||||
CODES['/'] = 63;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,34 +25,34 @@ import org.jackhuang.hellominecraft.util.logging.logger.Logger;
|
||||
*/
|
||||
public class HMCLog {
|
||||
|
||||
private static final Logger logger = new Logger("Hello Minecraft!");
|
||||
private static final Logger LOGGER = new Logger("Hello Minecraft!");
|
||||
|
||||
public static void log(String message) {
|
||||
logger.info(message);
|
||||
LOGGER.info(message);
|
||||
}
|
||||
|
||||
public static void warn(String message) {
|
||||
logger.warn(message);
|
||||
LOGGER.warn(message);
|
||||
}
|
||||
|
||||
public static void debug(String message) {
|
||||
logger.debug(message);
|
||||
LOGGER.debug(message);
|
||||
}
|
||||
|
||||
public static void warn(String msg, Throwable t) {
|
||||
logger.warn(msg, t);
|
||||
LOGGER.warn(msg, t);
|
||||
}
|
||||
|
||||
public static void debug(String msg, Throwable t) {
|
||||
logger.debug(msg, t);
|
||||
LOGGER.debug(msg, t);
|
||||
}
|
||||
|
||||
public static void err(String msg) {
|
||||
logger.error(msg);
|
||||
LOGGER.error(msg);
|
||||
}
|
||||
|
||||
public static void err(String msg, Throwable t) {
|
||||
logger.error(msg, t);
|
||||
LOGGER.error(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,18 +60,29 @@ public enum Level {
|
||||
if (m.find()) {
|
||||
// New style logs from log4j
|
||||
String levelStr = m.group("level");
|
||||
if ("INFO".equals(levelStr))
|
||||
level = INFO;
|
||||
else if ("WARN".equals(levelStr))
|
||||
level = WARN;
|
||||
else if ("ERROR".equals(levelStr))
|
||||
level = ERROR;
|
||||
else if ("FATAL".equals(levelStr))
|
||||
level = FATAL;
|
||||
else if ("TRACE".equals(levelStr))
|
||||
level = TRACE;
|
||||
else if ("DEBUG".equals(levelStr))
|
||||
level = DEBUG;
|
||||
if (null != levelStr)
|
||||
switch (levelStr) {
|
||||
case "INFO":
|
||||
level = INFO;
|
||||
break;
|
||||
case "WARN":
|
||||
level = WARN;
|
||||
break;
|
||||
case "ERROR":
|
||||
level = ERROR;
|
||||
break;
|
||||
case "FATAL":
|
||||
level = FATAL;
|
||||
break;
|
||||
case "TRACE":
|
||||
level = TRACE;
|
||||
break;
|
||||
case "DEBUG":
|
||||
level = DEBUG;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]")
|
||||
|| line.contains("[FINER]") || line.contains("[FINEST]"))
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Logger extends AbstractLogger {
|
||||
this.config = new PrivateConfig(this.config, level);
|
||||
}
|
||||
|
||||
public Level getLevel() {
|
||||
public synchronized Level getLevel() {
|
||||
return this.config.level;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.io.InputStreamReader;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.StringTokenizer;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
|
||||
/**
|
||||
* @author huangyuhui
|
||||
@@ -85,7 +84,7 @@ public enum OS {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(file)));
|
||||
long[] result = new long[4];
|
||||
String str = null;
|
||||
String str;
|
||||
StringTokenizer token;
|
||||
while ((str = br.readLine()) != null) {
|
||||
token = new StringTokenizer(str);
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.OutputStream;
|
||||
import java.util.Timer;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.util.logging.Level;
|
||||
import org.jackhuang.hellominecraft.util.ui.LogWindow;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -21,9 +21,7 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
|
||||
public class CheckBoxTreeLabel extends JLabel {
|
||||
|
||||
@@ -198,23 +198,20 @@ public class NavButtonManager implements ActionListener {
|
||||
final boolean enableNext = nextStep != null && canContinue && problem == null && !isDeferredResult;
|
||||
final boolean enablePrevious = wizard.getPreviousStep() != null && !isDeferredResult;
|
||||
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
next.setEnabled(enableNext);
|
||||
prev.setEnabled(enablePrevious);
|
||||
finish.setEnabled(enableFinish);
|
||||
JRootPane root = next.getRootPane();
|
||||
if (root != null)
|
||||
if (next.isEnabled())
|
||||
root.setDefaultButton(next);
|
||||
else if (finish.isEnabled())
|
||||
root.setDefaultButton(finish);
|
||||
else if (prev.isEnabled())
|
||||
root.setDefaultButton(prev);
|
||||
else
|
||||
root.setDefaultButton(null);
|
||||
}
|
||||
final Runnable runnable = () -> {
|
||||
next.setEnabled(enableNext);
|
||||
prev.setEnabled(enablePrevious);
|
||||
finish.setEnabled(enableFinish);
|
||||
JRootPane root = next.getRootPane();
|
||||
if (root != null)
|
||||
if (next.isEnabled())
|
||||
root.setDefaultButton(next);
|
||||
else if (finish.isEnabled())
|
||||
root.setDefaultButton(finish);
|
||||
else if (prev.isEnabled())
|
||||
root.setDefaultButton(prev);
|
||||
else
|
||||
root.setDefaultButton(null);
|
||||
};
|
||||
|
||||
if (EventQueue.isDispatchThread())
|
||||
@@ -265,21 +262,18 @@ public class NavButtonManager implements ActionListener {
|
||||
}
|
||||
|
||||
void deferredResultFailed(final boolean canGoBack) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!canGoBack)
|
||||
getCancel().setText(getCloseString());
|
||||
getPrev().setEnabled(true);
|
||||
getNext().setEnabled(false);
|
||||
getCancel().setEnabled(true);
|
||||
getFinish().setEnabled(false);
|
||||
final Runnable runnable = () -> {
|
||||
if (!canGoBack)
|
||||
getCancel().setText(getCloseString());
|
||||
getPrev().setEnabled(true);
|
||||
getNext().setEnabled(false);
|
||||
getCancel().setEnabled(true);
|
||||
getFinish().setEnabled(false);
|
||||
|
||||
if (NAME_CLOSE.equals(deferredStatus)) {
|
||||
// no action
|
||||
} else
|
||||
deferredStatus = DEFERRED_FAILED + deferredStatus;
|
||||
}
|
||||
if (NAME_CLOSE.equals(deferredStatus)) {
|
||||
// no action
|
||||
} else
|
||||
deferredStatus = DEFERRED_FAILED + deferredStatus;
|
||||
};
|
||||
if (EventQueue.isDispatchThread())
|
||||
runnable.run();
|
||||
@@ -601,25 +595,22 @@ public class NavButtonManager implements ActionListener {
|
||||
}
|
||||
|
||||
public void navigabilityChanged(final Wizard wizard) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (wizard.isBusy()) {
|
||||
next.setEnabled(false);
|
||||
prev.setEnabled(false);
|
||||
finish.setEnabled(false);
|
||||
cancel.setEnabled(false);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
wasBusy = true;
|
||||
return;
|
||||
} else if (wasBusy) {
|
||||
cancel.setEnabled(true);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
configureNavigationButtons(wizard, prev, next, finish);
|
||||
|
||||
parent.updateProblem();
|
||||
final Runnable runnable = () -> {
|
||||
if (wizard.isBusy()) {
|
||||
next.setEnabled(false);
|
||||
prev.setEnabled(false);
|
||||
finish.setEnabled(false);
|
||||
cancel.setEnabled(false);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
wasBusy = true;
|
||||
return;
|
||||
} else if (wasBusy) {
|
||||
cancel.setEnabled(true);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
configureNavigationButtons(wizard, prev, next, finish);
|
||||
|
||||
parent.updateProblem();
|
||||
};
|
||||
if (EventQueue.isDispatchThread())
|
||||
runnable.run();
|
||||
|
||||
@@ -150,14 +150,10 @@ final class Util {
|
||||
try {
|
||||
m.setAccessible(true);
|
||||
result = (String) m.invoke(null, (Object[]) null);
|
||||
} catch (InvocationTargetException ite) {
|
||||
} catch (InvocationTargetException | IllegalAccessException ite) {
|
||||
throw new IllegalArgumentException("Could not invoke "
|
||||
+ "public static String " + clazz.getName()
|
||||
+ ".getDescription() - make sure it exists.");
|
||||
} catch (IllegalAccessException iae) {
|
||||
throw new IllegalArgumentException("Could not invoke "
|
||||
+ "public static String " + clazz.getName()
|
||||
+ ".getDescription() - make sure it exists.");
|
||||
+ ".getDescription() - make sure it exists.", ite);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,7 @@ public abstract class WizardPanelNavResult extends DeferredWizardResult {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof WPNRimmediate && ((WPNRimmediate) o).value == value)
|
||||
return true;
|
||||
return false;
|
||||
return o instanceof WPNRimmediate && ((WPNRimmediate) o).value == value;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.install.cauldron;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
@@ -29,6 +31,6 @@ public class ForgeVersion {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForgeVersion{" + "vername=" + vername + ", ver=" + ver + ", mcver=" + mcver + ", releasetime=" + releasetime + ", changelog=" + changelog + ", installer=" + installer + ", javadoc=" + javadoc + ", src=" + src + ", universal=" + universal + ", userdev=" + userdev + ", typeint=" + typeint + '}';
|
||||
return "ForgeVersion{" + "vername=" + vername + ", ver=" + ver + ", mcver=" + mcver + ", releasetime=" + releasetime + ", changelog=" + changelog + ", installer=" + Arrays.toString(installer) + ", javadoc=" + Arrays.toString(javadoc) + ", src=" + Arrays.toString(src) + ", universal=" + universal + ", userdev=" + userdev + ", typeint=" + typeint + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,7 @@ public class ServerChecker {
|
||||
}
|
||||
if (file.getEntry("org/bukkit/craftbukkit/Main.class") != null)
|
||||
return true;
|
||||
if (file.getEntry("net/minecraft/server/MinecraftServer.class") != null)
|
||||
return true;
|
||||
return false;
|
||||
return file.getEntry("net/minecraft/server/MinecraftServer.class") != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class PlayerList<T extends BasePlayer> {
|
||||
|
||||
public void initByText(String s) {
|
||||
String[] lines = s.split("\n");
|
||||
op = new HashSet<T>();
|
||||
op = new HashSet<>();
|
||||
for (String l : lines) {
|
||||
if (l.startsWith("#"))
|
||||
continue;
|
||||
@@ -86,17 +86,7 @@ public abstract class PlayerList<T extends BasePlayer> {
|
||||
}
|
||||
|
||||
public void initByBoth(File txt, File json) {
|
||||
HashSet<T> player = new HashSet<T>();
|
||||
/*op = null;
|
||||
if(json.exists()) {
|
||||
try {
|
||||
initByJson(FileUtils.readFileToStringIgnoreFileNotFound(json));
|
||||
if(op != null)
|
||||
player.addAll(op);
|
||||
} catch(IOException e) {
|
||||
HMCLLog.warn("Failed to load playerlist by json", e);
|
||||
}
|
||||
}*/
|
||||
HashSet<T> player = new HashSet<>();
|
||||
op = null;
|
||||
if (txt.exists())
|
||||
try {
|
||||
|
||||
@@ -18,11 +18,9 @@ package org.jackhuang.hellominecraft.lookandfeel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
|
||||
@@ -42,22 +42,22 @@ import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
||||
public class ButtonPainter extends SynthPainter {
|
||||
|
||||
private static final String DEFAULT_NORMAL = "D5D5D5";
|
||||
private static final Color[] DEFAULT_NORMAL_FG = new Color[]{
|
||||
private static final Color[] DEFAULT_NORMAL_FG = new Color[] {
|
||||
GraphicsUtils.getWebColor(DEFAULT_NORMAL),
|
||||
GraphicsUtils.getWebColor(DEFAULT_NORMAL)
|
||||
};
|
||||
private static final String DEFAULT_PRELIGHT = "A9A9A9";
|
||||
private static final Color[] DEFAULT_PRELIGHT_FG = new Color[]{
|
||||
private static final Color[] DEFAULT_PRELIGHT_FG = new Color[] {
|
||||
GraphicsUtils.getWebColor(DEFAULT_PRELIGHT),
|
||||
GraphicsUtils.getWebColor(DEFAULT_PRELIGHT)
|
||||
};
|
||||
private static final String DEFAULT_ACTIVE = "222222";
|
||||
private static final Color[] DEFAULT_ACTIVE_FG = new Color[]{
|
||||
private static final Color[] DEFAULT_ACTIVE_FG = new Color[] {
|
||||
GraphicsUtils.getWebColor(DEFAULT_ACTIVE),
|
||||
GraphicsUtils.getWebColor(DEFAULT_ACTIVE)
|
||||
};
|
||||
|
||||
private static final Color[] DISABLED_BG = new Color[]{
|
||||
private static final Color[] DISABLED_BG = new Color[] {
|
||||
GraphicsUtils.getWebColor("E3EFE9"),
|
||||
GraphicsUtils.getMidWebColor("E3EFE9", "DFE2E6"),
|
||||
GraphicsUtils.getWebColor("DFE2E6"),
|
||||
@@ -68,7 +68,7 @@ public class ButtonPainter extends SynthPainter {
|
||||
GraphicsUtils.getWebColor("D8DBE1"),
|
||||
GraphicsUtils.getWebColor("DADDE3")
|
||||
};
|
||||
private static final Color[] DISABLED_FG = new Color[]{
|
||||
private static final Color[] DISABLED_FG = new Color[] {
|
||||
GraphicsUtils.getWebColor("C9CCD2"),
|
||||
GraphicsUtils.getWebColor("C9CCD2"),
|
||||
GraphicsUtils.getWebColor("BCBFC5"),
|
||||
@@ -79,18 +79,12 @@ public class ButtonPainter extends SynthPainter {
|
||||
if (System.currentTimeMillis() > c.lastDrawTime) {
|
||||
c.lastDrawTime = System.currentTimeMillis();
|
||||
c.drawPercent += add;
|
||||
if (c.drawPercent > 100 && add > 0) {
|
||||
if (c.drawPercent > 100 && add > 0)
|
||||
c.drawPercent = 100;
|
||||
} else if (c.drawPercent < 0 && add < 0) {
|
||||
else if (c.drawPercent < 0 && add < 0)
|
||||
c.drawPercent = 0;
|
||||
} else {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
c.updateUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
SwingUtilities.invokeLater(c::updateUI);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -103,98 +97,84 @@ public class ButtonPainter extends SynthPainter {
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
Color[] fg, bg;
|
||||
if ((context.getComponentState() & SynthConstants.DEFAULT) != 0) {
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0) {
|
||||
if ((context.getComponentState() & SynthConstants.DEFAULT) != 0)
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0)
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[]{c.activeFg, c.activeFg};
|
||||
bg = new Color[]{c.activeFg, c.activeFg};
|
||||
fg = new Color[] { c.activeFg, c.activeFg };
|
||||
bg = new Color[] { c.activeFg, c.activeFg };
|
||||
} else {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
}
|
||||
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
return;
|
||||
//fg = DISABLED_FG;
|
||||
//bg = DISABLED_BG;
|
||||
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
|
||||
else if ((context.getComponentState() & SynthConstants.DISABLED) != 0)
|
||||
return; //fg = DISABLED_FG;
|
||||
//bg = DISABLED_BG;
|
||||
else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0)
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
final ConstomButton c = (ConstomButton) context.getComponent();
|
||||
if (!processCustomButton(c, 1)) {
|
||||
if (!processCustomButton(c, 1))
|
||||
return;
|
||||
}
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
} else {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
}
|
||||
else if (context.getComponent() instanceof ConstomButton) {
|
||||
final ConstomButton c = (ConstomButton) context.getComponent();
|
||||
if (!processCustomButton(c, -1))
|
||||
return;
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
} else {
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
final ConstomButton c = (ConstomButton) context.getComponent();
|
||||
if (!processCustomButton(c, -1)) {
|
||||
return;
|
||||
}
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
} else {
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0) {
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[]{c.activeFg, c.activeFg};
|
||||
bg = new Color[]{c.activeFg, c.activeFg};
|
||||
} else {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
}
|
||||
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
else if ((context.getComponentState() & SynthConstants.PRESSED) != 0)
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[] { c.activeFg, c.activeFg };
|
||||
bg = new Color[] { c.activeFg, c.activeFg };
|
||||
} else {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
}
|
||||
else if ((context.getComponentState() & SynthConstants.DISABLED) != 0)
|
||||
return; //fg = DISABLED_FG;
|
||||
//bg = DISABLED_BG;
|
||||
else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0)
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
final ConstomButton c = (ConstomButton) context.getComponent();
|
||||
if (!processCustomButton(c, 1))
|
||||
return;
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
} else if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[] { c.prelightFg, c.prelightFg };
|
||||
bg = new Color[] { c.prelightBg, c.prelightBg };
|
||||
} else {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
}
|
||||
else if (context.getComponent() instanceof ConstomButton) {
|
||||
final ConstomButton c = (ConstomButton) context.getComponent();
|
||||
if (!processCustomButton(c, -1))
|
||||
return;
|
||||
//fg = DISABLED_FG;
|
||||
//bg = DISABLED_BG;
|
||||
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
final ConstomButton c = (ConstomButton) context.getComponent();
|
||||
if (!processCustomButton(c, 1)) {
|
||||
return;
|
||||
}
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
} else {
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[]{c.prelightFg, c.prelightFg};
|
||||
bg = new Color[]{c.prelightBg, c.prelightBg};
|
||||
} else {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
final ConstomButton c = (ConstomButton) context.getComponent();
|
||||
if (!processCustomButton(c, -1)) {
|
||||
return;
|
||||
}
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
}
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
/*w = w - 2;
|
||||
h = h - 2;
|
||||
@@ -222,7 +202,7 @@ public class ButtonPainter extends SynthPainter {
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
Color[] fg, bg;
|
||||
if ((context.getComponentState() & SynthConstants.DEFAULT) != 0) {
|
||||
if ((context.getComponentState() & SynthConstants.DEFAULT) != 0)
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
@@ -236,20 +216,18 @@ public class ButtonPainter extends SynthPainter {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
else if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
fg = DISABLED_FG;
|
||||
bg = DISABLED_BG;
|
||||
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
} else {
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
fg = DISABLED_FG;
|
||||
bg = DISABLED_BG;
|
||||
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
g2.setColor(fg[0]);
|
||||
Rectangle2D fgshape = new Rectangle2D.Float(x, y, w, h);
|
||||
|
||||
@@ -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.painter;
|
||||
|
||||
import javax.swing.plaf.synth.SynthContext;
|
||||
@@ -37,12 +37,13 @@ public class TextFieldPainter extends SynthPainter {
|
||||
|
||||
private boolean fill = true;
|
||||
|
||||
private static final Color disabled = GraphicsUtils.getWebColor("F3F3F3"),
|
||||
normal = GraphicsUtils.getWebColor("CCCCCC"),
|
||||
focused = GraphicsUtils.getWebColor("000000"),
|
||||
over = GraphicsUtils.getWebColor("7F7F7F");
|
||||
private static final Color DISABLED = GraphicsUtils.getWebColor("F3F3F3"),
|
||||
NORMAL = GraphicsUtils.getWebColor("CCCCCC"),
|
||||
FOCUSED = GraphicsUtils.getWebColor("000000"),
|
||||
OVER = GraphicsUtils.getWebColor("7F7F7F");
|
||||
|
||||
public TextFieldPainter() {}
|
||||
public TextFieldPainter() {
|
||||
}
|
||||
|
||||
public TextFieldPainter(boolean fill) {
|
||||
this.fill = fill;
|
||||
@@ -55,16 +56,15 @@ public class TextFieldPainter extends SynthPainter {
|
||||
g.setColor(Color.WHITE);
|
||||
g.fillRect(x, y, w, h);
|
||||
}
|
||||
Color color = null;
|
||||
if((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
|
||||
color = over;
|
||||
} else if((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
color = disabled;
|
||||
} else if((context.getComponentState() & SynthConstants.FOCUSED) != 0) {
|
||||
color = focused;
|
||||
} else {
|
||||
color = normal;
|
||||
}
|
||||
Color color;
|
||||
if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0)
|
||||
color = OVER;
|
||||
else if ((context.getComponentState() & SynthConstants.DISABLED) != 0)
|
||||
color = DISABLED;
|
||||
else if ((context.getComponentState() & SynthConstants.FOCUSED) != 0)
|
||||
color = FOCUSED;
|
||||
else
|
||||
color = NORMAL;
|
||||
g.setColor(color);
|
||||
g.drawLine(x, y, x + w, y);
|
||||
g.drawLine(x, y, x, y + w);
|
||||
|
||||
@@ -27,10 +27,10 @@ import java.awt.event.MouseEvent;
|
||||
*/
|
||||
public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
|
||||
private static final BufferedImage combo_normal = loadImage("combo_normal.png");
|
||||
private static final BufferedImage combo_over = loadImage("combo_over.png");
|
||||
private static final BufferedImage combo_pressed = loadImage("combo_pressed.png");
|
||||
private static final BufferedImage combo_disabled = loadImage("combo_disabled.png");
|
||||
private static final BufferedImage COMBO_NORMAL = loadImage("combo_normal.png");
|
||||
private static final BufferedImage COMBO_OVER = loadImage("combo_over.png");
|
||||
private static final BufferedImage COMBO_PRESSED = loadImage("combo_pressed.png");
|
||||
private static final BufferedImage COMBO_DISABLED = loadImage("combo_disabled.png");
|
||||
private static final Dimension BTN_SIZE = new Dimension(17, 20);
|
||||
private final Dimension btnSize = new Dimension(BTN_SIZE);
|
||||
|
||||
@@ -39,6 +39,7 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
* method that all UI deligates must have.
|
||||
*
|
||||
* @param c The component that the UI is for
|
||||
*
|
||||
* @return a new instance of NimbusComboBoxUI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
@@ -66,13 +67,13 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
/**
|
||||
* The minumum size is the size of the display area plus insets plus the
|
||||
* button.
|
||||
*
|
||||
* @return the size yeah.
|
||||
*/
|
||||
@Override
|
||||
public Dimension getMinimumSize(JComponent c) {
|
||||
if (!isMinimumSizeDirty) {
|
||||
if (!isMinimumSizeDirty)
|
||||
return new Dimension(cachedMinimumSize);
|
||||
}
|
||||
Dimension size = getDisplaySize();
|
||||
Insets insets = getInsets();
|
||||
btnSize.height = size.height = Math.max(size.height, BTN_SIZE.height);
|
||||
@@ -92,17 +93,16 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (comboBox.isEditable()) {
|
||||
BufferedImage img = combo_normal;
|
||||
if (mouseDown) {
|
||||
img = combo_pressed;
|
||||
} else if (!comboBox.isEnabled()) {
|
||||
img = combo_normal;
|
||||
} else if (mouseInside) {
|
||||
img = combo_over;
|
||||
}
|
||||
BufferedImage img = COMBO_NORMAL;
|
||||
if (mouseDown)
|
||||
img = COMBO_PRESSED;
|
||||
else if (!comboBox.isEnabled())
|
||||
img = COMBO_NORMAL;
|
||||
else if (mouseInside)
|
||||
img = COMBO_OVER;
|
||||
g.drawImage(img,
|
||||
0, 0, getWidth(), getHeight(),
|
||||
0, 0, img.getWidth(), img.getHeight(), comboBox);
|
||||
0, 0, getWidth(), getHeight(),
|
||||
0, 0, img.getWidth(), img.getHeight(), comboBox);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -125,32 +125,30 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
((JComponent) renderer).setForeground(comboBox.getForeground());
|
||||
}
|
||||
paintCurrentValue(g, rectangleForCurrentValue(), false);
|
||||
if (renderer instanceof JComponent) {
|
||||
if (renderer instanceof JComponent)
|
||||
((JComponent) renderer).setOpaque(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus) {
|
||||
if (!comboBox.isEditable()) {
|
||||
BufferedImage img = combo_normal;
|
||||
if (!comboBox.isEnabled()) {
|
||||
img = combo_disabled;
|
||||
} else if (mouseDown) {
|
||||
img = combo_pressed;
|
||||
} else if (mouseInside) {
|
||||
img = combo_over;
|
||||
}
|
||||
BufferedImage img = COMBO_NORMAL;
|
||||
if (!comboBox.isEnabled())
|
||||
img = COMBO_DISABLED;
|
||||
else if (mouseDown)
|
||||
img = COMBO_PRESSED;
|
||||
else if (mouseInside)
|
||||
img = COMBO_OVER;
|
||||
g.drawImage(img,
|
||||
bounds.x, bounds.y, bounds.x + 4, bounds.y + bounds.height,
|
||||
0, 0, 1, 26, comboBox);
|
||||
bounds.x, bounds.y, bounds.x + 4, bounds.y + bounds.height,
|
||||
0, 0, 1, 26, comboBox);
|
||||
g.drawImage(img,
|
||||
bounds.x + 1, bounds.y, bounds.x + bounds.width - 25, bounds.y + bounds.height,
|
||||
1, 0, 3, 26, comboBox);
|
||||
bounds.x + 1, bounds.y, bounds.x + bounds.width - 25, bounds.y + bounds.height,
|
||||
1, 0, 3, 26, comboBox);
|
||||
g.drawImage(img,
|
||||
bounds.x + bounds.width - 25, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
|
||||
4, 0, 29, 26, comboBox);
|
||||
bounds.x + bounds.width - 25, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
|
||||
4, 0, 29, 26, comboBox);
|
||||
} else {
|
||||
/*g.setColor(Color.WHITE);
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width - btnSize.width, bounds.height - 1);
|
||||
@@ -194,9 +192,8 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
if (comboBox.isEditable()) {
|
||||
if (e.getComponent() == arrowButton) {
|
||||
if (e.getComponent() == arrowButton)
|
||||
mouseInside = true;
|
||||
}
|
||||
} else {
|
||||
mouseInside = true;
|
||||
comboBox.repaint();
|
||||
@@ -206,9 +203,8 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
if (comboBox.isEditable()) {
|
||||
if (e.getComponent() == arrowButton) {
|
||||
if (e.getComponent() == arrowButton)
|
||||
mouseInside = false;
|
||||
}
|
||||
} else {
|
||||
mouseInside = false;
|
||||
comboBox.repaint();
|
||||
@@ -218,9 +214,8 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (comboBox.isEditable()) {
|
||||
if (e.getComponent() == arrowButton) {
|
||||
if (e.getComponent() == arrowButton)
|
||||
mouseDown = true;
|
||||
}
|
||||
} else {
|
||||
mouseDown = true;
|
||||
comboBox.repaint();
|
||||
@@ -230,9 +225,8 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (comboBox.isEditable()) {
|
||||
if (e.getComponent() == arrowButton) {
|
||||
if (e.getComponent() == arrowButton)
|
||||
mouseDown = false;
|
||||
}
|
||||
} else {
|
||||
mouseDown = false;
|
||||
comboBox.repaint();
|
||||
@@ -269,16 +263,14 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
Insets insets = getInsets();
|
||||
Rectangle cvb;
|
||||
|
||||
if (arrowButton != null) {
|
||||
if (cb.getComponentOrientation().isLeftToRight()) {
|
||||
if (arrowButton != null)
|
||||
if (cb.getComponentOrientation().isLeftToRight())
|
||||
arrowButton.setBounds(width - (insets.right + btnSize.width),
|
||||
insets.top,
|
||||
btnSize.width, btnSize.height);
|
||||
} else {
|
||||
insets.top,
|
||||
btnSize.width, btnSize.height);
|
||||
else
|
||||
arrowButton.setBounds(insets.left, insets.top,
|
||||
btnSize.width, btnSize.height);
|
||||
}
|
||||
}
|
||||
btnSize.width, btnSize.height);
|
||||
if (editor != null) {
|
||||
cvb = rectangleForCurrentValue();
|
||||
editor.setBounds(cvb.x, cvb.y, cvb.width, cvb.height);
|
||||
|
||||
Reference in New Issue
Block a user