Board index » jbuilder » KeyListener and StaticBrowserListener

KeyListener and StaticBrowserListener


2005-06-18 06:11:51 PM
jbuilder3
1.) Say you create an OT with custom JFrame or JDialog based views without
any cancel buttons and you want to dispose or hide these views not only by
using the mouse and so additionally via the help of some KeyListener which
you added inside your view classes. E.g. say when a view has the focus
pressing the Esc key should dispose the view. Something like this :
...
yourview.addKeyListener(new KeyHandler());
...
...
class KeyHandler extends KeyAdapter
{
public void keyPressed(KeyEvent evt)
{
if (evt.isConsumed())
return;
if(evt.getKeyCode() == evt.VK_ESCAPE)
{
yourview.dispose();
evt.consume();
}
}
}
AFAI can see this doesn't work nowadays in JB for the above mentioned OT
scenario, even I remember that it did so for old JB versions. What's the
recommended way to perform the above sketched for JB OTs?
2.) Also, is "Browser.addStaticBrowserListener(...)" supposed to be
recognized and acknowledged when placed into an OT's "initOpenTool(...)"
method like this...
...
Browser.addStaticBrowserListener(new BrowserAdapter() {
public void browserOpened(Browser browser) {
// we want to force an autostart of the OT here if some boolean
flag is set true
}
});
...
...during some tryouts this doesn't work. What's the recommended method for
performimg an autostarting of a custom OT when the JB browser is opening or
has been opened?
 
 

Re:KeyListener and StaticBrowserListener

(1) The OpenTool answer is to based your class on either BasicDialog or
DefaultDialog, then use the setCancelButton() method which handle the ESC
key for you (either to a Cancel button or to a default button). Otherwise
it is an 100% Swing issue. Internally the JBuilder classes do something
similar to what you can see in javax.swing.JColorChooser.
(2) The browserOpened() event is fired when the Browser is opened. This
happens when the "PreUI" category completes loading. So if your OpenTool
loads as part of the "UI" category or later, your tool will not have been
loaded/registered at the time the event is fired. The proper autostarting
depends on what you are doing, generally you should let JBuilder load you at
the correct time by assigning it to the property category.
Note that the Browser has a two-stage initialization. It shows itself after
"PreUI" so it is visible but disabled all through the loading of tools for
the "UI category. Then the "Browser" category is loaded causing the last
opened project to be re-opened.
"Valentino Kyriakides" < XXXX@XXXXX.COM >wrote in message
Quote
1.) Say you create an OT with custom JFrame or JDialog based views without
any cancel buttons and you want to dispose or hide these views not only by
using the mouse and so additionally via the help of some KeyListener which
you added inside your view classes. E.g. say when a view has the focus
pressing the Esc key should dispose the view. Something like this :

...
yourview.addKeyListener(new KeyHandler());
...
...
class KeyHandler extends KeyAdapter
{
public void keyPressed(KeyEvent evt)
{
if (evt.isConsumed())
return;

if(evt.getKeyCode() == evt.VK_ESCAPE)
{
yourview.dispose();
evt.consume();
}
}
}


AFAI can see this doesn't work nowadays in JB for the above mentioned OT
scenario, even I remember that it did so for old JB versions. What's the
recommended way to perform the above sketched for JB OTs?



2.) Also, is "Browser.addStaticBrowserListener(...)" supposed to be
recognized and acknowledged when placed into an OT's "initOpenTool(...)"
method like this...

...
Browser.addStaticBrowserListener(new BrowserAdapter() {
public void browserOpened(Browser browser) {
// we want to force an autostart of the OT here if some boolean
flag is set true
}
});
...

...during some tryouts this doesn't work. What's the recommended method
for
performimg an autostarting of a custom OT when the JB browser is opening
or
has been opened?


 

Re:KeyListener and StaticBrowserListener

Well, related to (1) even I know that DefaultDialog can make use of the
Cancel button here in order to handle the ESC key, my windows (jframe,
jdialog...) don't have and use any buttons at all. So my OT components just
have and offer the plain window's title bar close button operation. I wanted
to additionally support the Esc key handling as another possible closing
method for the windows. However, those usual 100% Swing mechanisms -as
mentioned in my initial posting- don't seem to work.
(2) Hmm, in my OT's manifest I used just one single "OpenTools-UI" category
entry, since the OT uses a toolbar state button, a Tools menu entry and also
some project view context menu entries. Inside the OT's "initOpenTool()"
method I used so far an own preferences boolean flag, which is read during
the OT's loading phase from an own OT specific persistent properties file.
E.g. something like...
Browser.addStaticBrowserListener(new BrowserAdapter() {
public void browserOpened(Browser browser) {
ACTION_MemMonitor.setState(memmon.MemoryMonitorPlugin.class,
MEMMON_AUTOSTART.getBoolean());
if (MEMMON_AUTOSTART.getBoolean() == true)
service.ACTION_MemMon.actionPerformed(browser);
}
});
...
...
What would be the right assigned manifest category for the above shown, in
order to get a chance that JB can perform an autostart for the OT when the
JB browser opens?
"Bill Joy" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
(1) The OpenTool answer is to based your class on either BasicDialog or
DefaultDialog, then use the setCancelButton() method which handle the ESC
key for you (either to a Cancel button or to a default button). Otherwise
it is an 100% Swing issue. Internally the JBuilder classes do something
similar to what you can see in javax.swing.JColorChooser.

(2) The browserOpened() event is fired when the Browser is opened. This
happens when the "PreUI" category completes loading. So if your OpenTool
loads as part of the "UI" category or later, your tool will not have been
loaded/registered at the time the event is fired. The proper autostarting
depends on what you are doing, generally you should let JBuilder load you
at
the correct time by assigning it to the property category.

Note that the Browser has a two-stage initialization. It shows itself
after
"PreUI" so it is visible but disabled all through the loading of tools for
the "UI category. Then the "Browser" category is loaded causing the last
opened project to be re-opened.


"Valentino Kyriakides" < XXXX@XXXXX.COM >wrote in message
news:42b3f2c5$ XXXX@XXXXX.COM ...
>1.) Say you create an OT with custom JFrame or JDialog based views
without
>any cancel buttons and you want to dispose or hide these views not only
by
>using the mouse and so additionally via the help of some KeyListener
which
>you added inside your view classes. E.g. say when a view has the focus
>pressing the Esc key should dispose the view. Something like this :
>
>...
>yourview.addKeyListener(new KeyHandler());
>...
>...
>class KeyHandler extends KeyAdapter
>{
>public void keyPressed(KeyEvent evt)
>{
>if (evt.isConsumed())
>return;
>
>if(evt.getKeyCode() == evt.VK_ESCAPE)
>{
>yourview.dispose();
>evt.consume();
>}
>}
>}
>
>
>AFAI can see this doesn't work nowadays in JB for the above mentioned OT
>scenario, even I remember that it did so for old JB versions. What's the
>recommended way to perform the above sketched for JB OTs?
>
>
>
>2.) Also, is "Browser.addStaticBrowserListener(...)" supposed to be
>recognized and acknowledged when placed into an OT's "initOpenTool(...)"
>method like this...
>
>...
>Browser.addStaticBrowserListener(new BrowserAdapter() {
>public void browserOpened(Browser browser) {
>// we want to force an autostart of the OT here if some
boolean
>flag is set true
>}
>});
>...
>
>...during some tryouts this doesn't work. What's the recommended method
>for
>performimg an autostarting of a custom OT when the JB browser is opening
>or
>has been opened?
>
>


 

{smallsort}