我试图在JavaFX中显示GridPane场景的网格线,但尽管调用它们仍未显示setGridLinesVisible(true).我究竟做错了什么?
我想在程序的主菜单上显示网格线,所以我可以告诉它在哪里放置节点.不幸的是,当我运行程序时,显示的所有内容都是带有单个按钮的空白屏幕.
我的MainMenu课程:
package screens;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
/**
* Creates the main menu Pane object and returns it.
* @author LuminousNutria
*/
public class MainMenu {
public MainMenu() {}
public Pane getPane() {
GridPane grid = new GridPane();
grid.setGridLinesVisible(true);
Button bttn = new Button("button");
grid.add(bttn, 2, 2);
return grid;
}
}
Run Code Online (Sandbox Code Playgroud)
我的主要课程:
package mainPackage;
import screens.*;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
/**
* Displays the Pane.
* @author LuminousNutria
*/
public class Main …Run Code Online (Sandbox Code Playgroud) 是否可以在不使用的情况下使所有GridPane的网格线永久可见setGridLinesVisible()?
我知道这setGridLinesVisible()仅用于调试目的,我想显示网格线以方便最终用户.
另外,我需要处理Pane容器而不是Canvas.
我的程序能够在Pane类型或Pane子类型父容器上添加,删除,修改,移动等形状对象和组.
谢谢
我对GDScript 语言的 Godot Docs 的一部分感到困惑。在页面中间的“引用函数”部分,它说您不能将函数存储在变量中,然后似乎立即自相矛盾。
Godot 函数可以存储在变量中吗?
引用函数
与 Python 不同,函数不是 GDScript 中的第一类对象。这意味着它们不能存储在变量中,不能作为参数传递给另一个函数或从其他函数返回。这是出于性能原因。
要在运行时按名称引用函数(例如,将其存储在变量中,或将其作为参数传递给另一个函数),必须使用 call 或 funcref 助手:
对不起.我相信之前已在这里得到了回答.但是,我找不到它.
基本上,我有一个try/catch块,无论我做什么,我似乎都会收到警告或错误.catch(IOException e)导致"过于宽泛"的警告.catch (FileNotFoundException e)导致需要IOException catch的代码出错.catch (FileNotFoundException | IOException e)导致"多捕获类型必须是不相交的"错误.最后,放置两个catch块(每个异常一个)会导致"'catch'分支与'FileNotFoundException'相同"警告.
我不想编辑IntelliJ的警告系统,因为它很有用.
如何在不发出警告或错误的情况下使try/catch块工作?
@Override
public void readFile(File inFile) {
try {
FileReader fr = new FileReader(inFile);
BufferedReader br = new BufferedReader(fr);
// get the line with the sizes of the puzzle on it
String sizes = br.readLine();
// find the height of the puzzle
int height = Character.getNumericValue(sizes.charAt(0));
// create a puzzleArr with a height
this.puzzleArr = new char[height][];
// create the char[] array of …Run Code Online (Sandbox Code Playgroud) 我在一个接口中输入了一堆String []数组.我希望IntelliJ-IDEA按字母顺序排列元素.
我不是在谈论在运行时或编译时的排序.我想要修改实际的java /文本文件.
如何让IntelliJ-IDEA按字母顺序和".java"文件本身对String []数组元素进行排序?
当前状态:
String[] RACES = {
"human", "elf", "small folk", "orc", "goblin", "aasimar", "tiefling"};
Run Code Online (Sandbox Code Playgroud)
期望状态:
String[] RACES = {
"aasimar", "elf", "goblin", "human", "orc", "small folk", "tiefling"};
Run Code Online (Sandbox Code Playgroud) 我正在尝试将Python Voronoi 生成器转换为 Java,但我对关键字参数不太熟悉,并且对作为函数参数编写的关键字参数感到困惑。
我读过这个问题,但它只涉及调用参数,而不是定义它们。
看起来该功能只是设置a为b“无”。我不明白为什么这是必要的。为什么不直接输入None而不是使用这样的参数呢?
在函数定义中使用等于 None 的关键字参数有什么意义?
功能:
class Arc:
p = None
pprev = None
pnext = None
e = None
s0 = None
s1 = None
def __init__(self, p, a=None, b=None):
self.p = p
self.pprev = a
self.pnext = b
self.e = None
self.s0 = None
self.s1 = None
Run Code Online (Sandbox Code Playgroud) 我试图了解C ++中组成与继承之间的语法差异。
我希望有人会提供两个简单的例子。使用组成的类的一个示例,使用继承的类的一个示例。
我想将二进制值加一,但我仍然不太熟悉 agda 中递归的工作原理。
为什么我在这里没有得到正确的输出?
Bin 类型定义
data Bin : Set where
?? : Bin
_O : Bin ? Bin
_I : Bin ? Bin
Run Code Online (Sandbox Code Playgroud)
我的增量函数
inc : Bin ? Bin
inc ?? = ?? I
inc (x O) = ?? I
inc (x I) = (inc x) I
Run Code Online (Sandbox Code Playgroud) 有时我会阅读在线javadocs并仍然想知道特定方法是如何工作的.例如,我最近在查看用于Java-11的ArrayList在线javadoc,我无法判断"remove"方法是否缩短了数组的长度,或者只是将空值保留在曾经是元素的位置.
如何查看IntelliJ-IDEA中默认Java类的代码实现?
我以前一起使用过 JavaFX 和 IntelliJ,通常可以让它工作。现在我正在尝试使用 HTMLEditor,尽管为 IntelliJ 提供了我的 JavaFX 库目录的路径并添加了我总是对“MyHTMLEditor”类的 vm 选项执行的相同指令,但我仍然不断收到调用目标异常。
我已经在其他程序上使用相同的设置成功运行了 JavaFX,所以我觉得可能需要将一些模块添加到 vm 选项中才能使 HTMLEditor 工作,但我不知道是什么。
如何阻止我的 HTMLEditor 对象产生错误?
我正在使用 OpenJFX 12 和 Oracle Java 12。
vm 选项说明:
--module-path /home/myName/Java_Libraries/javafx-sdk-12.0.1/lib --add-modules=javafx.controls,javafx.fxml
该程序:
public class MyHTMLEditor extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("My HTMLEditor");
stage.setWidth(650650);
stage.setHeight(300);
final HTMLEditor htmlEditor = new HTMLEditor();
htmlEditor.setPrefHeight(245);
Scene scene = new Scene(htmlEditor);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
Exception in Application start method
java.lang.reflect.InvocationTargetException …Run Code Online (Sandbox Code Playgroud) java ×6
javafx ×3
gridpane ×2
agda ×1
arrays ×1
binary ×1
c++ ×1
class ×1
composition ×1
exception ×1
file-io ×1
function ×1
gdscript ×1
godot ×1
inheritance ×1
java-8 ×1
keyword ×1
nonetype ×1
null ×1
oop ×1
pane ×1
python ×1
recursion ×1
scripting ×1
sorting ×1
string ×1
try-catch ×1
warnings ×1