我有一个只有一个FXML文件的JavaFX应用程序.在这个文件中,我有一个AnchorPane,里面有一个StackPane.这是截图:

当我启动此应用程序时,我想使用AnchorPane自动调整StackPane的大小.从而; StackPane将自动获得当前可用的宽度和高度.在我调整应用程序大小的那一刻,AnchorPane正在自动调整大小,但StackPane保持固定大小.
如何自动调整StackPane的大小并使其在父面板中完全拉伸?
我的守则
Main.java
package app;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(root,800,600);
scene.getStylesheets().add(this.getClass().getResource("/app/style1.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
}
Run Code Online (Sandbox Code Playgroud)
MainController.java
package app;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
public class MainController implements Initializable {
@FXML
private AnchorPane anchorPane;
@FXML …Run Code Online (Sandbox Code Playgroud) 我有一个在服务器(测试服务器)上运行的powershell脚本,并读取他的客户端(DC1)的日志文件.
DC1上启用了远程桌面和远程协助.
Get-EventLog System -ComputerName test-server -Source Microsoft-Windows-Winlogon # WORKS
Get-EventLog System -ComputerName DC1 -Source Microsoft-Windows-Winlogon # DOESN'T WORK
Run Code Online (Sandbox Code Playgroud)我在test-server上运行这个脚本.正如您在test-server上读取本地日志文件时所看到的那样工作正常但如果我尝试远程读取DC1的日志文件,则会收到错误" Get-EventLog:找不到网络路径 ".
错误的屏幕截图:

如何使用Get-EventLog避免此错误并从测试服务器读取DC1的日志文件?
我坚持使用javassist.我在运行时向对象类添加了一个新方法.
我的对象类:
package tmp3;
public class Car {
public Car(){}
}
Run Code Online (Sandbox Code Playgroud)
我的考试班:
package tmp3;
import java.lang.reflect.Method;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.CtNewMethod;
public class TestMain {
public static void main(String[] args) {
try {
CtClass ctclass = ClassPool.getDefault().get("tmp3.Car");
CtMethod newmethod = CtNewMethod.make("public void testPrint() { System.out.println(\"test ok\"); }",ctclass);
ctclass.addMethod(newmethod);
ctclass.writeFile();
for(Method me: ctclass.toClass().getDeclaredMethods()){ //test print, ok
System.out.println(me.getName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
但在那之后,我不知道如何调用(调用)它.我已经读过javassist没有能力调用方法.那我怎么能调用我刚刚用javassist添加的方法呢?
我在两天内尝试过很多东西但没有成功.你能帮帮我吗?
如果需要超过2分钟,我需要取消UpdateDatabase()函数.我已经尝试过canceltokens和计时器,但我无法解决这个问题(找不到任何合适的例子).
你能帮帮我吗?
App.xaml.cs
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
await PerformDataFetch();
}
internal async Task PerformDataFetch()
{
await LocalStorage.UpdateDatabase();
}
Run Code Online (Sandbox Code Playgroud)
LocalStorage.cs
public async static Task<bool> UpdateDatabase()
{
await ..// DOWNLOAD FILES
await ..// CHECK FILES
await ..// RUN CONTROLES
}
Run Code Online (Sandbox Code Playgroud)
根据答案编辑我的课程.
App.xaml.cs保持不变.编辑UpdateDatabase()并在LocalStorage.cs中添加新方法RunUpdate():
public static async Task UpdateDatabase()
{
CancellationTokenSource source = new CancellationTokenSource();
source.CancelAfter(TimeSpan.FromSeconds(30)); // how much time has the update process
Task<int> task = Task.Run(() => RunUpdate(source.Token), …Run Code Online (Sandbox Code Playgroud) 根据我想要构建forkJoin()方法的函数的参数.
例如:
码:
getAllByIds(parameter1: any, parameter2: any) {
let itemList = new Array();
return Observable.forkJoin(
this.http.get('rest/fillin/ids/' + parameter1) // don't put this request for parameter1 if it is empty
.map((res: Response) => res.json()),
this.http.get('rest/textitem/ids/' + parameter2) // don't put this request for parameter2 if it is empty
.map((res:Response) => res.json())
).map(
data => {
itemList.push(data[0]);
itemList.push(data[1]);
return itemList;
}
);
}
Run Code Online (Sandbox Code Playgroud)
那么,是否有可能像这样建立forkJoin()?
我想首先选择文件,然后通过另一个按钮而不是组件自己的Upload按钮开始上传这些文件.
我怎样才能做到这一点?
我试过的示例代码:
<button pButton type="button" label="Start Upload"
(click)="startUpload()"></button>
<p-fileUpload #fileInput name="fileIcon"
url="rest/batch/file/multimedia/"></p-fileUpload>
@ViewChild('fileInput') fileInput:ElementRef;
constructor( private renderer: Renderer ) { }
startUpload(){
// this.fileInput.upload(); -> doesn't compile, undefined
// this.fileInput.nativeElement.upload(); -> this.fileInput.nativeElement is undefined
?????????????????
}
Run Code Online (Sandbox Code Playgroud) 我有一个Primefaces(5.0)数据表.我使用两个列过滤器:selectOneMenu(Filter1)和selectCheckboxMenu(Filter2).
两个过滤器的数据都被正确填充.selectOneMenu(Filter1)可以过滤DataTable,但selectCheckboxMenu(Filter2)在选择值后没有找到任何数据.
JSF
<p:dataTable value="#{employeeBean.employees}" var="employee" id="employeeDTable"
emptyMessage="No data" filteredValue="#{employeeBean.filteredEmployees}"
widgetVar="empWidgetVar" rowKey="#{employee.id}">
<!-- THIS WORKS -->
<p:column headerText="Filter1" filterBy="truck.id" filterMatchMode="exact">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('empWidgetVar').filter()">
<f:selectItems value="#{dropdowns.trucksWithAllOption}"/>
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{employee.truck.license}"/>
</p:column>
<!-- THIS DOESN'T WORK (Doesn't find any data) -->
<p:column headerText="Filter2" filterBy="truck.id" filterMatchMode="in">
<f:facet name="filter">
<p:selectCheckboxMenu onchange="PF('empWidgetVar').filter()" label="Vrachtwagen">
<f:selectItems value="#{dropdowns.trucksWithAllOption}"/>
</p:selectCheckboxMenu>
</f:facet>
<h:outputText value="#{employee.truck.license}"/>
</p:column>
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
dropdowns.trucksWithAllOption

渲染过滤器1

渲染Filter2

为什么selectCheckboxMenu(Filter2)找不到任何数据而selectOneMenu(Filter1)找不到相同的数据?
我有抽象的通用服务类。
export default abstract class GenericService<Type> implements CrudService<Type> {
private readonly modifiedUrl: URL;
public constructor(url: string) {
this.modifiedUrl = new URL(url, window.location.href);
}
public async get(path?: string, filter?: URLSearchParams): Promise<Type> {
try {
if (path) {
this.modifiedUrl.href += `${path}`;
}
addQueryParams(this.modifiedUrl, filter);
const response = await handleRequest(`${this.modifiedUrl}`, getFetchOptions('GET'));
const data = await response.json();
return (await data.data) ? data.data : data;
} catch (error) {
throw new Error(`Runtime error: ${error}`);
}
}
}
export async function handleRequest(input: RequestInfo, init: RequestInit): Promise<Response> …Run Code Online (Sandbox Code Playgroud) 我有一个数组$ data:
PS> $data
Datum User Computer
----- --------- --------
10/06/2013 13:10:56 geb1@TESTDOMAIN.COM DC1$
10/06/2013 13:09:25 geb2@TESTDOMAIN.COM DC2$
10/06/2013 10:05:13 geb2@TESTDOMAIN.COM DC2$
7/06/2013 16:32:47 geb1@TESTDOMAIN.COM DC1$
Run Code Online (Sandbox Code Playgroud)
我想从每台计算机的$ data数组中获取最新日期,如下所示:
PS> $result
Datum User Computer
----- --------- --------
10/06/2013 13:10:56 geb1@TESTDOMAIN.COM DC1$
10/06/2013 13:09:25 geb2@TESTDOMAIN.COM DC2$
Run Code Online (Sandbox Code Playgroud)
我真的无法得到这个结果.你能帮帮我吗?
我唯一想到的就是使用 css。我尝试通过图标属性选择它们,但没有成功。
我的CSS是在primeng css文件之后加载的:
button[icon="fa-angle-double-up"] {
display: none;
}
button[ng-reflect-icon="fa-angle-double-up"] {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
我的组件:
@Component({
template: `<p-orderList></p-orderList>`,
styles: [`
button[icon="fa-angle-double-up"] {
display: none;
}
button[ng-reflect-icon="fa-angle-double-up"] {
display: none;
}
`],
encapsulation: ViewEncapsulation.None
})
Run Code Online (Sandbox Code Playgroud)
那么还有另一种方法可以删除我想要的按钮,或者通过 css 执行此操作的正确方法是什么?
我有一个webservice,它提供数据为json形式的mysql数据库.
PHP webservice
<?php
$conn = mysql_connect('localhost','root','');
mysql_select_db('db', $conn);
$query = mysql_query("SELECT id,group FROM faq");
//$query content is:
// Array ([id]=>faq1 [group]=>hardware) Array ([id]=>faq2 [group]=>software)
$faq = array();
while($row = mysql_fetch_assoc($query)) {
$faq[] = $row // <= ????????
}
header('Content-type: application/json');
return json_encode($faq);
?>
Run Code Online (Sandbox Code Playgroud)
我得到的JSON输出
[
{
"id": "faq1",
"group": "hardware"
},
{
"id": "faq2",
"group": "software"
}
]
Run Code Online (Sandbox Code Playgroud)
我想要的JSON输出
[
{
"id": "faq1",
"group": {
"id": "hardware"
}
},
{
"id": "faq2",
"group": {
"id": "software"
}
}
] …Run Code Online (Sandbox Code Playgroud) 在父组件中,我有一个子组件。两者都有其必填字段。最后,仅当两个组件都有效时才需要启用提交按钮(在这种情况下,它们的所有必填字段都已填写)。
我怎样才能做到这一点,尤其是使用模板驱动的验证?
种子代码
父组件
@Component({
selector: 'parent-comp',
templateUrl: 'parent.html'
})
export class Parent {
}
<input pInputText name="txt1" id="txt1"
required/>
<child-comp></child-comp>
<button pButton type="button" label="Submit"
[disabled]="IF ONE OF THE COMPS IS NOT VALID"></button>
Run Code Online (Sandbox Code Playgroud)
子组件
@Component({
selector: 'child-comp',
templateUrl: 'child.html'
})
export class Child {
}
<input pInputText name="txt2" id="txt2"
required/>
Run Code Online (Sandbox Code Playgroud)