我正在学习javaFX,我的问题是我有一些带有选择框和按钮的简单窗口。这个窗口是通过 FXML 定义的,它也与控制器类相关联。我想知道,如何用控制器类中的数据填充这个选择框,因为使用@FXML 引用这个选择框会抛出NullpointerEception
编辑 - 添加源代码 FXML 代码
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="240.0"
prefWidth="320.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="supermarket.ManageWindowCC">
<children>
<ChoiceBox fx:id="countChoiceBox" layoutX="44.0" layoutY="71.0" prefHeight="25.0" prefWidth="191.0"/>
<Label layoutX="44.0" layoutY="54.0" text="To change item's count, choose one"/>
<TextField layoutX="140.0" layoutY="129.0" prefHeight="25.0" prefWidth="24.0"/>
<Label layoutX="123.0" layoutY="112.0" text="New count"/>
<Button layoutX="126.1875" layoutY="171.5" mnemonicParsing="false" text="Submit"/>
</children>
Run Code Online (Sandbox Code Playgroud)
Java控制器代码:
public class ManageWindowCC {
@FXML
private ChoiceBox countChoiceBox;
public void onChangeCountClick(ActionEvent actionEvent) {
try {
Parent root = FXMLLoader.load(getClass().getResource("ChangeCount.fxml"));
Stage newStage = new Stage();
newStage.setTitle("Change …Run Code Online (Sandbox Code Playgroud) 我正在学习haskell,我正在尝试编写一些简单的函数.一切顺利,直到我使用功能isUpper.由于此错误,我无法编译项目:
[1 of 1] Compiling Main ( C:\Users\...\src\Main.hs, interpreted )
C:\Users\...\src\Main.hs:147:25:
Not in scope: `isUpper'
Failed, modules loaded: none.
Prelude>
Run Code Online (Sandbox Code Playgroud)
我的代码:
module Main where
main::IO()
main = undefined
stringIsUpper [] = True
stringIsUpper (x:ys) = (isUpper x) && (stringIsUpper(ys))
Run Code Online (Sandbox Code Playgroud)
此代码的目标应该只是检查插入的字符串是否由大写字母组成.我正在使用EclipseFP进行开发感谢您的帮助
对不起这个(也许)愚蠢的问题.我需要在我的java项目中创建一些本地数据库,所以我决定使用Apache Derby Client.我正在使用IntelliJ IDEA 13 Ultimate,我的问题是我不知道,如何创建本地数据库.Jetbrains网站上的教程没有用,因为只有关于连接到远程数据库的文章,而不是本地文章(或者至少我还没有找到它们).
到目前为止我做了什么:
用户名和密码相同: admin
test connection,抛出此错误:错误apply和ok,它说,它的连接,但例外的是仍然存在.所以你知道问题出在哪里吗?我有一个名为DatabaseSetting.java的小型配置类
package issuetrackinglite;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DatabaseSetting {
private String dbURL = "jdbc:derby://localhost:1527/MallDB;create=true";
private String user = "admin";
private String password = "admin";
private Connection connection;
public static final String CREATE_ITEMS_DB = "CREATE TABLE items (item_id INTEGER NOT NULL, item_name VARCHAR(20) NOT NULL, item_price REAL NOT NULL, multiplicity_shop INTEGER NOT …Run Code Online (Sandbox Code Playgroud) 运行非常简单的测试,我在基本授权标头中传递无效凭据,我希望服务器返回 401
const request = require('request-promise');
const expect = require('chai').expect;
const basicToken = require('basic-auth-token');
describe('PUT Endpoint', function () {
it.only('should return unauthorized if basic token is incorrect', async function (done) {
let options = {
url: `http://url_to_handle_request`,
resolveWithFullResponse: true,
headers: {
Authorization: `Basic ${basicToken('INVALID', 'CREDENTIALS')}`
}
};
try {
await request.put(options); // this should throw exception
} catch (err) {
expect(err.statusCode).to.be.equal(401); // this is called
}
done();
});
});Run Code Online (Sandbox Code Playgroud)
此代码的问题在于该expect子句解析为 false(因为服务器响应例如 403)并且测试以错误结束:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: …Run Code Online (Sandbox Code Playgroud)