我已经阅读了这个SO线程,当我尝试使用代码进行一些更改时,我只得到一个黑色的窗口,有人可以告诉我这里我做错了什么,我只有一个带有main函数的类:
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.sun.jna.NativeLibrary;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface;
import uk.co.caprica.vlcj.runtime.windows.WindowsCanvas;
public class Canvas_Demo {
// Create a media player factory
private MediaPlayerFactory mediaPlayerFactory;
// Create a new media player instance for the run-time platform
private EmbeddedMediaPlayer mediaPlayer;
private JPanel panel;
private WindowsCanvas canvas;
private JFrame frame;
//Constructor
public Canvas_Demo(String url){
//Creating a panel that while contains the canvas
panel = new JPanel();
panel.setBackground(Color.BLACK);
//Creating the canvas and adding it to the …Run Code Online (Sandbox Code Playgroud) 我试图只使用正则表达式匹配阿拉伯语文本,但我得到一个例外.这是我的代码:
txt.matches("\\P{Arabic}+")
Run Code Online (Sandbox Code Playgroud)
这是例外:
线程"main"中的异常java.util.regex.PatternSyntaxException:索引9附近的未知字符属性名{阿拉伯语}\P {阿拉伯语} +
从Oathy考试的"Kathy Sierra Bert Bates"一书中我发现了以下代码
public class FileTest {
public static void matches(Path path, String glob){
PathMatcher matcher = FileSystems.getDefault().getPathMatcher(glob);
System.out.println(matcher.matches(path));
}
public static void main(String[] args) throws IOException {
Path path = Paths.get("/com/java/One.java");
matches(path, "glob:*.java");
matches(path, "glob:**/*.java");
matches(path, "glob:*");
matches(path, "glob:**");
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
false
true
false
true
Run Code Online (Sandbox Code Playgroud)
我无法清楚地理解输出.有人会解释我吗?让我知道我的例子是什么是跨越目录边界.谢谢洛基
我的情况是我有一个包含一些文件(txt,png,...)的zip文件,我想直接用它们的名字来读它,我测试了下面的代码但没有结果(NullPointerExcepion):
InputStream in = Main.class.getResourceAsStream("/resouces/zipfile/test.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
Run Code Online (Sandbox Code Playgroud)
resources是一个包,zipfile是一个zip文件.
所以我刚刚开始编写我正在编写的Java程序,它告诉我我的全局变量需要是静态的.我不明白为什么它告诉我这个,因为我之前已经开发了Java程序而不必使我的全局变量保持静态.有人可以帮忙吗?
import java.awt.event.*;
import javax.swing.*;
public class PlannerMain {
JFrame frame;
JButton makeMap;
public static void main(String[] args){
frame = new JFrame("Land Planner");
makeMap = new JButton("Make Map");
makeMap.addActionListener(new makeMapListener());
frame.setSize(580,550);
frame.setVisible(true);
}
class makeMapListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
}
}
}
Run Code Online (Sandbox Code Playgroud) 我需要编写跨平台应用程序(基本上是CRUD).
使用Java Swing 好主意吗?或者它过时了,你知道更好的解决方案吗?我不想像5种语言一样使用各种东西,一两个就足够了.
我在python中有一个龙卷风web服务器:
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
from tornado.ioloop import IOLoop
import tornado.web
import time
import threading
import sys
from datetime import datetime
from datetime import timedelta
def sample():
print 'hiiiii'
threading.Timer(10, sample).start()
class WSHandler(tornado.websocket.WebSocketHandler):
def open(self):
print 'new connection'
def on_message(self, message):
self.write_message(message)
self.msg('hellooooooo')
print message
def msg(self,message):
self.write_message(message)
threading.Timer(10, self.msg('in timer')).start()
print 'in msg'+message
def on_close(self):
print 'connection closed'
application = tornado.web.Application([
(r'/', WSHandler),
])
if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8888)
interval_ms=120
main_loop=tornado.ioloop.IOLoop.instance()
main_loop.start()
Run Code Online (Sandbox Code Playgroud)
而客户是
<html> …Run Code Online (Sandbox Code Playgroud) 如何可以解析此日期格式Mon May 14 2010 00:00:00 GMT+0100 (Afr. centrale Ouest)此日期格式05-14-2010我的意思mm-dd-yyyy
它告诉我这个错误:
java.text.ParseException: Unparseable date: "Mon May 14 2010 00:00:00 GMT+0100 (Afr. centrale Ouest)"
编辑
SimpleDateFormat formatter = new SimpleDateFormat("M-d-yyyy");
newFirstDate = formatter.parse(""+vo.getFirstDate()); //here the error
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我创建了一个简单的Java应用程序,它使用了一些外部资源(文件夹).如何创建安装屏蔽以创建文件夹安装(如C:\Program Files\MyApp)并将外部资源复制到此目标?我正在使用Eclipse.
我想在Jlabel文本中包含可单击的单词,我想为每个单词注册一个MouseListener或获取单击的单词(否则).下图显示了我想要的内容.这可能吗 ?!
