我创建了一些文本框,我希望用户在其中输入十进制值.在我曾经使用的每个应用程序中,当我在文本框中键入内容并按Enter键时,该值被接受并且文本框失去焦点.我怎么能在我的应用程序中执行此操作?我知道用一个关键事件做它应该相对容易,但也许有一个命令或什么的.我搜索了stackoverflow,但我发现有关如何在输入后保持焦点的问题...
我不知道是否有人能从标题中理解我的问题,但这里有更具体的描述.我有一个类,我在其中创建了一个FlowPane,其中我添加了另一个类的对象(在VBoxes中打包的图像).每个VBox都有ContextMenu,其中是MenuItem"Remove File".我的问题是,如何在VBox类内部删除此对象.这是我的代码的一小部分:
//删除后,整个代码在编辑后面
我正在访问我的CustomPane(我的FlowPane类,具有指定属性)的代码工作,因为我可以删除对象,如果我是通过它们的索引,但当我删除其中一个,其他的索引更改,所以我正在寻找另一种解决方案.我需要在代码中专门删除类的对象.
好吧所以这里所谓的sscce,我不知道,从现在开始:
package sscce;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class Sscce extends Application {
@Override
public void start(Stage primaryStage) {
CustomPane root = new CustomPane();
root.setPadding(new Insets(20));
root.setHgap(10);
root.setVgap(10);
for (int i = 0; i < 10; i++) {
RectangleBox recB = new RectangleBox();
root.getChildren().add(recB);
} …Run Code Online (Sandbox Code Playgroud) 我在发送带参数的请求时遇到问题。我有在 PHP 中发送请求的示例,但我不知道在 RestSharp 中它应该是什么样子:
如您所见,在示例中,参数被添加到私钥(我也做过),然后还有这个 CURLOPT_POSTFIELDS,其中也添加了参数。我尝试通过 AddParameter、AddBody、AddJsonBody 来做,但没有任何效果。当我将参数连接到私钥时,响应始终为空,如果我删除它,我会得到响应,但我的参数被忽略。
string data = "{\"Paging\":{\"per_page\":\"" + 10 + "\"}}";
RestClient client = new RestClient("api");
string header = "WMS " + publicKey + ":" + GetMd5Hash(privateKey + data);
IRestRequest request = new RestRequest("products", Method.GET);
request.AddHeader("Content-Type", "application/json; charset=utf-8");
request.AddHeader("Authorization", header);
request.AddHeader("Content-Length", data.Length.ToString());
//request.RequestFormat = RestSharp.DataFormat.Json;
request.AddParameter("Paging", new { per_page = 10 });
IRestResponse response = client.Execute(request);
Encoding encoding = Encoding.GetEncoding("utf-8");
var result = encoding.GetString(response.RawBytes);
Run Code Online (Sandbox Code Playgroud)
我能够使用 fiddler 跟踪 php 请求,原始请求如下所示:
获取 API HTTP/1.1 主持人:api 编译指示:无缓存 …