Fixed swing syncing bugs

This commit is contained in:
huanghongxun
2015-12-09 23:24:24 +08:00
parent a436e10d93
commit 52c43bde06
9 changed files with 82 additions and 45 deletions

View File

@@ -219,8 +219,8 @@ implements ProgressProviderListener, Runnable, DoingDoneListener<Task> {
@Override
public void run() {
SwingUtilities.invokeLater(this::dispose);
suc = true;
this.dispose();
HMCLog.log("Tasks are finished.");
}

View File

@@ -31,7 +31,7 @@ public final class CollectionUtils {
public static <T> ArrayList<T> map(Collection<T> coll, Predicate<T> p) {
ArrayList<T> newColl = new ArrayList<>();
Observable.from(coll).filter(p).subscribe(newColl::add);
Observable.from(coll).filter(t -> p.apply(t)).subscribe(t -> newColl.add(t));
return newColl;
}

View File

@@ -161,7 +161,7 @@ public class SwingUtils {
char[] chars = longString.toCharArray();
FontMetrics fontMetrics = jLabel1.getFontMetrics(jLabel1.getFont());
for (int beginIndex = 0, limit = 1;; limit++) {
if (beginIndex + limit >= chars.length)
if (beginIndex + limit > chars.length)
break;
if (fontMetrics.charsWidth(chars, beginIndex, limit) < jLabel1.getWidth()) {
if (beginIndex + limit < chars.length)