小编BnM*_*McG的帖子

无法覆盖SwingWorker中的process()方法

我有一个SwingWorker类,如下所示:

    class RemotePlayersWorker extends SwingWorker<String[][], Object> {
        PlayerCanvas parent;
        RemoteHandler remote;
        String[][] players;
        int maximumConnections;

        public RemotePlayersWorker(PlayerCanvas parentCanvas, RemoteHandler remoteHandle) {
            this.parent = parentCanvas;
            this.remote = remoteHandle;
        }

        @Override
        protected String[][] doInBackground() throws Exception {
            System.out.println("TEST 1");
            players = remote.getConnectedPlayers();
            publish(players);
            return players;
        }

        @Override
        protected void process(List<String[][]> chunks) {
            for (String[][] chunk : chunks) {
                 // no need for the c variable
                 System.out.println(chunk.toString());
              }
        }

        @Override 
        protected void done() {

        }
    }
Run Code Online (Sandbox Code Playgroud)

但是,我在覆盖进程(List chunks)方法时遇到错误.Eclipse告诉我这个:

The method process(List) of type …
Run Code Online (Sandbox Code Playgroud)

java swing multithreading swingworker event-dispatch-thread

6
推荐指数
2
解决办法
1684
查看次数

Laravel 在控制器中使用非 Laravel composer 包

我正在尝试在 Laravel 控制器中使用非 Laravel composer 包。我已将项目添加到 composer.json 文件中,如下所示:

"require": {
    "laravel/framework": "5.0.*",
    "php": ">=5.4.0",
    "abraham/twitteroauth": "0.5.2"
},
Run Code Online (Sandbox Code Playgroud)

然后我跑了:

composer update
Run Code Online (Sandbox Code Playgroud)

在项目中,它已按预期将软件包安装在 vendor/ 目录中,我在那里看到了它。但是,当将以下代码添加到控制器时:

<?php
namespace App\Http\Controllers;

class HomeController extends Controller {

    use Abraham\TwitterOAuth\TwitterOAuth;

public function index()
{
    $o = new TwitterOauth();
    return view('home');
}
Run Code Online (Sandbox Code Playgroud)

Laravel 返回以下错误:

未找到特性“App\Http\Controllers\Abraham\TwitterOAuth\TwitterOAuth”

我怀疑这与命名空间已经声明的事实有关,但我对 PHP 命名空间的了解不足以解决这个问题。

欢迎任何帮助!

php namespaces laravel laravel-5

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