目前我正在填充我的JComboBox:
countryBox = new JComboBox(countryList.toArray(new String[countryList.size()]));
Run Code Online (Sandbox Code Playgroud)
但是,在使用我的程序时countryList,我希望以不同的方式填充我的JComboBox.我尝试使用该操作来更改我的JComboBox:
countryBox.addActionListener(new ActionListener() {
countryBox = new JComboBox(countryList.toArray(new String[countryList.size()]));
}
Run Code Online (Sandbox Code Playgroud)
但是,它并没有改变它的价值.对我来说,countryBox似乎预先填充了之前的数据.任何建议我能做什么?
我感谢你的回答!
我想在面板上放置一个表格growx以及wraps下一个组件。我是这样做的:
JPanel panel = new JPanel(new MigLayout(""));
panel.add(showTable(), "growx wrap");
Run Code Online (Sandbox Code Playgroud)
但是,我得到了错误: Illegal Constraint: 'growx wrap'
感谢您的回复!
我的错误是我的两个表的表头没有显示.现在我正在设置标题new JTable(data, columnNames).
这是一个显示我的问题的例子:
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import net.miginfocom.swing.MigLayout;
public class Test extends JFrame {
private static final long serialVersionUID = -4682396888922360841L;
private JMenuBar menuBar;
private JMenu mAbout;
private JMenu mMain;
private JTabbedPane tabbedPane;
public SettingsTab settings = new SettingsTab();
private void addMenuBar() {
menuBar = new JMenuBar();
mMain = new JMenu("Main");
mAbout = new JMenu("About");
menuBar.add(mMain); …Run Code Online (Sandbox Code Playgroud) 我正在使用php 7.1.8,我在我的mysql数据库中保存了以下字符串:
$dat = a:5:{i:0;s:4:"6162";i:1;s:4:"6160";i:2;s:4:"6236";i:3;s:4:"6326";i:4;s:4:"6308";}
我尝试$dat使用以下内容进行转换:
$dat = json_decode($dat, true);
但是,json_decode()回报null.
有什么建议我做错了吗?
我想过滤掉我的具有null或""值的对象数组中的对象。
let data = [{
"name": "Product 2",
"link": "/stock/product2",
"category": "234",
"description": ""
}, {
"name": "Product 1",
"link": "/stock/product1",
"category": "1231",
"description": ""
}, {
"name": "",
"link": null,
"ticker": "",
"description": ""
}]
data = data.filter(cv => (cv.name === "" && cv.link === null));
console.log(JSON.stringify(data))Run Code Online (Sandbox Code Playgroud)
如您在上面所看到的,我目前得到了假对象。我想回来:
{
"name": "Product 2",
"link": "/stock/product2",
"category": "234",
"description": ""
}, {
"name": "Product 1",
"link": "/stock/product1",
"category": "1231",
"description": ""
}
Run Code Online (Sandbox Code Playgroud)
有什么建议我做错了吗?
我想在我的视图中解析这个控制器:
testapp.controller("searchController", function($scope, $rootScope, $http, $location) {
var load = function() {
console.log('call load()...');
var url = 'products.json';
if($rootScope && $rootScope.appUrl) {
url = $rootScope.appUrl + '/' + url;
}
$http.get(url)
.success(function(data, status, headers, config) {
$scope.product = data;
angular.copy($scope.product, $scope.copy);
});
}
load();
});
Run Code Online (Sandbox Code Playgroud)
但是我已经实现了这样的解析:
<div class="container main-frame" ng-app="testapp"
ng-controller="searchController" ng-init="init()">
<h1 class="page-header">Products</h1>
<table class="table">
<thead>
<tr>
<th width="25px">ID</th>
<th>TITLE</th>
<th>PRICE</th>
<th>Description</th>
<th width="50px"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="p in product">
<td>{{p.id}}</td>
<td>{{p.title}}</td>
<td>{{p.price}}</td>
<td>{{p.description}}</td>
<!-- ng-show="user.id &&user.id==e.user_id" --> …Run Code Online (Sandbox Code Playgroud) 我想使用saveDialog初始化一个帧,但是当使用它时chooser.showSaveDialog(this);我得到一个错误:
public void initialize() {
JFrame frame = new JFrame();
Container content = frame.getContentPane();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Menu
JMenu menu = new JMenu("File");
menu.add(new AbstractAction("Make Image") {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
int option = chooser.showSaveDialog(this);
if(option == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
writeJPEGImage(file);
}
}});
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
JMenuBar menuBar = new JMenuBar();
menuBar.add(menu);
frame.setJMenuBar(menuBar);
content.add(tree);
frame.pack();
frame.setVisible(true);
}
Run Code Online (Sandbox Code Playgroud)
错误:
JFileChooser类型中的方法showSaveDialog(Component)不适用于参数()
我知道这个方法通常会得到一个Component,但是我的类中没有,因为我在这个方法中加载它.
任何建议如何解决?
我感谢你的回答!
PS.: new Test()确实有效,但我必须给它当前的组件!
我写了以下数据库查询以获取具有一定偏移量的所有帖子:
async function getPaginationPosts(start, size) {
try {
const posts = await knex("posts").select().where({
deleted: false,
}).orderBy("createdAt").limit(size).offset(start)
} catch (e) {
console.log(e.message)
console.log(e.stack)
}
return posts
}
Run Code Online (Sandbox Code Playgroud)
但是,我得到以下 Unhandled Promise Rejection
(node:1824) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: posts is n
ot defined
(node:1824) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejection
s that are not handled will terminate the Node.js process with a non-zero exit code.
Run Code Online (Sandbox Code Playgroud)
我的问题是,我在控制台中没有得到有关该错误的任何进一步信息。
您网站上的任何建议:
预先感谢您的答复!
更新资料
我将功能更改为以下内容:
async …Run Code Online (Sandbox Code Playgroud) 我正在使用 jdbc 连接查询数据库:
List<Map<String, Object>> rows = jdbcTemplate.queryForList(SELECT_QUERY);
for(Map row : rows) {
Results result = new Results();
result.setResultValueDouble((Double)row.get("AMOUNT"));
//add the data object to the list
resultList.add(result);
}
Run Code Online (Sandbox Code Playgroud)
但是,我查询的对象是 BigDecimal,我想将其转换为普通双精度。使用强制转换不起作用并给我一个ClassCastException.
有什么建议如何正确地投射这个对象吗?
感谢您的回复!
我创造了RegisterController.groovy出来的spring ui package.
当我创建它时,它看起来像这样:
class RegisterController extends grails.plugin.springsecurity.ui.RegisterController{
}
Run Code Online (Sandbox Code Playgroud)
然后我只是将初始复制RegisterController.groovy到我的模板中.
package com.testApplication.register
import grails.plugin.springsecurity.SpringSecurityUtils
import grails.plugin.springsecurity.authentication.dao.NullSaltSource
import grails.plugin.springsecurity.ui.RegistrationCode
import groovy.text.SimpleTemplateEngine
class RegisterController extends grails.plugin.springsecurity.ui.RegisterController {
// override default value from base class
static defaultAction = 'index'
// override default value from base class
static allowedMethods = [register: 'POST']
def mailService
def messageSource
def saltSource
def index() {
def copy = [:] + (flash.chainedParams ?: [:])
copy.remove 'controller'
copy.remove 'action'
[command: new RegisterCommand(copy)]
}
def …Run Code Online (Sandbox Code Playgroud) java ×5
swing ×4
javascript ×3
angularjs ×1
async-await ×1
bigdecimal ×1
casting ×1
double ×1
grails ×1
grails-2.0 ×1
groovy ×1
jcombobox ×1
jtable ×1
jtableheader ×1
knex.js ×1
miglayout ×1
mysql ×1
node.js ×1
php ×1
promise ×1
spring ×1