我在mac上使用java se7,oracle预览.
我的问题是"Files.probeContentType"返回null ...是否有可能是因为se7的早期状态为mac?我的代码:
if(directory == null) return;
String content = null;
try {
content = Files.probeContentType(directory.toPath());
} catch (IOException e) {
JOptionPane.showMessageDialog(main, e.toString());
return;
}
if(content == null)
{
return;
}
else if(content.contains("image"))
{
main.pctviewer.setImage(directory);
}
Run Code Online (Sandbox Code Playgroud)
该文件的名称是:
"/ Users/admin/Desktop/temp/q12/formulare/Bildschirmfoto 2012-09-11 um 17.57.59.png"
并且在eclipse中的调试模式下,如果我将鼠标悬停在文件"文件路径= Unis-path(id:145)"上方为红色
我有一个表格实验和一个表格标签.一个实验可能有许多标签.模式:
-------- --------
|Table1| 1 n |Table2|
| | <--------------> | |
| | | |
-------- --------
(experiment) (tags)
Run Code Online (Sandbox Code Playgroud)
是否可以使用jooq创建查询,返回实验和相应的标记列表.类似于结果,其中Record是一个experimentRecord,一个标签列表或一个地图.
我也有一个只返回一个结果的查询,那里有什么方便吗?
编辑:java8,最新的jooq.
我有一个基本的、简单的甚至可能是愚蠢的问题,但是我如何实现我可以将文件拖到我的 Java 程序上并打开它?我搜索了很长时间这个基本问题.....
只要我发现你不能将它拖到 .jar 上,因为它不可执行。您必须创建一个 .exe,它也会打开您的 .jar,但仅此而已!我真的很想知道如何:)
如果我可以通过搜索这个关键字得到答案,一个关键字就足够了。
谢谢,利安德
//编辑:我可能表达的东西有点复杂。后来我想有一个快捷方式,例如,我可以在快捷方式上拖动任何文件的桌面上,程序打开时会打开文件(此时它只会将其移动到特殊位置。
我不知道这个的代码是怎样的,我什至不知道如何用谷歌搜索这个(我只得到问题如何使用答案 Desktop.open(File f) 来实现“打开方式”)。
我有:
import qualified GHC.Types as T hiding (Module, (*))
import GHC.TypeNats hiding ((*))
Run Code Online (Sandbox Code Playgroud)
但是当我尝试定义一个(*)-operator时,它失败了:
{-# INLINE (*) #-}
infixl 7 *
(*) :: r -> r -> r
(*) = undefined
Run Code Online (Sandbox Code Playgroud)
同
error:
Ambiguous occurrence ‘*’
It could refer to either ‘T.*’,
imported qualified from ‘GHC.Types’ at ...
or ‘*’,
imported from ‘GHC.TypeNats’ at ...
|
1277 | infixl 7 *
Run Code Online (Sandbox Code Playgroud)
编辑:描述目前无法重现.我会尽快更新问题.
我有这种方法:
default <U> CompletableFuture<U> submit(Supplier<U> supplier) {
return CompletableFuture.supplyAsync(supplier, .....getThreadPool());
}
Run Code Online (Sandbox Code Playgroud)
它由不同的类广泛使用,但是当前如果计算失败,则没有默认日志记录。我的第一种方法是:
.exceptionally(throwable ->
.....handleThrowable(throwable, runnable);
)
Run Code Online (Sandbox Code Playgroud)
但是此方法用于恢复,因为我必须返回一些东西。如果我只想登录该怎么办?
注意:这是概念实现的证明,而不是最终结果。
我有第三个。派对附加组件,我想限制他们对声音的使用,例如限制持续时间等(安全管理器不可能)。为了实现这一点,我考虑用包装器替换 AudioSystem.getLine() 的返回。这是测试方面:
@Aspect
public class MixerAspect {
@Around("execution(* javax.sound.sampled.AudioSystem.getLine(javax.sound.sampled.Line.Info))")
public Object getLineAdvice(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("AspectJ");
pjp.getArgs();
Line ret = (Line) pjp.proceed();
return ret;
}
}
Run Code Online (Sandbox Code Playgroud)
每个附加组件都有自己的类加载器,它们通常不共享对象,所以这就是我想出的:
@Override
public Class<?> loadClass(String className) throws ClassNotFoundException {
....
if (className.equals(AudioSystem.class.getName())) {
.....
byte[] array = buffer.toByteArray();
try {
if (mixed == null)
mixed = weaver.defineClass(className, array, new CodeSource(mixerAspect, (CodeSigner[]) null));
return mixed;
} catch (IOException e) {
throw new ClassNotFoundException("unable to define class", e);
}
Run Code Online (Sandbox Code Playgroud)
这是 WeavingURLClassloader 的初始化代码:
weaver …Run Code Online (Sandbox Code Playgroud) 我有以下问题:我的鼠标输入方法不起作用,我不知道为什么。按下的鼠标完美无缺,只有 mouseEntered 不行。
这是鼠标监听器:
MouseListener mouseListener = new MouseListener() {
public void mouseClicked(MouseEvent e) {
jpopup.setLocation(e.getX(), e.getY());
jpopup.setInvoker(jpopup);
jpopup.setVisible(true);
System.out.println("Tray Icon - Mouse clicked!");
}
@Override
public void mouseEntered(MouseEvent e) {
System.out.println("Tray Icon - Mouse entered!");
}
public void mouseExited(MouseEvent e) {
System.out.println("Tray Icon - Mouse exited!");
}
public void mousePressed(MouseEvent e) {
System.out.println("Tray Icon - Mouse pressed!");
}
public void mouseReleased(MouseEvent e) {
System.out.println("Tray Icon - Mouse released!");
}
};
Run Code Online (Sandbox Code Playgroud)
这里是托盘图标:
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
trayIcon.addMouseListener(mouseListener);
Run Code Online (Sandbox Code Playgroud)
错误在哪里?我不知道...
编辑:我正在使用日食,如果这很有趣......
我有一个奇怪的问题.我创建这个窗口,但它的空白,直到我最小化它并再次最大化它.这是个常见的问题吗?这是我的代码(Sry因为长代码....我只删除了动作监听器,我担心我可以删除错误).
public class Gui_preferences extends JFrame{
private static final long serialVersionUID = -2375617814937747645L;
private JTextField savingPathField;
private JTextField schoolField;
private JTextField classStageField;
private JFormattedTextField classdurationField;
private FunctionsSchedule fkSchedule;
JFormattedTextField schoolbeginningformattedTextField;
boolean firstopening;
JLabel notClosingLabel;
private JTextField formsFolderNameField;
private JTextField subjectsFolderNameField;
public Gui_preferences(boolean first, FunctionsSchedule fktSchedule) {
this.fkSchedule = fktSchedule;
setPreferredSize(new Dimension(650, 420));
setSize(650, 420);
setResizable(false);
setAlwaysOnTop(true);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setVisible(true);
JScrollPane scrollPane = new JScrollPane();
getContentPane().add(scrollPane, BorderLayout.CENTER);
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(500, 420));
panel.setMinimumSize(new Dimension(500, 420));
scrollPane.setViewportView(panel);
panel.setLayout(new MigLayout("", …Run Code Online (Sandbox Code Playgroud) 我google了很多,它仍然没有工作,所有我的int和字符串等不会改变他们的valaues
我的de//序列化代码:
public void serialize()
{
XmlSerializer xs = new XmlSerializer(typeof(Stundenplan));
TextWriter writer = new StreamWriter(@"daten.xml");
xs.Serialize(writer, this);
writer.Close();
} //seems to work since the xml file looks good
public void deserialization()
{
XmlSerializer xs = new XmlSerializer(typeof(Stundenplan));
TextReader reader = new StreamReader(@"daten.xml");
Stundenplan stu;
stu = (Stundenplan)xs.Deserialize(reader);
} // don't see any change
Run Code Online (Sandbox Code Playgroud)
以下是我参与序列化的类,没有所有空白:
public class Stundenplan
{
public Fach[] faecher = new Fach[100];
public int fachnr = 0;
Run Code Online (Sandbox Code Playgroud)
.......(很多空洞)}
public class Fach
{
public String name;
public bool[] …Run Code Online (Sandbox Code Playgroud) 我必须创建一个 zip 文件,其中包含一个文件夹中的类(以及清单等!)classes和一个libs文件夹中的依赖 jar文件。我目前的尝试是:
task createZip(type: Jar) {
into('classes')
extension('zip')
with jar
}
Run Code Online (Sandbox Code Playgroud)
但它没有添加依赖项(正如任何人都猜到的那样)