我在我的应用程序中使用hibernate 3.2.2.对于连接池,我们使用的是c3p0 0.9.1.我在View模式中使用Generic DAO Pattern和Open Session来进行数据库操作.
我们正在开发现有网站的新网站.现在,在现有应用程序中,访问次数为50万次.我对c3p0配置感到困惑.在什么基准,我决定打开连接的否定.最大连接,最小连接,空闲时间,超时等....
我正在尝试将HTML5画布导出为PNG文件,以便将其存储在用户的计算机上.
以下代码段正确保存图像.
document.location.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
Run Code Online (Sandbox Code Playgroud)
但是,在Mac OS X上使用Chrome时,它始终保存为"下载".在Safari中,它被称为"未知".Firefox给它一个gobbledygook名称.
我可以向浏览器建议使用的名称,例如"exportedImage.png"吗?
今天,我们的巴西用户为我们制作了大量的崩溃报告.我已将其跟踪到此代码,该代码抛出了一个Joda异常:
import org.joda.time.DateTime;
import org.joda.time.DateTimeUtils;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalTime;
public class ScratchSpace {
public static void main(String[] args) {
// force Joda to act like we are in Sao Paolo on 2015-10-18
DateTimeUtils.setCurrentMillisFixed(1445185758078L); // 2015-10-18T18:29
DateTimeZone.setDefault(DateTimeZone.forID("America/Sao_Paulo"));
// most of users have offset == 0, but it could be any number of millis from 0 to 86_400_000-1 (millis in day)
int offset = 0;
// local time at start of day + offset millis
final LocalTime localTime = LocalTime.fromMillisOfDay(offset);
// convert …Run Code Online (Sandbox Code Playgroud) 我下载并安装了最新的Java 9早期版本,并且很高兴地发现Windows上的Java Swing应用程序现在可以以正确的大小呈现组件.使用HiDPI显示器的客户不再需要以预期宽度和高度的一半使用我的应用程序.
但是我注意到在我的Swing应用程序中,我自己的图标只是缩放到宽度和高度加倍,使它们看起来很锯齿.
我确实拥有正常尺寸(例如foobar.png)和双倍宽度/高度(例如foobar@2x.png)的全套图标.我使用Apple命名约定.
如何让Java 9在可用的情况下轻松找到并使用图像的更高分辨率版本,而无需手动编写代码?
代码示例总是让问题更清晰,Java 9还有一个多分辨率图标类,我可以使用它来编译和运行以下代码吗?
import javax.swing.*;
public class ScratchSpace {
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("I work in HiDPI!");
// can I replace the following line with some magical new method that automatically loads the same icon at multiple resolutions
// so that Swing chooses the correct one when rendering, depending on the current scale of the current display?
Icon icon = new IconWithMultipleSizes("foobar.png"); …Run Code Online (Sandbox Code Playgroud) 我需要创建一个Java组件,在进程通过时将背景转换为某种颜色,并在进程失败时将其他颜色转换为颜色.
我的第一个想法是:成功的绿色,失败的红色.
但后来我读到10%的男性无法区分这两种颜色.什么是更好的颜色组合?
(对于挑剔的人:是的,我知道单靠颜色是不够的,也可以使用文字,形状和噪音.不过我问的是颜色的合适使用.)
我在NSTextField中使用的文本是从文件加载的,如下所示.
NSString *path = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"];
NSAttributedString *as = [[NSAttributedString alloc] initWithPath:path documentAttributes:NULL];
[creditsLabel setAttributedStringValue:as];
[creditsLabel becomeFirstResponder];
Run Code Online (Sandbox Code Playgroud)
除非我首先点击NSTextField上的某个地方,否则窗口中的超链接不会呈现蓝色下划线.
如何使这些超链接看起来像超链接?
这是RTF:
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\f0\fs24 \cf0 Copyright \'a9 2009-2010 Fully Functional Software.\
All rights reserved.\
\
BlazingStars is made possible by {\field{\*\fldinst{HYPERLINK "http://www.iterasi.net/openviewer.aspx?sqrlitid=p4mjpt7nl02tyjl08_ctaa"}}{\fldrslt DBPrefsWindowController}}, {\field{\*\fldinst{HYPERLINK "http://mattgemmell.com/source"}}{\fldrslt Image Crop}}, {\field{\*\fldinst{HYPERLINK "http://code.google.com/p/tesseract-ocr/"}}{\fldrslt Tesseract-OCR}}, {\field{\*\fldinst{HYPERLINK "http://andymatuschak.org/articles/2005/12/18/help-with-apple-help"}}{\fldrslt Andy's Help Toolkit}}, and {\field{\*\fldinst{HYPERLINK "http://wafflesoftware.net/shortcut/"}}{\fldrslt Shortcut Recorder}}.\
\
Includes icons from the BlueCons set by {\field{\*\fldinst{HYPERLINK "http://www.mouserunner.com"}}{\fldrslt Ken Saunders}}.}
Run Code Online (Sandbox Code Playgroud)
alt text http://pokercopilot.com/stuff/stackoverflow/screenshot2.png
替代文字http://pokercopilot.com/stuff/stackoverflow/screenshot1.png
我在Mac OS X 10.6上使用Java 6.我的用户也是如此.我试图强制一个特定的JTextArea不使用抗锯齿.
有任何想法吗?
这是我的测试代码:
public static void main(String[] args) {
JTextArea jTextArea1 = new JTextArea("This is some text which should be anti-aliased");
jTextArea1.setFont(new Font("Lucida Grande", Font.PLAIN, 14));
JTextArea jTextArea2 = new JTextArea("Please no anti-aliasing for this text");
jTextArea2.setFont(new Font("Monaco", Font.PLAIN, 10));
final JFrame frame = new JFrame();
frame.getContentPane().add(new JScrollPane(jTextArea1), BorderLayout.NORTH);
frame.getContentPane().add(new JScrollPane(jTextArea2), BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
Run Code Online (Sandbox Code Playgroud) 我正在一个项目中,我们需要加密.jar文件,所以没有人可以访问jar文件中的.class文件....是否有任何java编码可以帮助我加密.jar文件?
这是困难的一个.客户通过崩溃报告向我发送了此堆栈跟踪信息.它没有提到我的应用程序的类,所以我很困惑,从哪里开始寻找.
我的应用是商业桌面应用.崩溃报告是匿名的,因此我无法轻易获得有关崩溃的更多信息.
编辑:一些谷歌搜索和线程跟踪使我得出结论,它是Java 1.7中的零星问题.寻找解决方案......
我该如何进行调试呢?
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:868)
at java.util.TimSort.mergeAt(TimSort.java:485)
at java.util.TimSort.mergeCollapse(TimSort.java:410)
at java.util.TimSort.sort(TimSort.java:214)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycle(SortingFocusTraversalPolicy.java:136)
at javax.swing.SortingFocusTraversalPolicy.getFocusTraversalCycle(SortingFocusTraversalPolicy.java:110)
at javax.swing.SortingFocusTraversalPolicy.getFirstComponent(SortingFocusTraversalPolicy.java:435)
at javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(LayoutFocusTraversalPolicy.java:166)
at javax.swing.DefaultFocusManager.getFirstComponent(DefaultFocusManager.java:120)
at javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent(LegacyGlueFocusTraversalPolicy.java:132)
at javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultComponent(LegacyGlueFocusTraversalPolicy.java:150)
at java.awt.FocusTraversalPolicy.getInitialComponent(FocusTraversalPolicy.java:169)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:380)
at java.awt.Component.dispatchEventImpl(Component.java:4731)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) …Run Code Online (Sandbox Code Playgroud) 我们基于install4j的应用程序具有一个名为(例如foobar-1.0.jar)的第三方库
在更新的版本中,我们用foobar-1.1.jar替换了jar
install4j更新程序会添加新的jar,但不会删除旧的jar。所以现在两者都在类路径上。这使我们的应用崩溃。
如何告诉更新程序删除不再存在的文件?