有没有更优雅的方式去做我在下面做的事情?也就是说,是否有比轮询和睡眠,轮询和睡眠更优雅的方式,等等,以便知道何时Runnable.run()通过调用方法invokeLater()?
private int myMethod() {
final WaitForEventQueue waitForQueue = new WaitForEventQueue();
EventQueue.invokeLater(waitForQueue);
while (!waitForQueue.done) {
try {
Thread.sleep(10);
} catch (InterruptedException ignore) {
}
}
return 0;
}
private class WaitForEventQueue implements Runnable {
private boolean done;
public void run() {
// Let all Swing text stuff finish.
done = true;
}
}
Run Code Online (Sandbox Code Playgroud) 在JTabbedPane上,如何为选定和未选定状态设置选项卡标题的颜色?
我正在使用正则表达式来尝试匹配INI文件中的节块.我正在使用正则表达式手册中给出的配方,但它似乎对我不起作用.
这是我正在使用的代码:
final BufferedReader in = new BufferedReader(
new FileReader(file));
String s;
String s2 = "";
while((s = in.readLine())!= null)
s2 += s + System.getProperty("line.separator");
in.close();
final String regex = "^\\[[^\\]\r\n]+](?:\r?\n(?:[^\r\n].*)?)*";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
String sectionBlock = null;
final Matcher regexMatcher = pattern.matcher(s2);
if (regexMatcher.find()) {
sectionBlock = regexMatcher.group();
}
Run Code Online (Sandbox Code Playgroud)
以下是我的输入文件的内容:
[Section 2]
Key 2.0=Value 2.0
Key 2.2=Value 2.2
Key 2.1=Value 2.1
[Section 1]
Key 1.1=Value 1.1
Key 1.0=Value 1.0
Key 1.2=Value 1.2
[Section 0] …Run Code Online (Sandbox Code Playgroud) 像这样将比例设置为负数是否有意义?
BigDecimal result;
.
.
.
result = result.setScale(-1, RoundingMode.HALF_UP)
Run Code Online (Sandbox Code Playgroud)
如果你这样做会发生什么?
我有以下代码。这是 shipFlagCountryDF 的架构
root
|-- flagcountry: string (nullable = true)
|-- max(count): long (nullable = true)
|-- min(count): long (nullable = true)
|-- avg(count): double (nullable = true)
|-- stddev_samp(count,0,0): double (nullable = false)
Run Code Online (Sandbox Code Playgroud)
以下是一些示例行:
+--------------------+----------+----------+----------+----------------------+
| flagcountry|max(count)|min(count)|avg(count)|stddev_samp(count,0,0)|
+--------------------+----------+----------+----------+----------------------+
| Cyprus| 65| 46| 55.0| 9.40744386111339|
| Luxembourg| 3| 1| 2.5| 0.9999999999999999|
| Niue| 5| 3| 4.4| 0.8944271909999159|
| Palestine| 2| 1| 1.25| 0.49999999999999994|
| Norway| 30| 18| 23.4| 5.683308895353129|
| Mongolia| 21| 15| 17.6| 2.302172886644268|
| Dominica| 1| 1| 1.0| …Run Code Online (Sandbox Code Playgroud) 我在 GitHub 上有一个现有的存储库。它是私人的,所以很抱歉我无法在这个问题中提供 URL。我的文件夹中有一些代码。该文件夹没有 .git 文件夹。我想将此文件夹与远程存储库“连接”或“链接”。我正在使用这个文档。
到步骤 4 为止一切都很顺利。然后我收到此错误:
% git init -b main
error: unknown switch `b'
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
java ×4
bigdecimal ×1
eventqueue ×1
git ×1
github ×1
ini ×1
json ×1
jtabbedpane ×1
polling ×1
regex ×1
scala ×1
sleep ×1
swing ×1