• R/O
  • SSH

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

最古版。新版→https://osdn.jp/users/tacticsrealize/pf/ChlorophyllUploader/wiki/FrontPage


Commit MetaInfo

修订版1cf0aedfcb141906f76f9bae13db90e53798f6c0 (tree)
时间2015-07-14 18:35:18
作者MirrgieRiana Kurilab
CommiterMirrgieRiana Kurilab

Log Message

FrameSelectPort: new時の処理が重いのを解決。キャンセル時のイベント追加

更改概述

差异

diff -r 53aa2d32a7eb -r 1cf0aedfcb14 src_main/ants/chlorofilsender/FrameSelectPort.java
--- a/src_main/ants/chlorofilsender/FrameSelectPort.java Tue Jul 14 18:34:20 2015 +0900
+++ b/src_main/ants/chlorofilsender/FrameSelectPort.java Tue Jul 14 18:35:18 2015 +0900
@@ -10,7 +10,6 @@
1010 import java.util.function.Consumer;
1111
1212 import javax.swing.JButton;
13-import javax.swing.JFrame;
1413 import javax.swing.JList;
1514 import javax.swing.JScrollPane;
1615
@@ -23,14 +22,16 @@
2322
2423 private JList<NamedSlot<CommPortIdentifier>> list;
2524 private Consumer<CommPortIdentifier> consumer;
25+ private boolean isCanceled = true;
2626
27- public FrameSelectPort(Consumer<CommPortIdentifier> consumer)
27+ public FrameSelectPort(
28+ Consumer<CommPortIdentifier> consumer,
29+ Runnable onCanceled)
2830 {
2931 super("ポート選択");
3032
3133 this.consumer = consumer;
3234
33- JFrame frame = this;
3435 {
3536
3637 list = new JList<>();
@@ -93,14 +94,22 @@
9394 GroupLayoutUtil groupLayoutUtil = new GroupLayoutUtil();
9495
9596 groupLayoutUtil.setComponents(compos);
96- groupLayoutUtil.setGroupLayoutTo(frame.getContentPane());
97+ groupLayoutUtil.setGroupLayoutTo(getContentPane());
9798
9899 groupLayoutUtil.getGroupLayout().setAutoCreateContainerGaps(true);
99100 groupLayoutUtil.getGroupLayout().setAutoCreateGaps(true);
100101 }
101102 }
102103
103- redraw(list);
104+ onOpened(e -> {
105+ redraw(list);
106+ });
107+
108+ onClosed(e -> {
109+ if (isCanceled) {
110+ onCanceled.run();
111+ }
112+ });
104113
105114 prepareFrame();
106115 }
@@ -110,6 +119,7 @@
110119 NamedSlot<CommPortIdentifier> portIdentifier = list.getSelectedValue();
111120 if (portIdentifier != null) {
112121 if (portIdentifier.get() != null) {
122+ isCanceled = false;
113123 dispose();
114124 consumer.accept(portIdentifier.get());
115125 }
diff -r 53aa2d32a7eb -r 1cf0aedfcb14 src_main/ants/chlorofilsender/Main.java
--- a/src_main/ants/chlorofilsender/Main.java Tue Jul 14 18:34:20 2015 +0900
+++ b/src_main/ants/chlorofilsender/Main.java Tue Jul 14 18:35:18 2015 +0900
@@ -20,7 +20,11 @@
2020 {
2121 System.loadLibrary("rxtxSerial");
2222 HSwing.setWindowsLookAndFeel();
23- new FrameSelectPort(Main::main2).setVisible(true);
23+ new FrameSelectPort(Main::main2, () -> {
24+
25+ // TODO
26+
27+ }).setVisible(true);
2428 }
2529
2630 private static void main2(CommPortIdentifier portIdentifier)