我有一种情况需要连接两个二维数组.
Object[][] getMergedResults() {
Object[][] a1 = getDataFromSource1();
Object[][] a2 = getDataFromSource2();
// I can guarantee that the second dimension of a1 and a2 are the same
// as I have some control over the two getDataFromSourceX() methods
// concat the two arrays
List<Object[]> result = new ArrayList<Object[]>();
for(Object[] entry: a1) {
result.add(entry);
}
for(Object[] entry: a2) {
result.add(entry);
}
Object[][] resultType = {};
return result.toArray(resultType);
}
Run Code Online (Sandbox Code Playgroud)
我已经看过这篇文章中一维数组串联的解决方案但是无法使它适用于我的二维数组.
到目前为止,我提出的解决方案是迭代两个数组并将每个成员添加到ArrayList,然后返回该数组列表的Array().我确信必须有一个更简单的解决方案,但到目前为止还没有一个解决方案.
我正在使用 PrimeNG 和 Primeflex 开发 Angular 7 应用程序。在尝试设计基于表单的组件的样式时,我遇到了<input pInputText ...>不尊重 prime-flex 样式的元素的问题(或者至少没有按照我的预期运行)。
问题摘要
(变体 1)
我将 a<label>和<input>元素封装在两个嵌套<div>元素中,这些元素的样式为class="p-grid"和class="p-col-*"。
<div class="p-grid">
<div class="p-col-8">
<label for="description">Description</label><br/>
<input id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label for="numeric">Numeric</label><br/>
<input id="numeric" pInputText formControlName="numeric">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我预计该<input>字段会随着可用空间而增大/缩小,但它似乎具有固定宽度,不会根据可用空间或我正在使用的列数进行调整。
(变体 2)
p-grid然后,我尝试在 column-div 中嵌套另一个元素,并为每个元素提供完整宽度:
<div class="p-grid">
<div class="p-col-8">
<div class="p-grid">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
</div>
<div class="p-col-4">
<div class="p-grid">
<label …Run Code Online (Sandbox Code Playgroud) 我有一个用户请求将加速器添加到子菜单(JMenu),这将允许用户按下快捷方式并使相应的子菜单"折叠",显示其包含的菜单项.
我不记得每个人都看过这样的东西(用Java或任何其他语言).我们的应用程序是使用Swing用Java编写的.我们有许多带有加速器的JMenuItem,但是当我尝试向JMenu添加加速器时,我得到以下异常:
java.lang.Error:没有为JMenu定义setAccelerator().请改用setMnemonic().
我试过使用MenuDemo!代码进一步试验这一点.
这是我试过的:
//a submenu
menu.addSeparator();
submenu = new JMenu("A submenu");
submenu.setMnemonic(KeyEvent.VK_S);
submenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK));
Run Code Online (Sandbox Code Playgroud)
最后一行是我添加的一行,导致异常.
我已经尝试了大量的谷歌搜索,但我能找到的是关于如何将加速器添加到JMenuItem的文章.
似乎JMenu不支持这种原生.有没有解决方法来实现这种行为?
我正在尝试在我的 angular 7 项目中使用save-svg-as-png库。
但是,我无法让它发挥作用。我已经使用
npm install --save save-svg-as-png
Run Code Online (Sandbox Code Playgroud)
我可以在 node_modules 下看到库。
不幸的是,该库是一个旧式的 javascript 库,我不知道我需要做什么才能在我的打字稿组件中访问它。
自述文件引用了显然存在类型定义的Typings库。但是,Typings 页面提到它在 TypeScript 2 中已被弃用,所以我没有追求这个。
显然有@types/save-svg-as-png支持原生 Angular 2+,但是当我尝试安装它时
npm install --save @types/save-svg-as-png
Run Code Online (Sandbox Code Playgroud)
找不到库 ( npm ERR! code 404)。
我用谷歌搜索了更多并在 github上遇到了这个问题,有人显然已经通过将它包含在 angular-cli.js 文件中来让它与 Angular 2 一起工作,但是随着对 Angular 的更改,这个文件在版本 7 中不再存在,我不知道现在需要怎么做。
我还发现了以下关于如何将 javascript 库集成到 Angular 2+ 中的文章,但其中大部分依赖于 @types 可用(它们不是,见上文)并且只有一个简短的部分关于如何提供你自己的库typings.d.ts文件,但玩了很长一段时间后,我没有进一步。是否有更详细的解释说明如何使用这种方法?
我还在stackoverflow 上找到了这篇关于如何将基于 IIFE 的库集成到打字稿应用程序中的文章,但没有让它工作。
我已将以下行添加到我的index.html文件中 …
angular ×2
java ×2
accelerator ×1
angular6 ×1
angular7 ×1
arrays ×1
css ×1
iife ×1
javascript ×1
jmenu ×1
key-bindings ×1
primeflex ×1
primeng ×1
swing ×1