我正在编写一个应用程序,它有一个JLayeredPane(称之为图层),包含两个不同层的JPanel.我覆盖了底部JPanel的paintComponent方法(称之为grid_panel),因此它绘制了一个网格,并在顶部绘制了一个paintComponent方法(称之为circuit_panel),因此它绘制了一个电路.
以下是结构摘要:
layers -
|-circuit_panel (on top)
|-grid_panel (at bottom)
Run Code Online (Sandbox Code Playgroud)
我希望grid_panel保持静态,即不进行任何重绘(除了初始的重绘),因为它不会改变.
麻烦的是,每当我调用circuit_panel.repaint()时,grid_panel也会被重新绘制! 这绝对不是有效的.
我认为这是由于JLayeredPane的热切绘画行为.有没有办法在JLayeredPane中禁用此功能?
如果你有兴趣看到上述效果,我写了一个小的演示程序:
public class Test2 extends JFrame {
public Test2() {
JLayeredPane layers = new JLayeredPane();
layers.setPreferredSize(new Dimension(600, 400));
MyPanel1 myPanel1 = new MyPanel1();
MyPanel2 myPanel2 = new MyPanel2();
myPanel1.setSize(600, 400);
myPanel2.setSize(600, 400);
myPanel1.setOpaque(false);
myPanel2.setOpaque(false);
myPanel2.addMouseListener(new MyMouseListener(myPanel2));
layers.add(myPanel1, new Integer(100)); // At bottom
layers.add(myPanel2, new Integer(101)); // On top
this.getContentPane().add(layers, BorderLayout.CENTER);
this.setSize(600, 400);
}
class MyPanel1 extends JPanel {
Color getRandomColor() {
int r = (int) …Run Code Online (Sandbox Code Playgroud) 我正在使用Cisco VPN(在Windows 7 Ultimate 64bit上)连接到我的公司网络.当我查看svn存储库时,我在下载一些文件后2或3秒不断收到此错误.
问题发生在TortoiseSVN 1.5.9和SlikSubversion 1.6.17上
我注意到下载像java或xml这样的文本文件经常导致这个问题,但下载压缩文件(jar等)很好.
我的SVN或VPN设置有误,还是网络问题?如何让SVN记录更多细节?
PS:我的SVN中没有使用任何SSL代理.
我正在使用Twitter Finagle编写服务器端程序.我不使用完整的Twitter服务器堆栈,只是启用异步处理的部分(所以Future,Function等).我希望Future对象有超时,所以我写了这个:
Future<String> future = Future.value(some_input).flatMap(time_consuming_function1);
future.get(Duration.apply(5, TimeUnit.SECONDS));
Run Code Online (Sandbox Code Playgroud)
time_consuming_function1运行时间超过5秒.但是future5秒后没有超时,它等到time_consuming_function1完成.
我认为这是因为future.get(timeout)只关心future创建需要多长时间,而不是整个运营链.有没有办法超时整个运营链?
我创建了一个非常简单的Maven项目,该项目构建了一个.war文件。Maven版本3.2.3,Java版本1.7.0_67。pom.xml文件在此要点中。
如果我运行mvn clean install,则项目构建良好。但是,如果我首先使用mvn dependency:resolve和下载所有依赖项mvn dependency:resolve-plugins,然后运行mvn -o install以离线构建,则会收到类似以下的错误。
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ docker-restaesy-1 ---
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-project:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-core:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-artifact:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-settings:jar:2.2.1 is missing, no dependency information available …Run Code Online (Sandbox Code Playgroud) 我创建了一个小项目来测试Docker集群.基本上,cluster.sh脚本启动三个相同的容器,并使用管道bridge1在主机上配置bridge (eth1)并向每个容器添加NIC().
如果我登录其中一个容器,我可以使用arping其他容器:
# 172.17.99.1
root@d01eb56fce52:/# arping 172.17.99.2
ARPING 172.17.99.2
42 bytes from aa:b3:98:92:0b:08 (172.17.99.2): index=0 time=1.001 sec
42 bytes from aa:b3:98:92:0b:08 (172.17.99.2): index=1 time=1.001 sec
42 bytes from aa:b3:98:92:0b:08 (172.17.99.2): index=2 time=1.001 sec
42 bytes from aa:b3:98:92:0b:08 (172.17.99.2): index=3 time=1.001 sec
^C
--- 172.17.99.2 statistics ---
5 packets transmitted, 4 packets received, 20% unanswered (0 extra)
Run Code Online (Sandbox Code Playgroud)
所以似乎数据包可以通过bridge1.
但问题是我不能ping等容器,我也不能经由像任何工具发送的任何IP数据包telnet或netcat.
相反,桥docker0和NIC eth0 …
在阅读了有关Java HttpURLConnection的所有类型的文档后,我仍然感到很困惑,因为它有什么样的集合以及它如何实现连接.
例如,以下代码
URL url = new URL(someUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
OutputStream os = connection.getOutputStream();
InputStream is = connection.getInputStream();
/** Write something to os and flush */
/** Read from is */
os.close();
is.close();
connection.disconnect();
Run Code Online (Sandbox Code Playgroud)
两者都做os,并is需要被刷新,关闭底层套接字是可重复使用的?
将connection.disconnect()关闭底层套接字(从而使其无法使用)?会keep-alive影响这种行为吗?
如果我使用不同的URL对象,但使用相同的URL,那么connection从它们创建的s 是否会共享底层套接字?当URL的主机部分相同但路径不同时怎么样?
什么时候汇集连接会被破坏?
什么是控制池大小的系统属性?
此外,如果您还可以将Android版本与Java进行比较,那就太棒了.
谢谢
我们都知道依赖树对于解决传递依赖冲突至关重要.同样的情况也是如此dependencyManagement,但我找不到以类似的方式为它打印依赖关系树的方法dependencies.
是否有插件或其他可以帮助的东西?
Maven版本:3.2.3
编辑
对于认为此问题与其他问题重复的人,请考虑:
另一个问题是关于依赖管理的插件管理.
另一个问题没有说明生成依赖树.
我正在使用AspectJ来拦截java.net.Socket调用。
我创建了一个非常简单的方面
after(): call(* java.net.Socket.connect(..)) {
System.out.println("Connect intercepted!");
}
Run Code Online (Sandbox Code Playgroud)
和aop.xml
<aspectj>
<aspects>
<aspect name="com.iggroup.lightstreamer.nwtp.SocketExceptionLoggingAspect"/>
</aspects>
<weaver options="-Xlint:ignore -Xset:weaveJavaxPackages=true -Xset:weaveJavaPackages=true">
</weaver>
</aspectj>
Run Code Online (Sandbox Code Playgroud)
当调用堆栈是这样的时,我可以看到控制台输出:
java.lang.Exception
at com.iggroup.lightstreamer.nwtp.SocketExceptionLoggingAspect.ajc$after$com_iggroup_lightstreamer_nwtp_SocketExceptionLoggingAspect$2$6e16217c(SocketExceptionLoggingAspect.aj:39)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:337)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:91)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:596)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475)
at com.iggroup.lightstreamer.nwtp.users.SsoRestClientImpl.lambda$0(SsoRestClientImpl.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
但是,当调用栈是这样时,什么都不会注销:
Caused by: java.net.ConnectException: Connection refused: connect …Run Code Online (Sandbox Code Playgroud) 想象一下,我创建了一个这样的数组:
IFS="|" read -ra ARR <<< "zero|one|||four"
Run Code Online (Sandbox Code Playgroud)
现在
echo ${#ARR[@]}
> 5
echo "${ARR[@]}"
> zero one four
echo "${ARR[0]}"
> zero
echo "${ARR[2]}"
> # Nothing, because it is empty
Run Code Online (Sandbox Code Playgroud)
问题是如何用另一个字符串替换空元素?
我试过了
${ARR[@]///other}
${ARR[@]//""/other}
Run Code Online (Sandbox Code Playgroud)
他们都没有工作.
我希望这个输出:
zero one other other four
Run Code Online (Sandbox Code Playgroud) 我是Finagle的新手.我现在正在阅读某人的代码,发现Future对象在不同的连接操作中被重用.我的问题是会导致Future对象多次执行(在每个连接中),还是只执行一次并存储结果以供以后连接?
例:
Future<A> a= b
.join(c)
.flatMap(new SomeFunctionReturningA());
Future<Tuple2<A, B>> future1 = a.join(b);
Future<D> future2 = future1.flatMap(new SomeFunctionReturningD());
future2.get();
Run Code Online (Sandbox Code Playgroud)
那么b会被执行两次,还是只执行一次?