我为JLabels和AbstractButtons编写了一个MnemonicsBuilder类.我想编写一个方便的方法setMnemonics( JFrame f ),它将迭代JFrame的每个子节点并选择JLabel和AbstractButtons.如何获取对JFrame中包含的所有内容的访问权限?我试过了:
LinkedList<JLabel> harvestJLabels( Container c, LinkedList<JLabel> l ) {
Component[] components = c.getComponents();
for( Component com : components )
{
if( com instanceof JLabel )
{
l.add( (JLabel) com );
} else if( com instanceof Container )
{
l.addAll( harvestJLabels( (Container) com, l ) );
}
}
return l;
}
Run Code Online (Sandbox Code Playgroud)
在某些情况下,这很好用.在其他情况下,它耗尽内存.我没想到什么?有没有更好的方法来搜索子组件?我的递归有缺陷吗?这不是Swing中"包含"其他东西的图片 - 例如,Swing不是Root Tree吗?
JFrame
|
|\__JMenuBar
| |
| \__JMenu
| |
| \__JMenuItem
|
|\__JPanel
| |
| |\__JButton
| |
| |\__JLabel …Run Code Online (Sandbox Code Playgroud) 我可以让 Amazon S3 使用 http 传递 CORS 标头,但不能使用 https。我如何让它与两者一起工作?如果我们使用 Akamai 作为 CDN 会怎样?
这是我的存储桶配置:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>https://*</AllowedOrigin>
<AllowedOrigin>http://*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
这是我的测试。它们之间的唯一区别是一个使用http,另一个使用https。这两种资源在浏览器中都加载得很好,但我想在可能是 https 的 CORS 设置中使用它们。
pnore@mbp> curl -i -H "Origin: http://example.com" -H "Access-Control-Request-Method: GET" -H 'Pragma: no-cache' --verbose http://my.custom.domain/path/to/file/in/bucket | head -n 15
* Adding handle: conn: 0x7fee83803a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fee83803a00) send_pipe: 1, recv_pipe: 0
% Total …Run Code Online (Sandbox Code Playgroud) 我在http://kilon.org/blog/2012/08/build-backbone-apps-using-requirejs/上关注Uzi Kilon的BackboneJS/RequireJS/backbone.LocalStorage示例.
当我git clone https://github.com/uzikilon/Todos工作得很好 - 但它使用旧版本的backbone.localstorage.但是,如果我lib/backbone.localStorage用新版本替换http://cdnjs.cloudflare.com/ajax/libs/backbone-localstorage.js/1.1.0/backbone.localStorage-min,那么我在这里得到"Uncaught TypeError:undefined is not function":https://github.com/uzikilon/Todos/blob/master/js/models/Todo.js#L3 - 为什么?我认为这与http://requirejs.org/docs/api.html#config-shim上的棘手细节有关或可能与此有关:http://blog.mostlystatic.com/2013/01/backbone-localstorage -uncaught.html.
require.config({
baseUrl: "./js/",
paths: {
jquery: 'lib/jquery-1.8.2',
underscore: 'lib/underscore-1.4.2',
backbone: 'lib/backbone-0.9.2',
// 'backbone.localStorage': 'lib/backbone.localStorage'
'backbone.localStorage': 'http://cdnjs.cloudflare.com/ajax/libs/backbone-localstorage.js/1.1.0/backbone.localStorage-min'
},
shim: {
underscore: {
exports: "_"
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backbone.localStorage': {
deps: ['backbone'],
exports: 'Backbone'
}
}
});
Run Code Online (Sandbox Code Playgroud) 我正在测试其他人的Web应用程序,该应用程序依赖于iphone/android html5 localstorage.我曾尝试的Opera Mobile模拟器,铬12.07,Firefox的5.01,歌剧11.5和Safari 5.1,Safari浏览器5.1与iPhone UA和IE 9.08.据我所知,他们都没有支持localstorage.我需要启用其中一个浏览器上的模式来测试依赖于Windows中的localstorage的应用程序吗?是否有其他浏览器我没有想过可能有本地存储支持?