JLayeredPane允许使用JLayeredPane.add(Component,Integer)将多个组件堆叠在一起.较高"层"中的组件显示在较低"层"中的组件顶部.
Container.add(Component,int)提供了一种类似的机制,其中具有较低索引的组件显示在具有较高索引的组件之上.
请注意,第一种机制使用Integer,第二种机制使用int.另外,一个在低值之上呈现高值,而另一个则相反.不要混两个:)
我的问题是:当Container已经提供相同的机制时,使用JLayeredPane有什么意义?一层组件比另一层好吗?
我的项目.hg目录是40MB.如果我hg push --verbose --debug是一个空的远程存储库,我看到它发送了数百MB.额外的开销来自哪里?
更新:hg bundle -a生成35MB文件.这是我看到的输出的精简版本:
pushing to https://jace.googlecode.com/hg/
using https://jace.googlecode.com/hg/
sending between command
using auth.default.* for authentication
jace.googlecode.com certificate successfully verified
sending capabilities command
using auth.default.* for authentication
capabilities: branchmap lookup unbundle=HG10UN,HG10UGZ,HG10BZ changegroupsubset
sending heads command
using auth.default.* for authentication
searching for changes
common changesets up to 71818a195bf5
sending branchmap command
[...]
bundling: <filenames>
sending unbundle command
sending xxx bytes
[...]
sending: xxx/xxx kb
Run Code Online (Sandbox Code Playgroud) 我正在启动一个包含单个webapp的嵌入式Jetty实例.webapp在启动时启动.我想知道如何检测Webapp的contextInitialized是否会引发异常.
当webapp抛出异常时,Server.start()不会,server.isRunning()返回true.有没有办法让我从容器外听取webapp异常?
鉴于:
public class Test
{
public static void main(String[] args)
{
int nThreads = 1;
Executor e = Executors.newFixedThreadPool(nThreads);
CompletableFuture.runAsync(() ->
{
System.out.println("Task 1. Thread: " + Thread.currentThread().getId());
}, e).thenComposeAsync((Void unused) ->
{
return CompletableFuture.runAsync(() ->
{
System.out.println("Task 2. Thread: " + Thread.currentThread().getId());
}, e);
}, e).join();
System.out.println("finished");
}
}
Run Code Online (Sandbox Code Playgroud)
我期待一个执行程序线程运行任务1,然后执行任务2.相反,代码挂起,如果nThreads小于2.
Future完成,但目前尚不清楚原因.总之,请帮助我了解thenComposeAsync()实际工作原理.Javadoc看起来像是为机器人而不是人类而写的:)
关注如何在线程池中使用MDC?如何使用MDC ForkJoinPool?具体来说,我怎么能ForkJoinTask在执行任务之前设置一个这样的MDC值?
我定义了一个具有多个目标的 Maven 插件。目前用户运行我的插件如下:
<plugin>
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<version>someVersion</version>
<executions>
<execution>
<goals>
<goal>myGoal</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但我见过其他插件,比如maven-compiler-pluginFlyway,不需要指定execution:https : //flywaydb.org/getstarted/java
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>5.2.4</version>
<configuration>
<url>jdbc:h2:file:./target/foobar</url>
<user>sa</user>
<locations>
<location>classpath:db/migration</location>
</locations>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当用户排除<executions>块时,如何指定默认运行的目标?
我如何定义新类型java.nio.channels.SelectableChannel(比如串口)?
如何使用Ant任务将Java类名转换为文件路径?
例如,给定一个包含foo.bar.Duck我想要出去的属性foo/bar/Duck.class.
我试图(和失败)中的条款来实现这个<pathconvert>和<regexpmapper>.
根据http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.10,客户端必须在 POST、PUT 或 DELETE 请求后使与 URL 关联的缓存无效。
是否可以指示 Web 浏览器使任意 URL 的缓存失效,而不向其发出 HTTP 请求?
例如:
PUT /companies/Nintendo创建一家名为“任天堂”的新公司GET /companies列出所有公司GET /companies. 浏览器不会自动执行此操作,因为两者在不同的 URL 上运行。该Cache-Control机制是否不适合这种情况?我应该使用no-cachewithETag来代替吗?对于这种情况,最佳做法是什么?
no-cache我知道下次可以通过,GET /companies但这需要应用程序跟踪 URL 失效,而不是将责任推给浏览器。意思是,我想在步骤 1 之后使 URL 失效,而不是必须保留此信息并在步骤 2 中应用它。有什么想法吗?
鉴于:
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.function.Function;
class Testcase
{
@FunctionalInterface
public interface MyBuilder1<R>
{
R apply(String message);
}
@FunctionalInterface
public interface MyBuilder2<R>
{
R apply(Object message);
}
public static void main(String[] args) throws Throwable
{
Class<?> clazz = IllegalArgumentException.class;
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle mh = lookup.findConstructor(clazz, MethodType.methodType(void.class, String.class));
MethodHandle myFunctionConstructor = LambdaMetafactory.metafactory(
lookup,
"apply",
MethodType.methodType(Function.class),
mh.type().erase(),
mh,
mh.type()
).getTarget();
MethodHandle myBuilderConstructor1 = LambdaMetafactory.metafactory(
lookup,
"apply",
MethodType.methodType(MyBuilder1.class),
mh.type().erase(),
mh,
mh.type()
).getTarget();
MethodHandle myBuilderConstructor2 = LambdaMetafactory.metafactory( …Run Code Online (Sandbox Code Playgroud)