我已经使用此答案在Windows 10操作中心成功创建了一个通知弹出窗口.问题是,通知在那里停留5秒钟,然后一旦消失就完全从动作中心移除.如何让操作中心保留通知,直到用户解除通知为止?这是代码:
import java.awt.*;
import java.awt.TrayIcon.MessageType;
import javax.swing.JOptionPane;
public class Win10Notif {
public static void main(String[] args) throws AWTException, java.net.MalformedURLException {
if (SystemTray.isSupported()) {
Win10Notif td = new Win10Notif();
td.displayTray();
} else {
System.err.println("System tray not supported!");
}
}
public void displayTray() throws AWTException, java.net.MalformedURLException {
//Obtain only one instance of the SystemTray object
SystemTray tray = SystemTray.getSystemTray();
//If the icon is a file
Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
//Alternative (if the icon is on the classpath):
//Image image …
Run Code Online (Sandbox Code Playgroud) 我试图使用外部jcifs库从网络共享中读取文件.我可以找到的大多数用于读取文件的示例代码非常复杂,可能不必要.我找到了一种写入文件的简单方法,如下所示.有没有办法使用类似的语法读取文件?
SmbFile file= null;
try {
String url = "smb://"+serverAddress+"/"+sharename+"/TEST.txt";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, username, password);
file = new SmbFile(url, auth);
SmbFileOutputStream out= new SmbFileOutputStream(file);
out.write("test string".getBytes());
out.flush();
out.close();
} catch(Exception e) {
JOptionPane.showMessageDialog(null, "ERROR: "+e);
}
Run Code Online (Sandbox Code Playgroud) 我在网上看到你可以使用底部的代码来制作水平链接的动画(底部的小提琴演示)。我是 html 的初学者,并希望在具有如下链接的上下文中使用它:
<a href="#nav">click this link</a>
<a name="nav" class="testing">anchor</a>
Run Code Online (Sandbox Code Playgroud)
动画网页水平滚动到锚点。这是我想要执行此操作的代码:
function goToByScrollHoriz(id){
$('html,body').animate({
scrollLeft: $("#"+id).offset().left
},'slow');
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以引导我如何?
谢谢