小编apa*_*ick的帖子

在继续之前等待Swing GUI关闭

我正在编写一个应用程序,要求用户将一些数据输入到应用程序随后将使用的Swing GUI中.用户输入数据后,不再需要GUI,因为应用程序会将一些数据写入文件.

一般的想法是这样的:

launchGui();
closeGui();
continueWithComputation();
Run Code Online (Sandbox Code Playgroud)

我知道Swing在后台使用了一些线程,我理解为什么程序在GUI关闭之前不会阻塞.

在继续之前,是否有可能以任何方式等待GUI关闭(单一JFrame关闭dispose())continueWithComputation()

java swing command-line multithreading

4
推荐指数
1
解决办法
6017
查看次数

VBoxLinuxAdditions.run永远不会退出0

我正在尝试使用Chef自动安装Virtualbox guest添加,但是我遇到了一个问题,其中VBoxLinuxAdditions.run从不存在,退出代码为0.我总是得到退出代码1,即使在脚本打印输出中没有报告任何错误.

它们似乎已经安装,所以我不明白为什么这个脚本总是返回1.

我正在使用Debian 6 guest OS的Windows 8.1主机Virtualbox 4.3.12.

我试图通过使用厨房运行以下配方来实现这一目标:

include_recipe "apt"

%W[make gcc xserver-xorg xserver-xorg-core linux-headers-#{node['kernel']['release']} dkms].each do |p|
  package p do
    action :install
  end
end

# get additions iso file
remote_file "#{Chef::Config[:file_cache_path]}/vboxAdditions.iso" do
  source "http://download.virtualbox.org/virtualbox/#{node['virtualbox']['version']}/VBoxGuestAdditions_#{node['virtualbox']['version']}.iso"
end

# create the mount point
directory "/mnt/vboxAdditions" do
  owner "root"
  group "root"
  mode "0755"
  action :create
end

# mount the iso
mount "/mnt/vboxAdditions" do
  action :mount
  device "#{Chef::Config[:file_cache_path]}/vboxAdditions.iso"
fstype "iso9660"
  options "loop"
end

# run the installer script
execute "install vbox guest …
Run Code Online (Sandbox Code Playgroud)

bash debian virtualbox chef-infra

1
推荐指数
1
解决办法
1413
查看次数

为什么Java在读取LinkedHashMap时会自动从String转换为Integer

我的Java应用程序显示一些奇怪的行为,我找不到解决方案.

此代码段获取LinkedHashMap键和值都是类型的内容String,并将它们写入文本文件.configWriter是类型的PrintWriter.

for (Map.Entry<String, String> entry : configMap.entireSet()) {

    configWriter.println(entry.getKey() + "=" + entry.getValue());
}
Run Code Online (Sandbox Code Playgroud)

宣布地图:

LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
Run Code Online (Sandbox Code Playgroud)

它通过使用Scanner类从文本文件中读取标记来填充.

一个在地图的值是一个String只包含数字(整数),但是当循环到达此值时,它抛出一个ClassCastException,你不能从投说法IntegerString.这很有道理,但值的类型是String.

有没有办法强制Java将此值保持为String

java string integer classcastexception linkedhashmap

0
推荐指数
1
解决办法
830
查看次数