<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6582284661533567119</id><updated>2011-07-31T03:21:12.023-07:00</updated><title type='text'>Osman Celik's Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://osmanceliks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6582284661533567119/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://osmanceliks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Osman Celik</name><uri>http://www.blogger.com/profile/17228911604983990032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_7D1g3QccvEg/Si_Eq7Y23sI/AAAAAAAAAAM/NQlngvRgIlY/S220/Celik_jpg.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6582284661533567119.post-5934140068598889509</id><published>2009-06-25T09:17:00.000-07:00</published><updated>2009-06-25T09:42:13.112-07:00</updated><title type='text'>How to use Key Bindings for some Swing components in a GUI</title><content type='html'>You have a Swing Application and you want to listen for some key actions, but only when some dialog or panel is active (on focus).&lt;br /&gt;1.) Create a JPanel and move all needed components of user-dialog in it&lt;br /&gt;2.)Create a global action for this Key&lt;br /&gt;&lt;pre class="java" name="code"&gt;&lt;br /&gt;public class Myaction extends AbstractAction{&lt;br /&gt;&lt;br /&gt;public void actionPerformed(ActionEvent e) {&lt;br /&gt;System.out.println("Hello");}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;3.)Instance the action&lt;br /&gt;&lt;br /&gt;&lt;pre class="java" name="code"&gt;&lt;br /&gt;MyAction actions = new MyAction();&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4.)Use the InputMap of JPanel to listen on e.g "F2" Key and put the instanced action&lt;br /&gt;to its ActionMap.&lt;br /&gt;&lt;br /&gt;&lt;pre class="java" name="code"&gt;&lt;br /&gt;jPanel1.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F2"), "doSomething");&lt;br /&gt;&lt;br /&gt;jPanel1.getActionMap().put("doSomething", actions);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Thats all. If you have an Swing application and the focus is on a JComponent in this Panel then the action will work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6582284661533567119-5934140068598889509?l=osmanceliks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://osmanceliks.blogspot.com/feeds/5934140068598889509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://osmanceliks.blogspot.com/2009/06/how-to-use-key-bindings-for-some-swing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6582284661533567119/posts/default/5934140068598889509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6582284661533567119/posts/default/5934140068598889509'/><link rel='alternate' type='text/html' href='http://osmanceliks.blogspot.com/2009/06/how-to-use-key-bindings-for-some-swing.html' title='How to use Key Bindings for some Swing components in a GUI'/><author><name>Osman Celik</name><uri>http://www.blogger.com/profile/17228911604983990032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_7D1g3QccvEg/Si_Eq7Y23sI/AAAAAAAAAAM/NQlngvRgIlY/S220/Celik_jpg.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6582284661533567119.post-413034931276479030</id><published>2009-06-19T07:24:00.001-07:00</published><updated>2009-06-19T08:14:53.064-07:00</updated><title type='text'>How to use Netbeans Progress bar</title><content type='html'>Package org.netbeans.api.progress Description &lt;br /&gt;This API allows to visualize tracking for progress of long lasting tasks.&lt;br /&gt;&lt;br /&gt;The usual usecase goes like this: &lt;br /&gt;&lt;br /&gt;&lt;pre class ="java" name="code"&gt;&lt;br /&gt;&lt;br /&gt;ProgressHandle handle = ProgressHandleFactory.createHandle("My custom task");&lt;br /&gt;...&lt;br /&gt;// we have 100 workunits&lt;br /&gt;// at this point the task appears in status bar.&lt;br /&gt;handle.start(100);&lt;br /&gt;...&lt;br /&gt;handle.progress(10);&lt;br /&gt;...&lt;br /&gt;handle.progress(50);&lt;br /&gt;...&lt;br /&gt;// at this point the task is finished and removed from status bar&lt;br /&gt;handle.finish();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://bits.netbeans.org/dev/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/package-summary.html"&gt;&lt;br /&gt;http://bits.netbeans.org/dev/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/package-summary.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6582284661533567119-413034931276479030?l=osmanceliks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://osmanceliks.blogspot.com/feeds/413034931276479030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://osmanceliks.blogspot.com/2009/06/package-org.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6582284661533567119/posts/default/413034931276479030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6582284661533567119/posts/default/413034931276479030'/><link rel='alternate' type='text/html' href='http://osmanceliks.blogspot.com/2009/06/package-org.html' title='How to use Netbeans Progress bar'/><author><name>Osman Celik</name><uri>http://www.blogger.com/profile/17228911604983990032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/_7D1g3QccvEg/Si_Eq7Y23sI/AAAAAAAAAAM/NQlngvRgIlY/S220/Celik_jpg.jpg'/></author><thr:total>0</thr:total></entry></feed>
