基本上我打算在JFrame上放置一些按钮,文本字段,标签等,我想让用户可以用鼠标在JFrame上移动不同的组件.
我已经看过使用MouseListeners的各种方法,子类化JComponent代码,DropSource/DropTarget实现等等,但我不确定哪种是"推荐"方式(我不需要支持不同帧/应用程序之间的"拖放")这是大多数例子似乎做的事情).
我需要将String转换为Float.
我会收到这样的字符串:
$string = "1.70 m";
$string2 = "2.445 m";
Run Code Online (Sandbox Code Playgroud)
如何轻松地将此字符串转换为:
$float1 = 1.70;
$float2 = 2.445;
Run Code Online (Sandbox Code Playgroud)
有人能给我一些线索吗?
最好的祝福,
我正在开展一个项目,我必须阅读一个dicom图像.
我无法安装dcmtk.我正在使用win7 64位和vs2010.
请解释在我的程序中包含dcmtk的过程.
采取以下java代码:
public class SomeClass {
private boolean initialized = false;
private final List<String> someList;
public SomeClass() {
someList = new ConcurrentLinkedQueue<String>();
}
public void doSomeProcessing() {
// do some stuff...
// check if the list has been initialized
if (!initialized) {
synchronized(this) {
if (!initialized) {
// invoke a webservice that takes a lot of time
final List<String> wsResult = invokeWebService();
someList.addAll(wsResult);
initialized = true;
}
}
}
// list is initialized
for (final String s : someList) {
// …Run Code Online (Sandbox Code Playgroud) java concurrency multithreading synchronization memory-model
我阅读了有关用户扩展和扩展selenium但我想知道如何从我正在创建的自定义命令中调用命令.
我在Selenium IDE Options中向Selenium核心扩展(user-extensions.js)添加了类似于以下的文件.
// selenium-action-example.js
Selenium.prototype.doExample = function() {
this.doOpen("/"); // doesn't waitForPageToLoad like the command does
// These two commands are equivalent to the clickAndWait command. NOT!
// For proof, see the filterForRemoteControl function:
// http://code.google.com/p/selenium/source/browse/trunk/ide/src/extension/content/formats/formatCommandOnlyAdapter.js?r=8284#68
this.doClick("css=a#example");
this.doWaitForPageToLoad(); // doesn't wait at all
this.doClick("link=Example");
this.doWaitForElementPresent("example"); // error! undefined function
this.doClick("example");
};
Run Code Online (Sandbox Code Playgroud)
换句话说,我如何在自定义操作中的点击之间等待?
假设我有一个 STL 容器类型(不是对象),例如vector<A>. 现在是这样value_type,A所以我想把它改成B。
基本上,我想要一个这种形式的类模板,或其变体:
template<typename container, typename new_value_type>
struct change_value_type
{
typedef /*....*/ new_container;
};
Run Code Online (Sandbox Code Playgroud)
这样我就可以按以下方式使用它:
typename change_value_type<vector<A>, B>::new_container vectorOfB;
vectorOfB.push_back(B());
vectorOfB.push_back(B());
vectorOfB.push_back(B());
//etc
Run Code Online (Sandbox Code Playgroud)
意思是,new_container是vector<B>
是否可以?
我使用Visual Studio安装项目为我的.Net应用程序创建MSI.如果我可以自动增加版本号,那就太好了.更好的方法是将安装程序版本设置为等于主输出exe的AssemblyVersion.
在我的应用程序中,在主要活动的onCreate()方法中,我正在创建唤醒锁定,以便在手机进入待机/屏幕关闭时CPU将继续运行.
同样在onCreate方法中,我有意创建一个使用加速度计的服务.当应用程序打开并监控加速度计值时,此服务需要持续运行(我知道这对电池不利,但我需要它来做).这是我目前的代码,服务开始很好.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Howaya");
wl.acquire();
if (appStart == true)
{
Intent AccelService = new Intent(this, Accelerometer.class);
AccelService.putExtra("unreg", false);
startService(AccelService);
}
appStart = false;
}
Run Code Online (Sandbox Code Playgroud)
我的清单中设置了以下权限 -
<uses-permission android:name="android.permission.WAKE_LOCK" />
Run Code Online (Sandbox Code Playgroud)
我尝试过不同的锁 - 昏暗的屏幕和全亮度也无济于事.我在logcat上的输出在这里 -
F/PowerManager(15628): android.util.Log$TerribleFailure: WakeLock finalized while still held: Howaya
F/PowerManager(15628): at android.util.Log.wtf(Log.java:260)
F/PowerManager(15628): at android.util.Log.wtf(Log.java:239)
F/PowerManager(15628): at android.os.PowerManager$WakeLock.finalize(PowerManager.java:329)
F/PowerManager(15628): at dalvik.system.NativeStart.run(Native Method)
Run Code Online (Sandbox Code Playgroud)
我见过有人说部分唤醒锁没有像他们应该做的那样工作,比如这个链接谷歌待机错误页面,但这个是去年发布和关闭所以我不知道是这样的,请问有人可以帮忙吗?关于最后一点我也有HTC Desire,谢谢.
java ×3
android ×1
c++ ×1
click ×1
components ×1
concurrency ×1
containers ×1
dicom ×1
memory-model ×1
php ×1
qt ×1
qt4 ×1
riak ×1
selenium ×1
selenium-ide ×1
selenium-rc ×1
standby ×1
stl ×1
string ×1
swing ×1
templates ×1
wakelock ×1