在下面的代码中,是否可以从else块调用错误函数?
$.getJSON('something.php', function(data) {
if (data.error === undefined) {
} else {
// How can I call the error function below?
}
}).error(function() {
// This is the error function the be called.
});
Run Code Online (Sandbox Code Playgroud) 我想创建一个3D NumPy数组,其序列号如下:
[[[11 27 43]
[12 28 44]
[13 29 45]
[14 30 46]]
[[15 31 47]
[16 32 48]
[17 33 49]
[18 34 50]]
[[19 35 51]
[20 36 52]
[21 37 53]
[22 38 54]]
[[23 39 55]
[24 40 56]
[25 41 57]
[26 42 58]]]
Run Code Online (Sandbox Code Playgroud)
我做到了这一点:A = np.arange(11, 59).reshape((4, 4, 3))但我得到了这个:
[[[11 12 13]
[14 15 16]
[17 18 19]
[20 21 22]]
[[23 24 25]
[26 27 28]
[29 30 31]
[32 …Run Code Online (Sandbox Code Playgroud) 我在JPanel上使用以下代码绘制了BufferedImage.
protected void paintComponent(Graphics g) {
if (image != null) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
double x = (getWidth() - scale * imageWidth) / 2;
double y = (getHeight() - scale * imageHeight) / 2;
AffineTransform at = AffineTransform.getTranslateInstance(x, y);
at.scale(scale, scale);
g2.drawRenderedImage(image, at);
}
}
Run Code Online (Sandbox Code Playgroud)
如何向该图像添加鼠标单击侦听器?另外,我想获得图像的点击坐标,而不是JPanel.
如何以编程方式触发更改侦听器JSlider?
我试图使用这个jQuery脚本调用bit.ly API:
$.get('http://api.bit.ly/shorten?login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&version=2.0.1&longUrl=www.wordpress.com', function(data) {
alert(data);
});
Run Code Online (Sandbox Code Playgroud)
但是firebug说"405方法不允许".怎么了?非常感谢.
如何将JButton与JComboBox"组合"并将其放在JToolbar上,如下图所示:
?