4
4
# swing-stream-utils
5
5
Utils for working with Java Swing components via Java 8 streams.
6
6
7
- Functionality of the library is provided by the static methods of class ` org.swingk.utils .stream.SwingStreamUtils` .
7
+ Functionality of the library is provided by the static methods of class ` io.github.swingk .stream.SwingStreamUtils` .
8
8
The methods may be divided into two categories: those which allow to iterate (or stream) over data items of Swing components
9
9
(e.g. ` SwingStreamUtils.stream ` ) and collectors which allow to create Swing components from a stream data (e.g. ` SwingStreamUtils.toTable ` ).
10
10
11
11
Example 1 (count how many times ` JTable ` cell value "London" appears in the selected cells of column 3):
12
12
``` java
13
- import org.swingk.utils .stream.SwingStreamUtils ;
14
- import org.swingk.utils .stream.TableCellData ;
13
+ import io.github.swingk .stream.SwingStreamUtils ;
14
+ import io.github.swingk .stream.TableCellData ;
15
15
16
16
JTable table = ... ;
17
17
long count = SwingStreamUtils . stream(table)
@@ -35,9 +35,9 @@ Example 2 (create table with 'Name' and 'Size' columns from a list of `File` obj
35
35
import java.io.File ;
36
36
import java.util.List ;
37
37
38
- import org.swingk.utils .stream.ColumnDef ;
38
+ import io.github.swingk .stream.ColumnDef ;
39
39
40
- import static org.swingk.utils .stream.SwingStreamUtils.toTable ;
40
+ import static io.github.swingk .stream.SwingStreamUtils.toTable ;
41
41
42
42
List<File > files = ... ;
43
43
/* FileTable is a subclass of JTable */
@@ -51,9 +51,9 @@ Example 3 (create a table with specific model class):
51
51
import java.io.File ;
52
52
import java.util.List ;
53
53
54
- import org.swingk.utils .stream.ColumnDef ;
54
+ import io.github.swingk .stream.ColumnDef ;
55
55
56
- import static org.swingk.utils .stream.SwingStreamUtils.toTable ;
56
+ import static io.github.swingk .stream.SwingStreamUtils.toTable ;
57
57
58
58
List<File > files = ... ;
59
59
FileTable table = files. stream()
@@ -71,9 +71,9 @@ Example:
71
71
import java.io.File ;
72
72
import java.util.function.Supplier ;
73
73
74
- import org.swingk.utils .stream.ColumnDef ;
74
+ import io.github.swingk .stream.ColumnDef ;
75
75
76
- import static org.swingk.utils .stream.SwingStreamUtils.toTable ;
76
+ import static io.github.swingk .stream.SwingStreamUtils.toTable ;
77
77
78
78
enum Column implements Supplier<ColumnDef<File > > {
79
79
NAME (new ColumnDef<> (" Name" , File :: getName, 100 , String . class)),
@@ -110,7 +110,7 @@ import java.io.File;
110
110
import java.util.List ;
111
111
import javax.swing.JComboBox ;
112
112
113
- import static org.swingk.utils .stream.SwingStreamUtils.toComboBox ;
113
+ import static io.github.swingk .stream.SwingStreamUtils.toComboBox ;
114
114
115
115
List<File > files = ... ;
116
116
JComboBox<String > = files. stream()
@@ -125,7 +125,7 @@ import java.util.stream.Collectors;
125
125
import java.awt.Component ;
126
126
import java.awt.Container ;
127
127
128
- import static org.swingk.utils .stream.SwingStreamUtils.streamDescendants ;
128
+ import static io.github.swingk .stream.SwingStreamUtils.streamDescendants ;
129
129
130
130
Container container = ... ;
131
131
List<Component > visibleDescendants = streamDescendants(container)
@@ -138,7 +138,7 @@ Example 6 (find all unselected combo box items which start with a letter "z"):
138
138
``` java
139
139
140
140
141
- import org.swingk.utils .stream.SwingStreamUtils ;
141
+ import io.github.swingk .stream.SwingStreamUtils ;
142
142
143
143
JComboBox<String > comboBox = ... ;
144
144
List<String > visibleDescendants = SwingStreamUtils . stream(comboBox)
@@ -153,9 +153,9 @@ import java.util.Optional;
153
153
import javax.swing.JTree ;
154
154
import javax.swing.tree.TreeNode ;
155
155
156
- import org.swingk.utils .stream.KTreePath ;
157
- import org.swingk.utils .stream.SwingStreamUtils ;
158
- import org.swingk.utils .stream.TreeTraversalType ;
156
+ import io.github.swingk .stream.KTreePath ;
157
+ import io.github.swingk .stream.SwingStreamUtils ;
158
+ import io.github.swingk .stream.TreeTraversalType ;
159
159
160
160
JTree tree = ... ;
161
161
TreeNode node = ... ;
@@ -168,9 +168,9 @@ It is worth mentioning that in most cases (check JavaDoc) the utility ensures th
168
168
``` java
169
169
import java.util.List ;
170
170
...
171
- import org.swingk.utils .stream.ColumnDef ;
171
+ import io.github.swingk .stream.ColumnDef ;
172
172
173
- import static org.swingk.utils .stream.SwingStreamUtils.toTable ;
173
+ import static io.github.swingk .stream.SwingStreamUtils.toTable ;
174
174
175
175
// may be not EDT (for example, Swing worker background thread)
176
176
List<Server > servers = ... ;
@@ -184,9 +184,9 @@ JTable table = servers.parallelStream() // OK to use parallel stream!
184
184
```java
185
185
import java.util. List ;
186
186
...
187
- import org.swingk.utils .stream. ColumnDef ;
187
+ import io.github.swingk .stream. ColumnDef ;
188
188
189
- import static org.swingk.utils .stream. SwingStreamUtils. toTableModel;
189
+ import static io.github.swingk .stream. SwingStreamUtils. toTableModel;
190
190
191
191
// may be executed on any thread
192
192
List<User > users = ... ;
0 commit comments