我看了一下:Eclipse-Shortcuts,但是我找不到生成构造函数的东西.
什么是生成标准构造函数的捷径?
我的java版本是:
Java Plug-in 10.3.1.255使用JRE版本1.7.0_03-b05 Java HotSpot(TM)客户端VM
所以当我有版本6.x一切都很好,升级后我得到了这个:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: This function should be called while holding treeLock
at java.awt.Component.checkTreeLock(Component.java:1196)
at java.awt.Container.validateTree(Container.java:1682)
at pl.recorder.ScenarioWindow.showUploadPanel(PlayerWindow.java:721)
at pl.recorder.actions.UploadFilesAction.execute(DesignFilesAction.java:71)
at pl.recorder.actions.EndTestAction.actionPerformed(EndTestAction.java:91)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at … 有没有一种简单的方法,使用Java Swing,在我的工作站上显示Java系统属性名称和值?
基本上,我正在寻找的是一个Java Swing应用程序,它显示如下:

每当我从快捷方式运行eclipse时,我无法正确构建我的一些项目,因为PATH我配置的变量.bashrc没有被使用.
当我从终端运行eclipse时,我可以很好地构建我的所有项目,因为它正在运行正确的shell.
问题是我想使用PATH我的变量.bashrc而不是永久打开终端.我以前试过这个,但是每天我都不小心关闭了正在运行eclipse的终端并丢失了所有未保存的代码.
谁能帮我?
我正在使用fedora 19. HelloWorld.java的内容:
class HelloWorld {
public static void main( String args[] ) {
System.out.println( "Hello World!!" );
}
}
Run Code Online (Sandbox Code Playgroud)
我可以使用成功编译它
javac HelloWorld.java
但我无法使用它
java HelloWorld
它给出以下错误
错误:无法找到或加载主类HelloWorld
但我可以使用它来运行它
sudo java HelloWorld
我在这里失踪了什么?
我正在重构一些代码,以便更容易阅读,我遇到了一些我觉得奇怪的东西,我想知道是否有人可以向我解释这个.
原始代码:
if(tokensLeft == 3) {
String id = tokens.nextToken();
String value = tokens.nextToken();
String trailerId = tokens.nextToken();
rawListener.binaryInfo(id, Integer.parseInt(value), trailerId, this);
} else if(tokensLeft == 2) {
String id = tokens.nextToken();
String value = tokens.nextToken();
rawListener.binaryInfo(id, Integer.parseInt(value), this);
} else {
System.out.println("Method call binaryInfo could not be done because: \"Wrong number of parameters\"");
}
Run Code Online (Sandbox Code Playgroud)
重构后:
switch(tokensLeft) {
case 3:
String id = tokens.nextToken();
String value = tokens.nextToken();
String trailerId = tokens.nextToken();
rawListener.binaryInfo(id, Integer.parseInt(value), trailerId, this);
break;
case 2:
String …Run Code Online (Sandbox Code Playgroud) 我有一个文件夹,其中包含以时间戳命名的文件.
当我尝试浏览每个文件时,它按字母顺序排序并给我这个顺序:
/home/user/buffereddata/1
/home/user/buffereddata/100
/home/user/buffereddata/1000
/home/user/buffereddata/200
/home/user/buffereddata/2000
/home/user/buffereddata/300
Run Code Online (Sandbox Code Playgroud)
但我希望它们像这样排序:
/home/user/buffereddata/1
/home/user/buffereddata/100
/home/user/buffereddata/200
/home/user/buffereddata/300
/home/user/buffereddata/1000
/home/user/buffereddata/2000
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
File file = new File(System.getProperty("user.home") + "/buffereddata");
if(file.exists()) {
File[] fileArray = file.listFiles();
Arrays.sort(fileArray);
for(File f : fileArray) {
System.out.println(f);
}
}
Run Code Online (Sandbox Code Playgroud)
是否有一些(最好是简单的)循环文件的方式,我想循环它们?
我有一些代码,每次通过我的循环时,它会增加8位字节.这一切都按预期进行,直到我达到120,然后我的数字突然变为负数.
码:
byte b = 0;
for(int i = 0; i < 0x100; i += 8) {
System.out.print(b + " ");
b += 8;
}
Run Code Online (Sandbox Code Playgroud)
输出:
0 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 -128 -120 -112 -104 -96 -88 -80 -72 -64 -56 -48 -40 -32 -24 -16 -8
我想看到的:
0 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 …
我有GridView,其中项目是带有图像(ImageView)和标题(TextView)的视图.我想在这个ImageView上执行onClick操作,但不是在整个GridView项上执行.如果我使用此代码:
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
ImageView imageView = (ImageView) view.findViewById(R.id.image);
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// some operation
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
只有第二次单击ImageView才能让我进行操作.如何通过首次单击GridView对ImageView进行操作?
我试图使一个项目从1列表移动到双击时的第二个列表.然后单击它时,将其移回第一个列表.
我遇到的问题是,当快速单击第二个列表中的项目时,双击事件将触发,尽管没有单击相同的项目.
你可以在这个jsfiddle中看到问题
https://jsfiddle.net/9afn4s7q/
$('.item').dblclick(function () {
$(this).detach();
$('#list2').append($(this));
$(this).click(function () {
$(this).detach();
$('#list1').append($(this));
});
});
Run Code Online (Sandbox Code Playgroud)
如何在单击不同项目时停止触发双击事件?