当我使用JDK 1.7.0在OS X上编译Spring JDBC源代码时,我收到此警告:
warning: CachedRowSetImpl is internal proprietary API and may be removed in a future release
Run Code Online (Sandbox Code Playgroud)
如何在编译期间禁止显示警告消息?
我已经知道并使用Java的@SuppressWarning注释.我正在寻找具体用法来抑制我所描述的警告.
我的问题具体是,在这行代码中:
@SuppressWarnings("valuegoeshere")
Run Code Online (Sandbox Code Playgroud)
应该用"valuegoeshere"替换什么?
编辑:人们,我知道最好避免导致警告的代码.通常这将是我的方法.但是我在这里编译第三方代码,我不想重写.我只想添加正确的注释来抑制警告,以便我可以实际做些什么的警告不会被埋没.
我已经执行了JDBC查询来获取结果集.在迭代之前,我想快速找出返回的行数.我怎样才能以高性能做到这一点?
我正在使用Java 6,Oracle 11g和最新的Oracle JDBC驱动程序.
我需要从Tomcat中运行的servlet发送电子邮件.我总是会向同一个收件人发送相同的主题,但内容不同.
使用Java发送电子邮件的简单方法是什么?
我正在使用java.util.Properties的store(Writer,String)方法来存储属性.在生成的文本文件中,属性以偶然的顺序存储.
这就是我正在做的事情:
Properties properties = createProperties();
properties.store(new FileWriter(file), null);
Run Code Online (Sandbox Code Playgroud)
如何确保按字母顺序或按属性添加顺序写出属性?
我希望解决方案比"手动创建属性文件"更简单.
我想在Java应用程序执行时将光标图标更改为我自定义的32x32图像.我查找并搜索,我发现的只是在JComponent上设置光标.但是,只要Java应用程序仍在运行,或者您可以说程序运行时,我希望将光标更改为指定的图标,无论它在何处移动,浏览和单击.
非常感谢.
我无法将JavaFX MenuBar显示为屏幕顶部的标准OS X菜单栏.
这是我在我的Application子类中尝试过的:
public void start(Stage primaryStage) throws Exception {
final Menu menu1 = new Menu("File");
final Menu menu2 = new Menu("Options");
final Menu menu3 = new Menu("Help");
MenuBar menuBar = new MenuBar();
menuBar.getMenus().addAll(menu1, menu2, menu3);
menuBar.setUseSystemMenuBar(true);
primaryStage.setTitle("Creating Menus with JavaFX 2.0");
final Group rootGroup = new Group();
final Scene scene = new Scene(rootGroup, 800, 400, Color.WHEAT);
rootGroup.getChildren().add(menuBar);
primaryStage.setScene(scene);
primaryStage.show();
}
Run Code Online (Sandbox Code Playgroud)
我假设使用了
menuBar.setUseSystemMenuBar(true);
Run Code Online (Sandbox Code Playgroud)
会做的伎俩,但实际上它使menuBar完全消失.
我在OS X 10.9上使用Java 1.8.0-b132
我在Java 6中使用SwingWorker来避免在事件派发线程上运行长时间运行的代码.
如果在我的done()方法中调用get()会返回异常,那么处理异常的适当方法是什么?
我特别关注可能的InterruptedExceptions.JavaDoc示例简单地忽略了异常,但多年来我已经了解到吞咽异常导致难以调试的代码.
示例用法如下:
new SwingWorker<String, Void>() {
@Override
protected String doInBackground() throws Exception {
// do long-running calculation
return result;
}
@Override
protected void done() {
try {
setTextField(get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}.execute();
Run Code Online (Sandbox Code Playgroud) 如何在主窗口关闭时退出Cocoa应用程序?如果没有,您必须单击应用程序图标并单击菜单中的退出.