小编Nik*_*los的帖子

Linux上的JavaFX显示"图形设备初始化失败:es2,sw"

我刚开始在Linux上编写/测试JavaFX的东西,我在创建一个简单的应用程序时遇到了错误.在Foruns,我发现许多人对此有所了解,但我能找到一个明确的解释,说明它发生的原因.我想了解我的方案中缺少什么才能使其正常工作.

任何建议都会真正贬值.

环境信息:

java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b123)
Java HotSpot(TM) Client VM (build 25.0-b65, mixed mode)

Linux MYServer 2.6.21-1.3228.fc7 #1 SMP Tue Jun 12 15:37:31 EDT 2007 i686 i686 i386 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

例外:

Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:300)
        at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:244)
        at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:179)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:210)
        at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:653)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:314)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at …
Run Code Online (Sandbox Code Playgroud)

java linux javafx java-8

32
推荐指数
6
解决办法
4万
查看次数

从一周的数字到Joda Time的日期名称

我有一周中一天数字:2(如果星期一开始一周,则应与星期二相匹配).

从这个数字有一种方法可以使用Joda Time获取Java中的当天名称吗?在javascript中使用moment.js很容易做到:

moment().day(my number)
Run Code Online (Sandbox Code Playgroud)

java jodatime

16
推荐指数
1
解决办法
2万
查看次数

Javafx使用计时器时不在fx应用程序线程上

我正在使用它

import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;



