我收到了错误
未捕获的TypeError:无法设置未定义的属性"0"
出于某种原因,在这一行
world_map_array[i][z]="grass.gif|ongrass.gif|collision.gif|above.gif";
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
谢谢你的帮助
var x_world_map_tiles = 100;
var y_world_map_tiles = 100;
var world_map_array = new Array(x_world_map_tiles);
for (i=0; i<=2; i++)//create a two dimensional array so can access the map through x and y coords map_array[0][1] etc.
{
world_map_array[i]=new Array(y_world_map_tiles);
}
for (i=0; i<=x_world_map_tiles; i++)//just a test
{
for (z=0; z<=y_world_map_tiles; z++)//just a test
{
world_map_array[i][z]="grass.gif|ongrass.gif|collision.gif|above.gif";
}
}
Run Code Online (Sandbox Code Playgroud) 我有模态窗口.我希望窗口能够最小化和关闭,但不能调整大小或最大化.
如何禁用最大化按钮并防止调整窗口大小?
当 sql 查询预计不会返回任何结果时,我似乎无法从 db.query 中获取 ErrNoRows 。
results, err := database.Query("SELECT title FROM accountProject WHERE accountID=? AND MATCH(title) AGAINST(?)", accountID, query)
if err != nil {
if err == sql.ErrNoRows {
return errProjectDoesNotExist
}
return err
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在系统临时文件夹中创建一个唯一的临时目录,并且已经阅读了tmpnam()的安全性和文件创建问题.
我写了下面的代码,并想知道它是否会满足这些问题,我是否正确使用了tmpnam()函数并抛出了filesystem_error?我是否应该为其他事情添加检查(例如temp_directory_path,它也会引发异常)?
// Unique temporary directory path in the system temporary directory path.
std::filesystem::path tmp_dir_path {std::filesystem::temp_directory_path() /= std::tmpnam(nullptr)};
// Attempt to create the directory.
if (std::filesystem::create_directories(tmp_dir_path)) {
// Directory successfully created.
return tmp_dir_path;
} else {
// Directory could not be created.
throw std::filesystem_error("directory could not be created.");
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个TreeView显示目录内容的目录,例如:
ABC
BCD
123.php
Run Code Online (Sandbox Code Playgroud)
其中 ABC 和 BCD 都是目录。我觉得我错过了一些东西,因为TreeView在删除完整目录位置之前工作正常,但是一旦删除它,它就不会像上面那样显示。
public void displayTreeView(String inputDirectoryLocation, CheckBoxTreeItem<String> mainRootItem) {
// Creates the root item.
CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>(inputDirectoryLocation);
// Hides the root item of the tree view.
treeView.setShowRoot(false);
// Creates the cell factory.
treeView.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
// Get a list of files.
File fileInputDirectoryLocation = new File(inputDirectoryLocation);
File fileList[] = fileInputDirectoryLocation.listFiles();
// Loop through each file and directory in the fileList.
for (int i = 0; i < fileList.length; i++) …Run Code Online (Sandbox Code Playgroud) 我创建了一个抽象类和一个具体的子类:
//bca.h
#include <string>
class bca {
public:
virtual std::string get_virtual_year() const = 0;
};
Run Code Online (Sandbox Code Playgroud)
//bca_interface.h
#include "bca.h"
class bca_interface : public bca {
public:
std::string get_virtual_year() const override;
};
Run Code Online (Sandbox Code Playgroud)
//bca_interface.cpp
#include "bca_interface.h"
std::string bca::get_virtual_year() const override {
return "";
}
Run Code Online (Sandbox Code Playgroud)
当我bca_interface.cpp用g ++ 编译时,我得到:
//bca.h
#include <string>
class bca {
public:
virtual std::string get_virtual_year() const = 0;
};
Run Code Online (Sandbox Code Playgroud) 如何检测何时CheckBoxTreeItem选择或未选择?
我是否使用事件处理程序或更改侦听器?我要检查什么事?是否有我可以收听的事件列表,如checkboxtreeitem.selection或其他什么?
谢谢
我试图设置我的选择框的默认选定项目,但是它没有按预期工作......
<ChoiceBox fx:id="d" value="- Select choice -">
<String fx:value="hellow"/>
</ChoiceBox>
Run Code Online (Sandbox Code Playgroud)