public class Main extends Application {

public static void main(String[] args) {
    launch(args);
}

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 600, 400);
    primaryStage.setScene(scene);
    Circle circle = new Circle(300,200,50, Color.BLACK);
    primaryStage.setTitle("Circle");
    primaryStage.setResizable(false);
    root.getChildren().add(circle);
    moveCircle(circle, scene);
    primaryStage.show();
}
public int random(int min, int max) {
    return new Random().nextInt((max - min) + …
Run Code Online (Sandbox Code Playgroud)

java javafx javafx-2 javafx-8

8
推荐指数
1
解决办法
1万
查看次数

将JSON解析为Angular app中的Typescript类

我正在创建一个应用程序使用角度和打字稿.一切都很好地融合在一起,但有一个问题让我感到困惑.

我定义了我想在应用程序中传递的实体/模型类,类的数据来自$ resource调用的JSON.

以下是模型类的示例:

module app.domain {

    export interface IJob {
        id: number;
        jobTitle: string;
        jobDescription: string;
    }

    export class Job implements IJob {

       constructor(public id:number, public jobTitle: string, public jobDescription: string) {

       }
    }
}
Run Code Online (Sandbox Code Playgroud)

我通过返回资源的服务访问我的JSON资源:

namespace app.services {
    'use strict';

    interface IDataService {
        getJobResource(): angular.resource.IResourceClass<IJobResource>
    }

    interface IJobResource extends angular.resource.IResource<app.domain.IJob>{

    }

    export class DataService implements IDataService {

        static $inject: Array<string> = ['$log','$resource','ApiDataEndpoint'];
        constructor(
                    private $log: angular.ILogService,
                    private $resource: angular.resource.IResourceService,
                    private ApiDataEndpoint          
            ){}

        getJobResource(): angular.resource.IResourceClass<IJobResource>{
            return this.$resource(this.ApiDataEndpoint.url + 'job/:id',{}); …
Run Code Online (Sandbox Code Playgroud)

javascript json angularjs typescript angular-resource

7
推荐指数
1
解决办法
743
查看次数

HTTP状态500 - Servlet.init()

MyResource

@Path("myresource")
public class MyResource {

    /**
     * Method handling HTTP GET requests. The returned object will be sent
     * to the client as "text/plain" media type.
     *
     * @return String that will be returned as a text/plain response.
     */
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getIt() {
        return "Got it!";
    }
}
Run Code Online (Sandbox Code Playgroud)

的index.jsp

<html>
<body>
    <h2>Jersey RESTful Web Application!</h2>
    <p><a href="webapi/myresource">Jersey resource</a>
    <p>Visit <a href="http://jersey.java.net">Project Jersey website</a>
    for more information on Jersey!
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml …
Run Code Online (Sandbox Code Playgroud)

java tomcat servlets

7
推荐指数
3
解决办法
1万
查看次数

angularjs ng-options从options数组中选择自定义对象

我试图从ng-options对象列表中获取2个不同的id,并将其映射到用户select上的select模型中.模型已正确映射,但该值未显示在选择框中.

http://plnkr.co/edit/Z3ohLie4vpTvXhUiLfl6?p=preview

<!DOCTYPE html>
    <html ng-app="angularjs-starter">

      <head lang="en">
        <meta charset="utf-8">
        <title>Custom Plunker</title>
        <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
        <link rel="stylesheet" href="style.css">
        <script src="app.js"></script>
      </head>

      <body ng-controller="MainCtrl">
        <h1>Select something</h1>
        <select ng-model="selectedItem" ng-options="{'id':item.id,'anotherid':item.anotherId} as item.name for item in items"></select>
        <h3>The selected item:</h3>
        <pre>{{selectedItem | json}}</pre>
      </body>

    </html>
Run Code Online (Sandbox Code Playgroud)

Javascript:

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {
  $scope.items = [
    { id: 1, name: 'foo', anotherId: 11 },
    { id: 2, name: 'bar', anotherId: 22 },
    { id: 3, name: 'blah', anotherId: 33 }];
});
Run Code Online (Sandbox Code Playgroud)

angularjs ng-options

5
推荐指数
1
解决办法
1738
查看次数

AngularJS摘要回调

我发现自己经常要求每个摘要周期缓存数据,例如map/reduce函数或深度嵌套的访问器.为此,设置摘要回调,清除摘要循环之前/之后的缓存值会很有用.是否有"有角度的方式"来实现这一目标?

javascript performance caching angularjs angularjs-directive

4
推荐指数
1
解决办法
1820
查看次数

无法使用buildozer编译python脚本

我正在使用win 32 python 2.7和kivy 1.8.0,但在使用buildozer进行编译以创建Android应用程序时,它显示以下错误:

C:\Python27\Scripts>buildozer android debug deploy
I check configuration tokens
Unknown command/target android
Run Code Online (Sandbox Code Playgroud)

windows python-2.7 kivy

4
推荐指数
1
解决办法
3777
查看次数

避免公式注入,保留单元格值(HSSF/*.xls 中的引号前缀)

我正在开发的应用程序使用 Apache POI 创建 Excel 导出。通过安全审计,我们注意到如果用户不够小心,包含恶意值的单元格可能会产生任意进程。

要重现,请运行以下命令:

import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

public class BadWorkbookCreator {
    public static void main(String[] args) throws Exception {
        try(
            Workbook wb = new HSSFWorkbook();
            FileOutputStream fos = new FileOutputStream("C:/workbook-bad.xls")
        ) {
            Sheet sheet = wb.createSheet("Sheet");
            Row row = sheet.createRow(0);
            row.createCell(0).setCellValue("Aaaaaaaaaa");
            row.createCell(1).setCellValue("-2+3 +cmd|'/C calc'!G20");
            wb.write(fos);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后打开生成的文件:

重现问题的截图

并按照以下步骤操作:

  1. 单击 (A) 以选择包含恶意内容的单元格
  2. 单击 (B) 使光标位于公式编辑器中
  3. 按 ENTER
  4. 系统会询问您是否允许 Excel 运行外部应用程序;如果您回答是,则 Calc 已启动(或任何恶意代码)

有人可能会说,用户负责让 Excel 运行任意的东西,用户被警告。但是,Excel 是从可信来源下载的,有人可能会落入陷阱。

使用 Excel,您可以在公式编辑器中的文本前放置单引号以将其转义。以编程方式在单元格内容中放置单引号(例如下面的代码)使单引号可见! …

java apache-poi

3
推荐指数
1
解决办法
6800
查看次数

Spring Data JPA - 在日期之前和之后构建查询

我是Java JPA的新手 - Spring Boot.我想创建一个JPA查找,它将计算两个日期之间的行数.

我需要得到一个数字,显示过去28天内加入的成员数量.就像10.

但也得到一个值,表明与上个月的差异 - 所以+ 4% - 或-2% - 所以我想它将是count1/count2*100 =差异.你如何检测极性 - 所以评估它的消极或正面?

目前我有这样的事情

long countByRegisteredDateAfter(Date thresholdDate) throws Exception;
Run Code Online (Sandbox Code Playgroud)

但需要一些可能更像这样的东西

long countByRegisteredBeforeDateAfter(Date thresholdDate1, Date thresholdDate2)
    throws Exception;
Run Code Online (Sandbox Code Playgroud)

也许更精细的调整这样的东西

long countByRegisteredBeforeAndDateAfterAndRole(Date thresholdDate1, Date thresholdDate2, String role)
    throws Exception;
Run Code Online (Sandbox Code Playgroud)

代码到目前为止:

            // 28 days ago
            Calendar thresholdPast28 = Calendar.getInstance();
            thresholdPast28.set(Calendar.HOUR_OF_DAY,0);
            thresholdPast28.set(Calendar.MINUTE,0);
            thresholdPast28.set(Calendar.SECOND,0);
            thresholdPast28.add(Calendar.DATE,-28);

            java.util.Date thresholdPast28Date = thresholdPast28.getTime();
            Long countLast28Days = (Long) tblLoginRepository.countByRegisteredDateAfter(thresholdPast28Date);

            System.out.println("countLast28Days " + countLast28Days);


            // 56 days ago
            Calendar thresholdPast56 = Calendar.getInstance();
            thresholdPast56.set(Calendar.HOUR_OF_DAY,0);
            thresholdPast56.set(Calendar.MINUTE,0);
            thresholdPast56.set(Calendar.SECOND,0);
            thresholdPast56.add(Calendar.DATE,-28);

            java.util.Date …
Run Code Online (Sandbox Code Playgroud)

java spring jpql spring-data-jpa

3
推荐指数
1
解决办法
9300
查看次数

秘银与angularjs

我是Mithril JS框架的新手,并试图将Mitril视图与angularJS集成.有人曾尝试过这个吗?

我想检查如何绑定角度控制器方法以单击在Mitril中创建的元素的事件.

我通过这个代码得到了这个

var e = document.getElementById('elementId');
var scope = angular.element(e).scope();
m("a[href='javascript:;']", {
    onclick : scope.someMethod
}, "Test");
Run Code Online (Sandbox Code Playgroud)

但我不确定这是否是正确的方法.

angularjs mithril.js

2
推荐指数
1
解决办法
2136
查看次数

AngularJS ng-click指令不调用函数

我正在尝试使用ng-click来调用我的控制器中的一个函数,但是我无法让它工作.我把一切都剥离到最简单的形式,所以我现在有这个:

<button id="submitBtn" type="submit" class="btn btn-default"
  ng-click="count = count + 1; count = count + 2; alert('hello');" >Submit</button>    
Run Code Online (Sandbox Code Playgroud)

前两个语句(count = count + 1; count = count + 2;)执行得很好,但它不会调用alert函数.当我取出两个计数递增语句时,警报仍然不起作用.无论何时我尝试调用一个函数,它都会失败,但是普通的旧Javascript可以工作.

(仅仅是一个FYI,我在页面上有Javascript,阻止表单提交和触发回发).

编辑:

我将包含我的控制器代码:

myApp.controller('LawSearchController', ['$scope', function ($scope) {

    $scope.alert = function (text) {
        alert(text);
    };
}]);
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs

1
推荐指数
1
解决办法
682
查看次数

JavaFX - 在css中获取混合模式的类转换异常

JavaFX CSS指南建议通过CSS设置混合模式,如下所示:

-fx-blend-mode: blue
Run Code Online (Sandbox Code Playgroud)

但是在将以下CSS字符串应用于Text节点时,我得到了一个异常:

-fx-blend-mode:green;
-fx-fill:rgba(0.501960813999176,0.4000000059604645,0.800000011920929,1.0);
-fx-font-size:52;
-fx-font-style:normal;
-fx-font-weight:normal
Run Code Online (Sandbox Code Playgroud)

例外:

Dec 05, 2014 12:54:23 PM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: javafx.scene.paint.Color cannot be
     cast to java.lang.String' while converting value for '-fx-blend-mode' from
     inline style on Text[text="Title At Company", x=0.0, y=0.0, alignment=LEFT,
     origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System,
     style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff]
Run Code Online (Sandbox Code Playgroud)

CSS字符串是错的还是什么?我只需要通过CSS应用混合模式.

css javafx javafx-8

0
推荐指数
1
解决办法
1925
查看次数